Skip to content

Commit

Permalink
Adds phpcs and resolves phpcs errors
Browse files Browse the repository at this point in the history
  • Loading branch information
Chris Nizzardini committed Jan 10, 2024
1 parent 7068719 commit 7a57fc8
Show file tree
Hide file tree
Showing 7 changed files with 51 additions and 35 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ jobs:
- name: Test Suite
run: |
composer test
composer check
#
# CakePHP version compatability
Expand Down
33 changes: 33 additions & 0 deletions tests/AuditLogsTable.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?php
/**
* @copyright Copyright (c) 2024, Canadian Mortgages Inc.
*/
declare(strict_types=1);

namespace AuditStash\Test;

use Cake\ORM\Table;

class AuditLogsTable extends Table
{
public function initialize(array $config): void
{
parent::initialize($config);

$this->setTable('audit_logs');
$this->setPrimaryKey('id');

$this->setSchema([
'id' => 'integer',
'transaction' => 'string',
'type' => 'string',
'primary_key' => 'integer',
'source' => 'string',
'parent_source' => 'string',
'original' => 'string',
'changed' => 'string',
'meta' => 'string',
'created' => 'datetime',
]);
}
}
13 changes: 13 additions & 0 deletions tests/DebugPersister.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php
declare(strict_types=1);

namespace AuditStash\Test;

use AuditStash\PersisterInterface;

class DebugPersister implements PersisterInterface
{
public function logEvents(array $events): void
{
}
}
2 changes: 1 addition & 1 deletion tests/TestCase/Meta/ApplicationMetadataTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public function testDataIsAdded()
$listener = new ApplicationMetadata('my_app', ['extra' => 'thing']);
$this->getEventManager()->on($listener);
$logs[] = new AuditDeleteEvent('1234', 1, 'articles');
$event = $this->dispatchEvent('AuditStash.beforeLog', ['logs' => $logs]);
$this->dispatchEvent('AuditStash.beforeLog', ['logs' => $logs]);

$expected = [
'app_name' => 'my_app',
Expand Down
2 changes: 1 addition & 1 deletion tests/TestCase/Meta/RequestMetadataTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public function testRequestDataIsAdded()
$request->expects($this->once())->method('clientIp')->will($this->returnValue('12345'));
$request->expects($this->once())->method('getRequestTarget')->will($this->returnValue('/things?a=b'));
$logs[] = new AuditDeleteEvent('1234', 1, 'articles');
$event = $this->dispatchEvent('AuditStash.beforeLog', ['logs' => $logs]);
$this->dispatchEvent('AuditStash.beforeLog', ['logs' => $logs]);

$expected = [
'ip' => '12345',
Expand Down
9 changes: 1 addition & 8 deletions tests/TestCase/Model/Behavior/AuditIntegrationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,11 @@
use AuditStash\Event\AuditDeleteEvent;
use AuditStash\Event\AuditUpdateEvent;
use AuditStash\Model\Behavior\AuditLogBehavior;
use AuditStash\PersisterInterface;
use AuditStash\Test\DebugPersister;
use Cake\ORM\Locator\LocatorAwareTrait;
use Cake\ORM\Table;
use Cake\TestSuite\TestCase;

class DebugPersister implements PersisterInterface
{
public function logEvents(array $events): void
{
}
}

class AuditIntegrationTest extends TestCase
{
use LocatorAwareTrait;
Expand Down
25 changes: 1 addition & 24 deletions tests/TestCase/Persister/TablePersisterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

use AuditStash\Event\AuditCreateEvent;
use AuditStash\Persister\TablePersister;
use AuditStash\Test\AuditLogsTable;
use Cake\Datasource\EntityInterface;
use Cake\ORM\Entity;
use Cake\ORM\Table;
Expand All @@ -13,30 +14,6 @@
use InvalidArgumentException;
use PHPUnit\Framework\MockObject\MockObject;

class AuditLogsTable extends Table
{
public function initialize(array $config): void
{
parent::initialize($config);

$this->setTable('audit_logs');
$this->setPrimaryKey('id');

$this->setSchema([
'id' => 'integer',
'transaction' => 'string',
'type' => 'string',
'primary_key' => 'integer',
'source' => 'string',
'parent_source' => 'string',
'original' => 'string',
'changed' => 'string',
'meta' => 'string',
'created' => 'datetime',
]);
}
}

class TablePersisterTest extends TestCase
{
/**
Expand Down

0 comments on commit 7a57fc8

Please sign in to comment.