Skip to content

Commit 360874e

Browse files
committed
Merge branch '4.x'
* 4.x: Fix test model misconfiguration Fix deprecated phpunit calls Make tests pass again Fix too few arguments exception Migrations: Split change() into up() and down() Bump dependencies Apply suggested changes Resolve 'Array and string offset access syntax with curly braces is deprecated' for php 7.4 Resolve Deprecated Error: App::path() is deprecated for class path Update tests/bootstrap.php Resolve tests Restor trevis file and retry Made suggested changes to travis.yml Remove old php versions from travis.yml Patch some tests Make shell declarations compatible with 4.x-dev Update composer.json Make table declarations compatible with with 4.x-dev
2 parents 2a26dc6 + e4f1e0c commit 360874e

30 files changed

Lines changed: 258 additions & 260 deletions

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
/composer.lock
22
/vendor
33
/phpunit.xml
4+
.phpunit.result.cache
5+
.idea

.travis.yml

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
language: php
22

33
php:
4-
- 5.6
5-
- 7.0
6-
- 7.1
74
- 7.2
85
- 7.3
96
- 7.4
@@ -27,14 +24,11 @@ matrix:
2724
fast_finish: true
2825

2926
include:
30-
- php: 7.0
27+
- php: 7.2
3128
env: MINIMUMS=1 DEFAULT=1 DB=mysql db_dsn='mysql://travis@0.0.0.0/cakephp_test'
3229

33-
- php: 7.0
34-
env: PHPCS=1 DEFAULT=0
35-
3630
before_install:
37-
- if [[ $TRAVIS_PHP_VERSION != 7.3 ]]; then phpenv config-rm xdebug.ini; fi
31+
- if [[ $TRAVIS_PHP_VERSION != "7.4" ]]; then phpenv config-rm xdebug.ini; fi
3832

3933
- if [ -n "$GH_TOKEN" ]; then composer config github-oauth.github.com ${GH_TOKEN}; fi;
4034

composer.json

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "cakephp/acl",
3-
"description": "Acl Plugin for CakePHP 3.x framework",
3+
"description": "Acl Plugin for CakePHP framework",
44
"type": "cakephp-plugin",
55
"keywords": [
66
"cakephp",
@@ -21,12 +21,13 @@
2121
"source": "https://github.com/cakephp/acl"
2222
},
2323
"require": {
24-
"cakephp/cakephp": "^3.8.2",
25-
"cakephp/plugin-installer": "*"
24+
"php": "^7.2",
25+
"cakephp/cakephp": "^4.0",
26+
"cakephp/plugin-installer": "^1.2"
2627
},
2728
"require-dev": {
28-
"cakephp/cakephp-codesniffer": "^3.0",
29-
"phpunit/phpunit": "^5.7.14|^6.0"
29+
"cakephp/cakephp-codesniffer": "~4.2.0",
30+
"phpunit/phpunit": "^8.0"
3031
},
3132
"autoload": {
3233
"psr-4": {
@@ -36,7 +37,10 @@
3637
"autoload-dev": {
3738
"psr-4": {
3839
"Acl\\Test\\": "tests/",
39-
"Cake\\Test\\": "vendor/cakephp/cakephp/tests/"
40+
"Cake\\Test\\": "vendor/cakephp/cakephp/tests/",
41+
"TestApp\\": "tests/test_app/TestApp"
42+
4043
}
41-
}
44+
},
45+
"minimum-stability": "dev"
4246
}

config/Migrations/20141229162641_cake_php_db_acl.php

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,9 @@ class CakePhpDbAcl extends AbstractMigration
66
{
77

88
/**
9-
* Change Method.
10-
*
11-
* More information on this method is available here:
12-
* http://docs.phinx.org/en/latest/migrations.html#the-change-method
13-
*
14-
* Uncomment this method if you would like to use it.
15-
*
9+
* Migrate Up.
1610
*/
17-
public function change()
11+
public function up()
1812
{
1913
$table = $this->table('acos');
2014
$table->addColumn('parent_id', 'integer',['null'=>true])
@@ -48,18 +42,14 @@ public function change()
4842
->create();
4943
}
5044

51-
/**
52-
* Migrate Up.
53-
*/
54-
public function up()
55-
{
56-
}
57-
5845
/**
5946
* Migrate Down.
6047
*/
6148
public function down()
6249
{
50+
$this->table('aros_acos')->drop()->save();
51+
$this->table('acos')->drop()->save();
52+
$this->table('aros')->drop()->save();
6353
}
6454

6555
}

phpunit.xml.dist

Lines changed: 36 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,54 +1,43 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22

33
<phpunit
4-
colors="true"
5-
processIsolation="false"
6-
stopOnFailure="false"
7-
syntaxCheck="false"
8-
bootstrap="./tests/bootstrap.php"
9-
>
10-
<php>
11-
<ini name="memory_limit" value="-1"/>
12-
<ini name="apc.enable_cli" value="1"/>
13-
</php>
4+
colors="true"
5+
processIsolation="false"
6+
stopOnFailure="false"
7+
bootstrap="./tests/bootstrap.php"
8+
>
9+
<php>
10+
<ini name="memory_limit" value="-1"/>
11+
<ini name="apc.enable_cli" value="1"/>
12+
13+
<!-- SQLite
14+
<env name="db_class" value="Cake\Database\Driver\Sqlite"/>
15+
<env name="db_dsn" value="sqlite:///:memory:"/>
16+
-->
17+
<!-- Postgres
18+
<env name="db_dsn" value="postgres://localhost/cake_test?timezone=UTC"/>
19+
-->
20+
<!-- Mysql
21+
<env name="db_dsn" value="mysql://localhost/cake_test?timezone=UTC"/>
22+
-->
23+
<!-- SQL Server
24+
<env name="db_dsn" value="sqlserver://localhost/cake_test?timezone=UTC"/>
25+
-->
26+
</php>
27+
28+
<testsuites>
29+
<testsuite name="Acl Plugin Test Suite">
30+
<directory>./tests/TestCase/</directory>
31+
</testsuite>
32+
</testsuites>
33+
<listeners>
34+
<listener class="\Cake\TestSuite\Fixture\FixtureInjector" file="./vendor/cakephp/cakephp/src/TestSuite/Fixture/FixtureInjector.php">
35+
<arguments>
36+
<object class="\Cake\TestSuite\Fixture\FixtureManager" />
37+
</arguments>
38+
</listener>
39+
</listeners>
1440

15-
<testsuites>
16-
<testsuite name="Acl Plugin Test Suite">
17-
<directory>./tests/TestCase/</directory>
18-
</testsuite>
19-
</testsuites>
20-
<listeners>
21-
<listener class="\Cake\TestSuite\Fixture\FixtureInjector" file="./vendor/cakephp/cakephp/src/TestSuite/Fixture/FixtureInjector.php">
22-
<arguments>
23-
<object class="\Cake\TestSuite\Fixture\FixtureManager" />
24-
</arguments>
25-
</listener>
26-
</listeners>
27-
<php>
28-
<!-- SQLite
29-
<env name="db_class" value="Cake\Database\Driver\Sqlite"/>
30-
<env name="db_dsn" value="sqlite::memory:"/>
31-
-->
32-
<!-- Postgres
33-
<env name="db_class" value="Cake\Database\Driver\Postgres"/>
34-
<env name="db_database" value="cake_test"/>
35-
<env name="db_login" value=""/>
36-
<env name="db_password" value=""/>
37-
-->
38-
<!-- Mysql
39-
<env name="db_class" value="Cake\Database\Driver\Mysql"/>
40-
<env name="db_dsn" value="mysql:host=localhost;dbname=cake_test"/>
41-
<env name="db_database" value=""/>
42-
<env name="db_login" value=""/>
43-
<env name="db_password" value=""/>
44-
-->
45-
<!-- SQL Server
46-
<env name="db_class" value="Cake\Database\Driver\Sqlserver"/>
47-
<env name="db_dsn" value="sqlsrv:Server=localhost;Database=cake_test;MultipleActiveResultSets=false"/>
48-
<env name="db_login" value=""/>
49-
<env name="db_password" value=""/>
50-
-->
51-
</php>
5241
<filter>
5342
<whitelist>
5443
<directory suffix=".php">./src/</directory>

src/AclExtras.php

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
use Cake\Routing\Router;
2727
use Cake\Utility\Hash;
2828
use Cake\Utility\Inflector;
29+
use ReflectionException;
2930

3031
/**
3132
* Provides features for additional ACL operations.
@@ -222,9 +223,9 @@ protected function _processPrefixes($root)
222223
$pathNode = $this->_checkNode($path, $prefix, $root->id);
223224
$this->foundACOs[$root->id][] = $prefix;
224225
if (isset($this->foundACOs[$pathNode->id])) {
225-
$this->foundACOs[$pathNode->id] += $this->_updateControllers($pathNode, $controllers, null, $prefix);
226+
$this->foundACOs[$pathNode->id] += $this->_updateControllers($pathNode, $controllers, '', $prefix);
226227
} else {
227-
$this->foundACOs[$pathNode->id] = $this->_updateControllers($pathNode, $controllers, null, $prefix);
228+
$this->foundACOs[$pathNode->id] = $this->_updateControllers($pathNode, $controllers, '', $prefix);
228229
}
229230
}
230231
}
@@ -235,7 +236,7 @@ protected function _processPrefixes($root)
235236
* @param string $plugin The name of the plugin to alias
236237
* @return string
237238
*/
238-
protected function _pluginAlias($plugin)
239+
protected function _pluginAlias(string $plugin) :string
239240
{
240241
return preg_replace('/\//', '\\', Inflector::camelize($plugin));
241242
}
@@ -305,7 +306,7 @@ protected function _processPlugins($root, array $plugins = [])
305306
* @param string $prefix Name of the prefix you are making controllers for.
306307
* @return array
307308
*/
308-
protected function _updateControllers($root, $controllers, $plugin = null, $prefix = null)
309+
protected function _updateControllers($root, array $controllers, string $plugin = '', string $prefix = '')
309310
{
310311
$pluginPath = $this->_pluginAlias($plugin);
311312

@@ -350,12 +351,12 @@ protected function _updateControllers($root, $controllers, $plugin = null, $pref
350351
public function getControllerList($plugin = null, $prefix = null)
351352
{
352353
if (!$plugin) {
353-
$path = App::path('Controller' . (empty($prefix) ? '' : DS . Inflector::camelize($prefix)));
354+
$path = App::classPath('Controller' . (empty($prefix) ? '' : DS . Inflector::camelize($prefix)));
354355
$dir = new Folder($path[0]);
355356
$controllers = $dir->find('.*Controller\.php');
356357
} else {
357-
$path = App::path('Controller' . (empty($prefix) ? '' : DS . Inflector::camelize($prefix)), $plugin);
358-
$dir = new Folder($path[0]);
358+
$path = Plugin::classPath($plugin) . 'Controller' . DS. (empty($prefix) ? '' : DS . Inflector::camelize($prefix));
359+
$dir = new Folder($path);
359360
$controllers = $dir->find('.*Controller\.php');
360361
}
361362

src/Adapter/CachedDbAcl.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ public function check($aro, $aco, $action = "*")
6666
*/
6767
public function allow($aro, $aco, $actions = "*", $value = 1)
6868
{
69-
Cache::clear(false, $this->_cacheConfig);
69+
Cache::clear($this->_cacheConfig);
7070

7171
return parent::allow($aro, $aco, $actions, $value);
7272
}

src/Auth/ActionsAuthorize.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ class ActionsAuthorize extends BaseAuthorize
3535
* @param \Cake\Network\Request $request The request needing authorization.
3636
* @return bool
3737
*/
38-
public function authorize($user, ServerRequest $request)
38+
public function authorize($user, ServerRequest $request) :bool
3939
{
4040
$Acl = $this->_registry->load('Acl');
4141
$user = [$this->_config['userModel'] => $user];

src/Auth/CrudAuthorize.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ public function __construct(ComponentRegistry $registry, $config = [])
5353
* @param \Cake\Network\Request $request The request needing authorization.
5454
* @return bool
5555
*/
56-
public function authorize($user, ServerRequest $request)
56+
public function authorize($user, ServerRequest $request): bool
5757
{
5858
$mapped = $this->getConfig('actionMap.' . $request->getParam('action'));
5959

src/Model/Table/AclNodesTable.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ class AclNodesTable extends Table
3636
*
3737
* @return void
3838
*/
39-
public static function defaultConnectionName()
39+
public static function defaultConnectionName() :string
4040
{
4141
return Configure::read('Acl.database');
4242
}

0 commit comments

Comments
 (0)