From a64239e78b639c87a18f6eb65883db73497ca3b3 Mon Sep 17 00:00:00 2001 From: Nathaniel McHugh Date: Mon, 4 Jan 2021 13:48:08 +0000 Subject: [PATCH 1/6] Drop support of PHP 7.1 add up to 8.0 --- .travis.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 478f3b6..5304159 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,8 +2,9 @@ sudo: false language: php php: - - 7.1 - 7.2 + - 7.3 + - 7.4 cache: directories: From 0c4c5c592f78cab48f5cc3c0fe39f6ee881cba8b Mon Sep 17 00:00:00 2001 From: Nathaniel McHugh Date: Mon, 4 Jan 2021 14:55:54 +0000 Subject: [PATCH 2/6] Add php verions 8 to the CI config --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index 5304159..28e21a3 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,6 +5,7 @@ php: - 7.2 - 7.3 - 7.4 + - 8.0 cache: directories: From 903d04d82704dfffaf076f248abc8129435d3db9 Mon Sep 17 00:00:00 2001 From: Nathaniel McHugh Date: Mon, 4 Jan 2021 14:56:26 +0000 Subject: [PATCH 3/6] Allow php-cs-fixer minor version updates --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 779f820..d086ca9 100644 --- a/composer.json +++ b/composer.json @@ -11,7 +11,7 @@ "pimple/pimple": "^3.0" }, "require-dev": { - "friendsofphp/php-cs-fixer": "2.16.0", + "friendsofphp/php-cs-fixer": "^2.16", "phpunit/phpunit": "^5.7", "roave/security-advisories": "dev-master", "squizlabs/php_codesniffer": "^2.7" From f5d6aeccd13b1a8fb8bed1bedf822e1eafeb4512 Mon Sep 17 00:00:00 2001 From: Nathaniel McHugh Date: Mon, 4 Jan 2021 15:48:54 +0000 Subject: [PATCH 4/6] Update PHPUnit and fix tests --- composer.json | 6 +++--- phpunit.xml | 1 - tests/AppSetupTest.php | 2 +- tests/FieldCleanerProviderTest.php | 5 +++-- tests/ReferenceStoreTest.php | 3 ++- tests/SamplerTest.php | 3 ++- tests/SqliteBasedTestCase.php | 7 ++++--- 7 files changed, 15 insertions(+), 12 deletions(-) diff --git a/composer.json b/composer.json index d086ca9..c7c0b42 100644 --- a/composer.json +++ b/composer.json @@ -12,9 +12,9 @@ }, "require-dev": { "friendsofphp/php-cs-fixer": "^2.16", - "phpunit/phpunit": "^5.7", + "phpunit/phpunit": "^8.5", "roave/security-advisories": "dev-master", - "squizlabs/php_codesniffer": "^2.7" + "squizlabs/php_codesniffer": "^3.5" }, "authors": [ { @@ -40,7 +40,7 @@ "phpcbf": "./vendor/bin/phpcbf src/ --standard=PSR2 --warning-severity=8", "php-cs-fixer-lint": "./vendor/bin/php-cs-fixer --verbose --dry-run fix --rules=@PSR2,no_unused_imports src/", "php-cs-fixer-fix": "./vendor/bin/php-cs-fixer --verbose fix --rules=@PSR2,no_unused_imports src/", - "phpunit": "./vendor/bin/phpunit --coverage-clover=phpcov.xml --coverage-text", + "phpunit": "XDEBUG_MODE=coverage ./vendor/bin/phpunit --coverage-clover=phpcov.xml --coverage-text", "lint": [ "@phpcs", "@php-cs-fixer-lint" diff --git a/phpunit.xml b/phpunit.xml index ec92eda..a940c08 100644 --- a/phpunit.xml +++ b/phpunit.xml @@ -3,7 +3,6 @@ convertErrorsToExceptions="true" convertNoticesToExceptions="true" convertWarningsToExceptions="true" - strict="true" verbose="false"> diff --git a/tests/AppSetupTest.php b/tests/AppSetupTest.php index e5728f7..0de13f0 100644 --- a/tests/AppSetupTest.php +++ b/tests/AppSetupTest.php @@ -46,13 +46,13 @@ public function testSampleMigration() * Check that sqlite credential files handle missing directory field correctly * * @return void - * @expectedException \RuntimeException */ public function testSqliteCredentialMissingDirectoryHandling() { $app = new App(); $app->loadCredentialsFile($this->fixturesDir . '/sqlite-credentials-no-dir.json'); $app->loadDatabaseConfigFile($this->fixturesDir . '/small_sqlite_migration.json'); + $this->expectException(\RuntimeException::class); $app->createDestConnectionByDbName('small-sqlite-source'); // directory tested at connection time now } diff --git a/tests/FieldCleanerProviderTest.php b/tests/FieldCleanerProviderTest.php index 35f10c2..29f5b9e 100644 --- a/tests/FieldCleanerProviderTest.php +++ b/tests/FieldCleanerProviderTest.php @@ -3,15 +3,16 @@ namespace Quidco\DbSampler\Tests; use Quidco\DbSampler\FieldCleanerProvider; +use PHPUnit\Framework\TestCase; -class FieldCleanerProviderTest extends \PHPUnit_Framework_TestCase +class FieldCleanerProviderTest extends TestCase { /** * @var FieldCleanerProvider */ private $fieldCleaner; - public function setUp() + public function setUp(): void { $this->fieldCleaner = new FieldCleanerProvider(); } diff --git a/tests/ReferenceStoreTest.php b/tests/ReferenceStoreTest.php index b9d063e..88d2d85 100644 --- a/tests/ReferenceStoreTest.php +++ b/tests/ReferenceStoreTest.php @@ -3,8 +3,9 @@ namespace Quidco\DbSampler\Tests; use Quidco\DbSampler\ReferenceStore; +use PHPUnit\Framework\TestCase; -class ReferenceStoreTest extends \PHPUnit_Framework_TestCase +class ReferenceStoreTest extends TestCase { public function testBasicFunctions() { diff --git a/tests/SamplerTest.php b/tests/SamplerTest.php index 212273f..e7a5a23 100644 --- a/tests/SamplerTest.php +++ b/tests/SamplerTest.php @@ -67,14 +67,15 @@ public function testMatchedWhereNoConstraints() ]; $sampler->loadConfig((object)$config); $sampler->execute(); + $this->assertInstanceOf(Matched::class, $sampler); } /** - * @expectedException \RuntimeException */ public function testMatchedNoConfigThrows() { $sampler = $this->generateMatched(); + $this->expectException(\RuntimeException::class); $sampler->loadConfig((object)[]); $sampler->execute(); } diff --git a/tests/SqliteBasedTestCase.php b/tests/SqliteBasedTestCase.php index a118a63..ce5c3ec 100644 --- a/tests/SqliteBasedTestCase.php +++ b/tests/SqliteBasedTestCase.php @@ -4,8 +4,9 @@ use Doctrine\DBAL\Connection; use Doctrine\DBAL\DriverManager; +use PHPUnit\Framework\TestCase; -abstract class SqliteBasedTestCase extends \PHPUnit_Framework_TestCase +abstract class SqliteBasedTestCase extends TestCase { /** * @var string @@ -25,7 +26,7 @@ abstract class SqliteBasedTestCase extends \PHPUnit_Framework_TestCase * * @return void */ - protected function setUp() + protected function setUp(): void { $this->fixturesDir = __DIR__ . '/fixtures'; $sqliteConfig = ['driver' => 'pdo_sqlite', 'directory' => $this->fixturesDir . '/sqlite-dbs']; @@ -44,7 +45,7 @@ protected function setUp() * * @return void */ - protected function tearDown() + protected function tearDown(): void { parent::tearDown(); unlink($this->fixturesDir . '/sqlite-credentials.json'); From 7ba51d9d5342753e0343f602620dd2ce61656f23 Mon Sep 17 00:00:00 2001 From: Nathaniel McHugh Date: Tue, 5 Jan 2021 10:09:08 +0000 Subject: [PATCH 5/6] Replace faker too --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index c7c0b42..3ca323c 100644 --- a/composer.json +++ b/composer.json @@ -6,7 +6,7 @@ "bin": ["bin/dbsampler"], "require": { "doctrine/dbal": "^2.5", - "fzaninotto/faker": "^1.6", + "fakerphp/faker": "^1.13", "monolog/monolog": "^1.22", "pimple/pimple": "^3.0" }, From db6b451f5c8484c18525109c11e735d8a8f71bd0 Mon Sep 17 00:00:00 2001 From: Nathaniel McHugh Date: Tue, 5 Jan 2021 13:58:38 +0000 Subject: [PATCH 6/6] Set code sniffer fixer to ignore PHP version as it seems to work ok with PHP8 but this check complains --- composer.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/composer.json b/composer.json index 3ca323c..a300cae 100644 --- a/composer.json +++ b/composer.json @@ -38,8 +38,8 @@ "scripts": { "phpcs": "./vendor/bin/phpcs src/ --standard=PSR2 --warning-severity=8", "phpcbf": "./vendor/bin/phpcbf src/ --standard=PSR2 --warning-severity=8", - "php-cs-fixer-lint": "./vendor/bin/php-cs-fixer --verbose --dry-run fix --rules=@PSR2,no_unused_imports src/", - "php-cs-fixer-fix": "./vendor/bin/php-cs-fixer --verbose fix --rules=@PSR2,no_unused_imports src/", + "php-cs-fixer-lint": "PHP_CS_FIXER_IGNORE_ENV=1 ./vendor/bin/php-cs-fixer --verbose --dry-run fix --rules=@PSR2,no_unused_imports src/", + "php-cs-fixer-fix": "PHP_CS_FIXER_IGNORE_ENV=1 ./vendor/bin/php-cs-fixer --verbose fix --rules=@PSR2,no_unused_imports src/", "phpunit": "XDEBUG_MODE=coverage ./vendor/bin/phpunit --coverage-clover=phpcov.xml --coverage-text", "lint": [ "@phpcs",