diff --git a/composer.json b/composer.json index 22547fbc..8ffd7bba 100644 --- a/composer.json +++ b/composer.json @@ -57,5 +57,10 @@ "@psalm" ], "test": "phpunit" + }, + "config": { + "allow-plugins": { + "dealerdirect/phpcodesniffer-composer-installer": true + } } } diff --git a/tests/TestCase/Controller/Component/SearchComponentTest.php b/tests/TestCase/Controller/Component/SearchComponentTest.php index 779e12ae..bffb5a68 100644 --- a/tests/TestCase/Controller/Component/SearchComponentTest.php +++ b/tests/TestCase/Controller/Component/SearchComponentTest.php @@ -38,8 +38,7 @@ public function setUp(): void { parent::setUp(); - // Router::$initialized = true; - Router::scope('/', function (RouteBuilder $routes) { + Router::createRouteBuilder('/')->scope('/', function (RouteBuilder $routes) { $routes->connect( '/users/my-predictions', ['controller' => 'UserAnswers', 'action' => 'index', 'type' => 'open'], diff --git a/tests/TestCase/Model/Filter/BooleanTest.php b/tests/TestCase/Model/Filter/BooleanTest.php index c82c75d1..c2651141 100644 --- a/tests/TestCase/Model/Filter/BooleanTest.php +++ b/tests/TestCase/Model/Filter/BooleanTest.php @@ -32,7 +32,7 @@ public function testProcessWithFlagOn() $result = $filter->process(); $this->assertTrue($result); - $this->assertRegExp( + $this->assertMatchesRegularExpression( '/WHERE Articles\.is_active = \:c0$/', $filter->getQuery()->sql() ); @@ -54,7 +54,7 @@ public function testProcessWithFlagOff() $filter->setQuery($articles->find()); $filter->process(); - $this->assertRegExp( + $this->assertMatchesRegularExpression( '/WHERE Articles\.is_active = \:c0$/', $filter->getQuery()->sql() ); @@ -76,7 +76,7 @@ public function testProcessWithStringFlagTrue() $filter->setQuery($articles->find()); $filter->process(); - $this->assertRegExp( + $this->assertMatchesRegularExpression( '/WHERE Articles\.is_active = \:c0$/', $filter->getQuery()->sql() ); @@ -98,7 +98,7 @@ public function testProcessWithStringFlagFalse() $filter->setQuery($articles->find()); $filter->process(); - $this->assertRegExp( + $this->assertMatchesRegularExpression( '/WHERE Articles\.is_active = \:c0$/', $filter->getQuery()->sql() ); @@ -120,7 +120,7 @@ public function testProcessWithBooleanFlagTrue() $filter->setQuery($articles->find()); $filter->process(); - $this->assertRegExp( + $this->assertMatchesRegularExpression( '/WHERE Articles\.is_active = \:c0$/', $filter->getQuery()->sql() ); @@ -142,7 +142,7 @@ public function testProcessWithBooleanFlagFalse() $filter->setQuery($articles->find()); $filter->process(); - $this->assertRegExp( + $this->assertMatchesRegularExpression( '/WHERE Articles\.is_active = \:c0$/', $filter->getQuery()->sql() ); @@ -164,7 +164,7 @@ public function testProcessWithStringFlag1() $filter->setQuery($articles->find()); $filter->process(); - $this->assertRegExp( + $this->assertMatchesRegularExpression( '/WHERE Articles\.is_active = \:c0$/', $filter->getQuery()->sql() ); @@ -186,7 +186,7 @@ public function testProcessWithStringFlag0() $filter->setQuery($articles->find()); $filter->process(); - $this->assertRegExp( + $this->assertMatchesRegularExpression( '/WHERE Articles\.is_active = \:c0$/', $filter->getQuery()->sql() ); @@ -208,7 +208,7 @@ public function testProcessWithIntegerFlag1() $filter->setQuery($articles->find()); $filter->process(); - $this->assertRegExp( + $this->assertMatchesRegularExpression( '/WHERE Articles\.is_active = \:c0$/', $filter->getQuery()->sql() ); @@ -227,7 +227,7 @@ public function testProcessWithIntegerFlag0() $filter->setQuery($articles->find()); $filter->process(); - $this->assertRegExp( + $this->assertMatchesRegularExpression( '/WHERE Articles\.is_active = \:c0$/', $filter->getQuery()->sql() ); @@ -286,7 +286,7 @@ public function testProcessMultiField() $filter->setQuery($articles->find()); $filter->process(); - $this->assertRegExp( + $this->assertMatchesRegularExpression( '/WHERE \(Articles\.is_active = :c0 OR Articles\.other = :c1\)$/', $filter->getQuery()->sql() ); @@ -311,7 +311,7 @@ public function testProcessMultiFieldWithAndMode() $filter->setQuery($articles->find()); $filter->process(); - $this->assertRegExp( + $this->assertMatchesRegularExpression( '/WHERE \(Articles\.is_active = :c0 AND Articles\.other = :c1\)$/', $filter->getQuery()->sql() ); @@ -333,7 +333,7 @@ public function testProcessDefaultFallbackForDisallowedMultiValue() $filter->setQuery($articles->find()); $filter->process(); - $this->assertRegExp( + $this->assertMatchesRegularExpression( '/WHERE Articles\.is_active = :c0$/', $filter->getQuery()->sql() ); diff --git a/tests/TestCase/Model/Filter/CallbackTest.php b/tests/TestCase/Model/Filter/CallbackTest.php index 34ccefed..e8016646 100644 --- a/tests/TestCase/Model/Filter/CallbackTest.php +++ b/tests/TestCase/Model/Filter/CallbackTest.php @@ -37,7 +37,7 @@ public function testProcess() $filter->setQuery($articles->find()); $this->assertTrue($filter->process()); - $this->assertRegExp( + $this->assertMatchesRegularExpression( '/WHERE title = \:c0$/', $filter->getQuery()->sql() ); diff --git a/tests/TestCase/Model/Filter/CompareTest.php b/tests/TestCase/Model/Filter/CompareTest.php index 32f8968c..87757974 100644 --- a/tests/TestCase/Model/Filter/CompareTest.php +++ b/tests/TestCase/Model/Filter/CompareTest.php @@ -31,7 +31,7 @@ public function testProcess() $filter->setQuery($articles->find()); $filter->process(); - $this->assertRegExp( + $this->assertMatchesRegularExpression( '/WHERE Articles\.created >= :c0$/', $filter->getQuery()->sql() ); @@ -53,7 +53,7 @@ public function testProcessMode() $filter->setQuery($articles->find()); $filter->process(); - $this->assertRegExp( + $this->assertMatchesRegularExpression( '/WHERE \(Articles\.created >= :c0 AND Articles\.modified >= :c1\)$/', $filter->getQuery()->sql() ); @@ -75,7 +75,7 @@ public function testProcessModeOr() $filter->setQuery($articles->find()); $filter->process(); - $this->assertRegExp( + $this->assertMatchesRegularExpression( '/WHERE \(Articles\.created >= :c0 OR Articles\.modified >= :c1\)$/', $filter->getQuery()->sql() ); @@ -114,7 +114,7 @@ public function testProcessDefaultFallbackForDisallowedMultiValue() $filter->setQuery($articles->find()); $filter->process(); - $this->assertRegExp( + $this->assertMatchesRegularExpression( '/WHERE Articles\.created >= :c0$/', $filter->getQuery()->sql() ); diff --git a/tests/TestCase/Model/Filter/ExistsTest.php b/tests/TestCase/Model/Filter/ExistsTest.php index 217d5ab8..16ee93f7 100644 --- a/tests/TestCase/Model/Filter/ExistsTest.php +++ b/tests/TestCase/Model/Filter/ExistsTest.php @@ -33,7 +33,7 @@ public function testProcessWithFlagOn() $this->assertTrue($result); - $this->assertRegExp( + $this->assertMatchesRegularExpression( '/WHERE \(Articles\.number\) IS NOT NULL$/', $filter->getQuery()->sql() ); @@ -53,7 +53,7 @@ public function testProcessWithFlagOff() $this->assertTrue($result); - $this->assertRegExp( + $this->assertMatchesRegularExpression( '/WHERE \(Articles\.number\) IS NULL$/', $filter->getQuery()->sql() ); @@ -75,7 +75,7 @@ public function testProcessWithFlagOnNotNullable() $this->assertTrue($result); - $this->assertRegExp( + $this->assertMatchesRegularExpression( '/WHERE Articles\.number != \:c0$/', $filter->getQuery()->sql() ); @@ -101,7 +101,7 @@ public function testProcessWithFlagOffNotNullable() $this->assertTrue($result); - $this->assertRegExp( + $this->assertMatchesRegularExpression( '/WHERE Articles\.number = \:c0$/', $filter->getQuery()->sql() ); @@ -161,7 +161,7 @@ public function testProcessMultiField() $this->assertTrue($result); - $this->assertRegExp( + $this->assertMatchesRegularExpression( '/WHERE \(\(Articles\.number\) IS NOT NULL OR \(Articles\.title\) IS NOT NULL\)$/', $filter->getQuery()->sql() ); diff --git a/tests/TestCase/Model/Filter/FinderTest.php b/tests/TestCase/Model/Filter/FinderTest.php index e80e357a..7aea4a83 100644 --- a/tests/TestCase/Model/Filter/FinderTest.php +++ b/tests/TestCase/Model/Filter/FinderTest.php @@ -33,7 +33,7 @@ public function testProcess() $filter->setQuery($articles->find()); $filter->process(); - $this->assertRegExp( + $this->assertMatchesRegularExpression( '/WHERE \(Articles\.is_active = \:c0 AND foo = \:c1\)$/', $filter->getQuery()->sql() ); @@ -60,7 +60,7 @@ public function testProcessMap() $filter->setQuery($articles->find()); $filter->process(); - $this->assertRegExp( + $this->assertMatchesRegularExpression( '/WHERE title = :c0$/', $filter->getQuery()->sql() ); diff --git a/tests/TestCase/Model/Filter/LikeTest.php b/tests/TestCase/Model/Filter/LikeTest.php index 3b61b6d5..f6eeff7f 100644 --- a/tests/TestCase/Model/Filter/LikeTest.php +++ b/tests/TestCase/Model/Filter/LikeTest.php @@ -32,7 +32,7 @@ public function testProcess() $filter->setQuery($articles->find()); $filter->process(); - $this->assertRegExp( + $this->assertMatchesRegularExpression( '/WHERE Articles\.title like \:c0$/', $filter->getQuery()->sql() ); @@ -45,7 +45,7 @@ public function testProcess() $filter->setQuery($articles->find()); $filter->process(); - $this->assertRegExp( + $this->assertMatchesRegularExpression( '/WHERE Articles\.title ilike \:c0$/', $filter->getQuery()->sql() ); @@ -67,7 +67,7 @@ public function testProcessSingleValueWithAndValueMode() $filter->setQuery($articles->find()); $filter->process(); - $this->assertRegExp( + $this->assertMatchesRegularExpression( '/WHERE Articles\.title like :c0$/', $filter->getQuery()->sql() ); @@ -92,7 +92,7 @@ public function testProcessSingleValueAndMultiFieldWithAndValueMode() $filter->setQuery($articles->find()); $filter->process(); - $this->assertRegExp( + $this->assertMatchesRegularExpression( '/WHERE \(Articles\.title like :c0 OR Articles\.other like :c1\)$/', $filter->getQuery()->sql() ); @@ -114,7 +114,7 @@ public function testProcessMultiValue() $filter->setQuery($articles->find()); $filter->process(); - $this->assertRegExp( + $this->assertMatchesRegularExpression( '/WHERE \(Articles\.title like :c0 OR Articles\.title like :c1\)$/', $filter->getQuery()->sql() ); @@ -139,7 +139,7 @@ public function testProcessMultiValueWithAndValueMode() $filter->setQuery($articles->find()); $filter->process(); - $this->assertRegExp( + $this->assertMatchesRegularExpression( '/WHERE \(Articles\.title like :c0 AND Articles\.title like :c1\)$/', $filter->getQuery()->sql() ); @@ -164,7 +164,7 @@ public function testProcessMultiValueAndMultiField() $filter->setQuery($articles->find()); $filter->process(); - $this->assertRegExp( + $this->assertMatchesRegularExpression( '/WHERE \(\(Articles\.title like :c0 OR Articles\.title like :c1\) ' . 'OR \(Articles\.other like :c2 OR Articles\.other like :c3\)\)$/', $filter->getQuery()->sql() @@ -191,7 +191,7 @@ public function testProcessMultiValueAndMultiFieldWithAndFieldMode() $filter->setQuery($articles->find()); $filter->process(); - $this->assertRegExp( + $this->assertMatchesRegularExpression( '/WHERE \(\(Articles\.title like :c0 OR Articles\.title like :c1\) ' . 'AND \(Articles\.other like :c2 OR Articles\.other like :c3\)\)$/', $filter->getQuery()->sql() @@ -277,7 +277,7 @@ public function testProcessDefaultFallbackForDisallowedMultiValue() $filter->setQuery($articles->find()); $filter->process(); - $this->assertRegExp( + $this->assertMatchesRegularExpression( '/WHERE Articles\.title like :c0$/', $filter->getQuery()->sql() ); diff --git a/tests/TestCase/Model/Filter/ValueTest.php b/tests/TestCase/Model/Filter/ValueTest.php index f8661c9b..00487158 100644 --- a/tests/TestCase/Model/Filter/ValueTest.php +++ b/tests/TestCase/Model/Filter/ValueTest.php @@ -31,7 +31,7 @@ public function testProcess() $filter->setQuery($articles->find()); $filter->process(); - $this->assertRegExp( + $this->assertMatchesRegularExpression( '/WHERE Articles\.title = :c0$/', $filter->getQuery()->sql() ); @@ -53,7 +53,7 @@ public function testProcessSingleValueWithAndMode() $filter->setQuery($articles->find()); $filter->process(); - $this->assertRegExp( + $this->assertMatchesRegularExpression( '/WHERE Articles\.title = :c0$/', $filter->getQuery()->sql() ); @@ -77,7 +77,7 @@ public function testProcessSingleValueAndMultiField() $filter->setQuery($articles->find()); $filter->process(); - $this->assertRegExp( + $this->assertMatchesRegularExpression( '/WHERE \(Articles\.title = :c0 OR Articles\.other = :c1\)$/', $filter->getQuery()->sql() ); @@ -102,7 +102,7 @@ public function testProcessSingleValueAndMultiFieldWithAndMode() $filter->setQuery($articles->find()); $filter->process(); - $this->assertRegExp( + $this->assertMatchesRegularExpression( '/WHERE \(Articles\.title = :c0 AND Articles\.other = :c1\)$/', $filter->getQuery()->sql() ); @@ -124,7 +124,7 @@ public function testProcessMultiValue() $filter->setQuery($articles->find()); $filter->process(); - $this->assertRegExp( + $this->assertMatchesRegularExpression( '/WHERE Articles\.title IN \(:c0,:c1\)$/', $filter->getQuery()->sql() ); @@ -149,7 +149,7 @@ public function testProcessMultiValueWithAndMode() $filter->setQuery($articles->find()); $filter->process(); - $this->assertRegExp( + $this->assertMatchesRegularExpression( '/WHERE Articles\.title IN \(:c0,:c1\)$/', $filter->getQuery()->sql() ); @@ -174,7 +174,7 @@ public function testProcessMultiValueAndMultiField() $filter->setQuery($articles->find()); $filter->process(); - $this->assertRegExp( + $this->assertMatchesRegularExpression( '/WHERE \(Articles\.title IN \(:c0,:c1\) ' . 'OR Articles\.other IN \(:c2,:c3\)\)$/', $filter->getQuery()->sql() @@ -201,7 +201,7 @@ public function testProcessMultiValueAndMultiFieldWithAndMode() $filter->setQuery($articles->find()); $filter->process(); - $this->assertRegExp( + $this->assertMatchesRegularExpression( '/WHERE \(Articles\.title IN \(:c0,:c1\) ' . 'AND Articles\.other IN \(:c2,:c3\)\)$/', $filter->getQuery()->sql() @@ -224,7 +224,7 @@ public function testProcessMultiValueWithNonScalarValue() $filter->setQuery($articles->find()); $filter->process(); - $this->assertRegExp( + $this->assertMatchesRegularExpression( '/WHERE Articles\.title IN \(:c0\)$/', $filter->getQuery()->sql() ); @@ -262,7 +262,7 @@ public function testProcessDefaultFallbackForDisallowedMultiValue() $filter->setQuery($articles->find()); $filter->process(); - $this->assertRegExp( + $this->assertMatchesRegularExpression( '/WHERE Articles\.title = :c0$/', $filter->getQuery()->sql() ); @@ -303,7 +303,7 @@ public function testProcessCaseInsensitiveMode() $filter->setQuery($articles->find()); $filter->process(); - $this->assertRegExp( + $this->assertMatchesRegularExpression( '/WHERE Articles\.title IN \(:c0,:c1\)$/', $filter->getQuery()->sql() ); @@ -327,7 +327,7 @@ public function testProcessNegation() $filter->setQuery($articles->find()); $filter->process(); - $this->assertRegExp( + $this->assertMatchesRegularExpression( '/WHERE Articles\.number != :c0$/', $filter->getQuery()->sql() ); diff --git a/tests/TestCase/Model/SearchTraitTest.php b/tests/TestCase/Model/SearchTraitTest.php index e6694702..3bb9ef94 100644 --- a/tests/TestCase/Model/SearchTraitTest.php +++ b/tests/TestCase/Model/SearchTraitTest.php @@ -24,12 +24,6 @@ class SearchTraitTest extends TestCase */ public function setUp(): void { - if (!class_exists(Webservice::class)) { - $this->markTestSkipped( - 'Muffin/Webservice plugin is not loaded.' - ); - } - parent::setUp(); $webserviceMock = $this->getMockBuilder(Webservice::class) diff --git a/tests/TestCase/View/Helper/SearchHelperTest.php b/tests/TestCase/View/Helper/SearchHelperTest.php index e08ef8d2..50a342e4 100644 --- a/tests/TestCase/View/Helper/SearchHelperTest.php +++ b/tests/TestCase/View/Helper/SearchHelperTest.php @@ -35,7 +35,7 @@ public function setUp(): void $config = []; $this->searchHelper = new SearchHelper($this->view, $config); - Router::scope('/', function (RouteBuilder $routes) { + Router::createRouteBuilder('/')->scope('/', function (RouteBuilder $routes) { $routes->connect( '/controller/action', ['controller' => 'Controller', 'action' => 'action'] diff --git a/tests/bootstrap.php b/tests/bootstrap.php index 944101f8..e40213d4 100644 --- a/tests/bootstrap.php +++ b/tests/bootstrap.php @@ -1,6 +1,8 @@