diff --git a/.gitignore b/.gitignore index 9a9b3fb..153aba6 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,4 @@ composer.lock tests/test_app/database/data tests/test_app/vendor .php_cs.cache +.phpunit.result.cache diff --git a/composer.json b/composer.json index b188d07..a2a9df6 100644 --- a/composer.json +++ b/composer.json @@ -9,7 +9,7 @@ "require-dev": { "phpunit/phpunit": "^8.5", "cakephp/cakephp": "^4.0", - "cakephp/cakephp-codesniffer": "~4.0.0" + "cakephp/cakephp-codesniffer": "^4.0" }, "license": "MIT", "authors": [ @@ -32,6 +32,6 @@ "test": "phpunit", "cs-check": "phpcs --colors -p ./src ./tests/TestCase", "stan": "phpstan.phar analyse src/ tests/TestCase", - "stan-setup": "cp composer.json composer.backup && composer require --dev phpstan/phpstan:^0.12 && mv composer.backup composer.json" + "stan-setup": "cp composer.json composer.backup && composer require --dev phpstan/phpstan:@stable && mv composer.backup composer.json" } } diff --git a/phpcs.xml.dist b/phpcs.xml.dist index 549f072..8a4f429 100644 --- a/phpcs.xml.dist +++ b/phpcs.xml.dist @@ -3,11 +3,4 @@ - - - - - - - /> diff --git a/phpstan.neon b/phpstan.neon index 9139975..eb7e589 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -1,4 +1,5 @@ parameters: - level: 5 + level: 6 + checkMissingIterableValueType: false autoload_files: - tests/bootstrap.php diff --git a/phpunit.xml.dist b/phpunit.xml.dist index cdefb23..e59982a 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -3,7 +3,6 @@ colors="true" processIsolation="false" stopOnFailure="false" - syntaxCheck="false" bootstrap="./tests/bootstrap.php" > diff --git a/src/Database/Connection/MasterReplicaConnection.php b/src/Database/Connection/MasterReplicaConnection.php index bd0a03a..dad580a 100644 --- a/src/Database/Connection/MasterReplicaConnection.php +++ b/src/Database/Connection/MasterReplicaConnection.php @@ -1,11 +1,9 @@ role = $role; $driver = $this->getDriver(); diff --git a/tests/TestCase/Database/Connection/MasterReplicaConnectionTest.php b/tests/TestCase/Database/Connection/MasterReplicaConnectionTest.php index 102a485..56e8d7b 100644 --- a/tests/TestCase/Database/Connection/MasterReplicaConnectionTest.php +++ b/tests/TestCase/Database/Connection/MasterReplicaConnectionTest.php @@ -1,5 +1,4 @@ subject, 'drivers'); $driversProperty->setAccessible(true); @@ -120,10 +115,8 @@ public function constructToSetDefaultRole() /** * @test - * - * @return void */ - public function switchRole() + public function switchRole(): void { $roleProperty = new ReflectionProperty($this->subject, 'role'); $roleProperty->setAccessible(true); @@ -159,9 +152,8 @@ public function switchRole() * @test * * @depends switchRole - * @return void */ - public function getDriver() + public function getDriver(): void { $driversProperty = new ReflectionProperty($this->subject, 'drivers'); $driversProperty->setAccessible(true); diff --git a/tests/TestCase/MasterReplicaConnectionIntegrationTest.php b/tests/TestCase/MasterReplicaConnectionIntegrationTest.php index 6fe7592..42cba03 100644 --- a/tests/TestCase/MasterReplicaConnectionIntegrationTest.php +++ b/tests/TestCase/MasterReplicaConnectionIntegrationTest.php @@ -1,5 +1,4 @@ getTableLocator()->get('Users'); $query = $table->query() @@ -72,7 +67,7 @@ public function switchToReadOnlyUserThenNotWritable() // Secondary user is not writable, so PDO throws the exception. $connection->switchRole('secondary'); $this->expectException(PDOException::class); - $this->expectExceptionMessageRegExp( + $this->expectExceptionMessageMatches( "/INSERT command denied to user '(.*?)'@'(.*?)' for table 'users'/" ); $query->cleanCopy()->execute(); diff --git a/tests/test_app/composer.json b/tests/test_app/composer.json index e520494..501dfbc 100644 --- a/tests/test_app/composer.json +++ b/tests/test_app/composer.json @@ -9,13 +9,13 @@ } ], "require": { - "cakephp/cakephp": "^3.5", + "cakephp/cakephp": "^4.0", "connehito/cakephp-master-replica": "@dev" }, "require-dev": { - "phpunit/phpunit": "^6.0", - "phpstan/phpstan": "^0.11.9", - "squizlabs/php_codesniffer": "^3.4" + "phpunit/phpunit": "^8.5", + "phpstan/phpstan": "@stable", + "squizlabs/php_codesniffer": "@stable" }, "license": "MIT", "authors": [