Skip to content

Commit

Permalink
Merge pull request #319 from FriendsOfCake/tests
Browse files Browse the repository at this point in the history
Fix deprecations in tests.
  • Loading branch information
dereuromark authored Mar 9, 2022
2 parents 760d996 + 15a8cfc commit 6dab51f
Show file tree
Hide file tree
Showing 12 changed files with 59 additions and 55 deletions.
5 changes: 5 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,5 +57,10 @@
"@psalm"
],
"test": "phpunit"
},
"config": {
"allow-plugins": {
"dealerdirect/phpcodesniffer-composer-installer": true
}
}
}
3 changes: 1 addition & 2 deletions tests/TestCase/Controller/Component/SearchComponentTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'],
Expand Down
26 changes: 13 additions & 13 deletions tests/TestCase/Model/Filter/BooleanTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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()
);
Expand All @@ -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()
);
Expand All @@ -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()
);
Expand All @@ -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()
);
Expand All @@ -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()
);
Expand All @@ -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()
);
Expand All @@ -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()
);
Expand All @@ -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()
);
Expand All @@ -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()
);
Expand All @@ -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()
);
Expand Down Expand Up @@ -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()
);
Expand All @@ -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()
);
Expand All @@ -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()
);
Expand Down
2 changes: 1 addition & 1 deletion tests/TestCase/Model/Filter/CallbackTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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()
);
Expand Down
8 changes: 4 additions & 4 deletions tests/TestCase/Model/Filter/CompareTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public function testProcess()
$filter->setQuery($articles->find());
$filter->process();

$this->assertRegExp(
$this->assertMatchesRegularExpression(
'/WHERE Articles\.created >= :c0$/',
$filter->getQuery()->sql()
);
Expand All @@ -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()
);
Expand All @@ -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()
);
Expand Down Expand Up @@ -114,7 +114,7 @@ public function testProcessDefaultFallbackForDisallowedMultiValue()
$filter->setQuery($articles->find());
$filter->process();

$this->assertRegExp(
$this->assertMatchesRegularExpression(
'/WHERE Articles\.created >= :c0$/',
$filter->getQuery()->sql()
);
Expand Down
10 changes: 5 additions & 5 deletions tests/TestCase/Model/Filter/ExistsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public function testProcessWithFlagOn()

$this->assertTrue($result);

$this->assertRegExp(
$this->assertMatchesRegularExpression(
'/WHERE \(Articles\.number\) IS NOT NULL$/',
$filter->getQuery()->sql()
);
Expand All @@ -53,7 +53,7 @@ public function testProcessWithFlagOff()

$this->assertTrue($result);

$this->assertRegExp(
$this->assertMatchesRegularExpression(
'/WHERE \(Articles\.number\) IS NULL$/',
$filter->getQuery()->sql()
);
Expand All @@ -75,7 +75,7 @@ public function testProcessWithFlagOnNotNullable()

$this->assertTrue($result);

$this->assertRegExp(
$this->assertMatchesRegularExpression(
'/WHERE Articles\.number != \:c0$/',
$filter->getQuery()->sql()
);
Expand All @@ -101,7 +101,7 @@ public function testProcessWithFlagOffNotNullable()

$this->assertTrue($result);

$this->assertRegExp(
$this->assertMatchesRegularExpression(
'/WHERE Articles\.number = \:c0$/',
$filter->getQuery()->sql()
);
Expand Down Expand Up @@ -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()
);
Expand Down
4 changes: 2 additions & 2 deletions tests/TestCase/Model/Filter/FinderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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()
);
Expand All @@ -60,7 +60,7 @@ public function testProcessMap()
$filter->setQuery($articles->find());
$filter->process();

$this->assertRegExp(
$this->assertMatchesRegularExpression(
'/WHERE title = :c0$/',
$filter->getQuery()->sql()
);
Expand Down
18 changes: 9 additions & 9 deletions tests/TestCase/Model/Filter/LikeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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()
);
Expand All @@ -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()
);
Expand All @@ -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()
);
Expand All @@ -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()
);
Expand All @@ -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()
);
Expand All @@ -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()
);
Expand All @@ -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()
Expand All @@ -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()
Expand Down Expand Up @@ -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()
);
Expand Down
Loading

0 comments on commit 6dab51f

Please sign in to comment.