Skip to content

Commit

Permalink
Cake 4.x (#43)
Browse files Browse the repository at this point in the history
* Update composer.json

* Update composer.json

* Update composer.json

* Update RequestMetadata.php

* Update AuditLogBehavior.php

* Update composer.json

* Cake4 only

* Update .travis.yml

* Update ElasticMappingShell.php

* additional changes

* fix testsuite errors

* revert

Co-authored-by: Ali1 <ali.m.bakir@gmail.com>
  • Loading branch information
swiffer and Ali1 authored Feb 18, 2020
1 parent 0986ab1 commit f8f1ca0
Show file tree
Hide file tree
Showing 11 changed files with 30 additions and 30 deletions.
3 changes: 2 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
language: php

php:
- 7.1
- 7.2
- 7.3
- 7.4

sudo: true

Expand Down
12 changes: 6 additions & 6 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
"type": "cakephp-plugin",
"license": "MIT",
"require": {
"php": ">=7.0.0",
"cakephp/orm": "^3.0"
"php": ">=7.2",
"cakephp/orm": "^4.0"
},
"require-dev": {
"phpunit/phpunit": "^6.0",
"cakephp/cakephp": "^3.6",
"cakephp/elastic-search": "^2.0-dev",
"phpunit/phpunit": "^8.0",
"cakephp/cakephp": "^4.0",
"cakephp/elastic-search": "dev-cake-4.x-updates",
"friendsofcake/process-mq": "dev-master"
},
"suggest": {
Expand All @@ -29,4 +29,4 @@
"Cake\\Test\\": "./vendor/cakephp/cakephp/tests"
}
}
}
}
1 change: 0 additions & 1 deletion phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
colors="true"
processIsolation="false"
stopOnFailure="false"
syntaxCheck="false"
bootstrap="./tests/bootstrap.php"
>
<php>
Expand Down
2 changes: 1 addition & 1 deletion src/Meta/ApplicationMetadata.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public function __construct($name, $data = [])
*
* @return array
*/
public function implementedEvents()
public function implementedEvents(): array
{
return ['AuditStash.beforeLog' => 'beforeLog'];
}
Expand Down
2 changes: 1 addition & 1 deletion src/Meta/RequestMetadata.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public function __construct($request, $user = null)
*
* @return array
*/
public function implementedEvents()
public function implementedEvents(): array
{
return ['AuditStash.beforeLog' => 'beforeLog'];
}
Expand Down
2 changes: 1 addition & 1 deletion src/Model/Behavior/AuditLogBehavior.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class AuditLogBehavior extends Behavior
*
* @return array
*/
public function implementedEvents()
public function implementedEvents(): array
{
return [
'Model.beforeSave' => 'injectTracking',
Expand Down
3 changes: 2 additions & 1 deletion src/Shell/ElasticMappingShell.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace AuditStash\Shell;

use Cake\Console\ConsoleOptionParser;
use Cake\Console\Shell;
use Cake\Datasource\ConnectionManager;
use Cake\Utility\Inflector;
Expand All @@ -16,7 +17,7 @@ class ElasticMappingShell extends Shell
/**
* {@inheritdoc}
*/
public function getOptionParser()
public function getOptionParser(): ConsoleOptionParser
{
return parent::getOptionParser()
->setDescription('Creates type mappings in elastic search for the tables you want tracked with audit logging')
Expand Down
12 changes: 6 additions & 6 deletions tests/TestCase/Model/Behavior/AuditIntegrationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,19 +29,19 @@ class AuditIntegrationTest extends TestCase
* @var array
*/
public $fixtures = [
'core.articles',
'core.comments',
'core.authors',
'core.tags',
'core.articles_tags',
'core.Articles',
'core.Comments',
'core.Authors',
'core.Tags',
'core.ArticlesTags',
];

/**
* tests setup.
*
* @return void
*/
public function setUp()
public function setUp(): void
{
$this->table = $this->loadModel('Articles');
$this->table->hasMany('Comments');
Expand Down
2 changes: 1 addition & 1 deletion tests/TestCase/Model/Behavior/AuditLogBehaviorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

class AuditLogBehaviorTest extends TestCase
{
public function setUp()
public function setUp(): void
{
parent::setUp();
$this->table = new Table(['table' => 'articles']);
Expand Down
8 changes: 4 additions & 4 deletions tests/TestCase/Persister/ElasticSearchPersisterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ class ElasticSearchPersisterTest extends TestCase
* @var string
*/
public $fixtures = [
'plugin.audit_stash.elastic_articles',
'plugin.audit_stash.elastic_audits',
'plugin.audit_stash.elastic_authors',
'plugin.audit_stash.elastic_tags',
'plugin.AuditStash.ElasticArticles',
'plugin.AuditStash.ElasticAudits',
'plugin.AuditStash.ElasticAuthors',
'plugin.AuditStash.ElasticTags',
];

/**
Expand Down
13 changes: 6 additions & 7 deletions tests/TestCase/Persister/TablePersisterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,11 @@
use Cake\ORM\Table;
use Cake\ORM\TableRegistry;
use Cake\TestSuite\TestCase;
use InvalidArgumentException;

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

Expand Down Expand Up @@ -49,7 +50,7 @@ class TablePersisterTest extends TestCase
*
* @return void
*/
public function setUp()
public function setUp(): void
{
parent::setUp();

Expand All @@ -65,7 +66,7 @@ public function setUp()
*
* @return void
*/
public function tearDown()
public function tearDown(): void
{
unset($this->TablePersister);

Expand Down Expand Up @@ -106,12 +107,10 @@ public function testSetTableAsObject()
$this->assertSame($customTable, $this->TablePersister->getTable());
}

/**
* @expectedException \InvalidArgumentException
* @expectedExceptionMessage The `$table` argument must be either a table alias, or an instance of `\Cake\ORM\Table`.
*/
public function testSetInvalidTable()
{
$this->expectException(InvalidArgumentException::class);
$this->expectExceptionMessage('The `$table` argument must be either a table alias, or an instance of `\Cake\ORM\Table`.');
$this->TablePersister->setTable(null);
}

Expand Down

0 comments on commit f8f1ca0

Please sign in to comment.