diff --git a/.travis.yml b/.travis.yml index 71357fb51..77f96bb2c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -20,16 +20,20 @@ matrix: fast_finish: true include: - - php: 7.0 + - php: 7.1 env: PHPCS=1 DEFAULT=0 - - php: 7.0 + - php: 7.1 env: PHPSTAN=1 DEFAULT=0 + - php: 5.6 + env: PREFER_LOWEST=1 + before_script: - - if [[ $TRAVIS_PHP_VERSION != 7.0 && $TRAVIS_PHP_VERSION != 7.2 ]]; then phpenv config-rm xdebug.ini; fi + - if [[ $TRAVIS_PHP_VERSION != 7.1 ]]; then phpenv config-rm xdebug.ini; fi - - composer install --prefer-dist --no-interaction + - if [[ $PREFER_LOWEST != 1 ]]; then composer install --no-interaction; fi + - if [[ $PREFER_LOWEST = 1 ]]; then composer update --no-interaction --prefer-lowest --prefer-stable; fi - if [[ $DB = 'mysql' ]]; then mysql -e 'CREATE DATABASE cakephp_test;'; fi - if [[ $DB = 'pgsql' ]]; then psql -c 'CREATE DATABASE cakephp_test;' -U postgres; fi @@ -38,14 +42,14 @@ before_script: - if [[ $PHPSTAN = 1 ]]; then composer require phpstan/phpstan:^0.9; fi script: - - if [[ $DEFAULT = 1 && $TRAVIS_PHP_VERSION != 7.0 ]]; then vendor/bin/phpunit; fi - - if [[ $DEFAULT = 1 && $TRAVIS_PHP_VERSION = 7.0 ]]; then vendor/bin/phpunit --coverage-clover=clover.xml; fi + - if [[ $DEFAULT = 1 && $TRAVIS_PHP_VERSION != 7.1 ]]; then vendor/bin/phpunit; fi + - if [[ $DEFAULT = 1 && $TRAVIS_PHP_VERSION = 7.1 ]]; then vendor/bin/phpunit --coverage-clover=clover.xml; fi - if [[ $PHPCS = 1 ]]; then vendor/bin/phpcs -p --extensions=php --standard=vendor/cakephp/cakephp-codesniffer/CakePHP ./src ./tests; fi - if [[ $PHPSTAN = 1 ]]; then vendor/bin/phpstan analyse -c phpstan.neon -l 4 src; fi after_success: - - if [[ $DEFAULT = 1 && $TRAVIS_PHP_VERSION = 7.0 ]]; then bash <(curl -s https://codecov.io/bash); fi + - if [[ $DEFAULT = 1 && $TRAVIS_PHP_VERSION = 7.1 ]]; then bash <(curl -s https://codecov.io/bash); fi notifications: email: false diff --git a/aliases.php b/aliases.php new file mode 100644 index 000000000..721631408 --- /dev/null +++ b/aliases.php @@ -0,0 +1,15 @@ +name; + } + /** * Dispatches the controller action. Checks that the action exists and isn't private. * diff --git a/src/Listener/RelatedModelsListener.php b/src/Listener/RelatedModelsListener.php index 4235ff95b..f9f0dbd5f 100644 --- a/src/Listener/RelatedModelsListener.php +++ b/src/Listener/RelatedModelsListener.php @@ -37,7 +37,12 @@ public function implementedEvents() */ public function beforePaginate(Event $event) { - $contained = $event->getSubject()->query->getContain(); + $method = 'contain'; + if (method_exists($event->getSubject()->query, 'getContain')) { + $method = 'getContain'; + } + $contained = $event->getSubject()->query->$method(); + if (!empty($contained)) { return; } diff --git a/tests/TestCase/Controller/Component/CrudComponentTest.php b/tests/TestCase/Controller/Component/CrudComponentTest.php index 8bad87249..d3976a974 100644 --- a/tests/TestCase/Controller/Component/CrudComponentTest.php +++ b/tests/TestCase/Controller/Component/CrudComponentTest.php @@ -56,6 +56,7 @@ public function getLog($params = []) class CrudExamplesController extends \Cake\Controller\Controller { + use \Crud\Controller\ControllerTrait; public $modelClass = 'CrudExamples'; diff --git a/tests/TestCase/Listener/ApiListenerTest.php b/tests/TestCase/Listener/ApiListenerTest.php index a8a0940c1..58079f12c 100644 --- a/tests/TestCase/Listener/ApiListenerTest.php +++ b/tests/TestCase/Listener/ApiListenerTest.php @@ -538,7 +538,7 @@ public function testEnsureSerializeWithoutViewVar() ->getMock(); $controller = $this - ->getMockBuilder('\Cake\Controller\Controller') + ->getMockBuilder('\Crud\Test\App\Controller\BlogsController') ->setMethods(['set']) ->disableOriginalConstructor() ->getMock(); diff --git a/tests/TestCase/Listener/RelatedModelsListenerTest.php b/tests/TestCase/Listener/RelatedModelsListenerTest.php index f8c2f4d61..647777184 100644 --- a/tests/TestCase/Listener/RelatedModelsListenerTest.php +++ b/tests/TestCase/Listener/RelatedModelsListenerTest.php @@ -287,7 +287,7 @@ public function testbeforePaginate() $table = $this ->getMockBuilder('\Cake\ORM\Table') ->disableOriginalConstructor() - ->setMethods(['associations', 'findAssociation', 'getSchema']) + ->setMethods(['associations', 'findAssociation', 'association', 'getSchema']) ->getMock(); $table @@ -309,7 +309,11 @@ public function testbeforePaginate() $event = new Event('beforePaginate', $subject); $listener->beforePaginate($event); - $result = $event->getSubject()->query->getContain(); + if (method_exists($event->getSubject()->query, 'getContain')) { + $result = $event->getSubject()->query->getContain(); + } else { + $result = $event->getSubject()->query->contain(); + } $this->assertEquals(['Users' => []], $result); }