diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4164901c9..4b5ea4c91 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -102,7 +102,7 @@ jobs: if [[ ${{ matrix.db-type }} == 'pgsql' ]]; then export PGSQL_DSN='pgsql://postgres:postgres@127.0.0.1/phinx'; fi if [[ ${{ matrix.prefer-lowest != 'prefer-lowest' }} ]]; then - export CODECOVERAGE=1 && vendor/bin/phpunit --verbose --coverage-clover=coverage.xml + export CODECOVERAGE=1 && vendor/bin/phpunit --coverage-clover=coverage.xml else vendor/bin/phpunit fi @@ -180,7 +180,7 @@ jobs: SQLSRV_DSN: 'sqlsrv://(localdb)\MSSQLLocalDB/phinx' CODECOVERAGE: 1 run: | - vendor/bin/phpunit --verbose --coverage-clover=coverage.xml + vendor/bin/phpunit --coverage-clover=coverage.xml - name: Submit code coverage uses: codecov/codecov-action@v5 diff --git a/composer.json b/composer.json index 4fa95419e..857ebf815 100644 --- a/composer.json +++ b/composer.json @@ -48,7 +48,7 @@ "ext-pdo": "*", "cakephp/cakephp-codesniffer": "^5.0", "cakephp/i18n": "^5.0", - "phpunit/phpunit": "^9.5.19", + "phpunit/phpunit": "^10.5", "symfony/yaml": "^4.0|^5.0|^6.0|^7.0" }, "autoload": { diff --git a/tests/Phinx/Config/AbstractConfigTest.php b/tests/Phinx/Config/AbstractConfigTestCase.php similarity index 96% rename from tests/Phinx/Config/AbstractConfigTest.php rename to tests/Phinx/Config/AbstractConfigTestCase.php index af178b564..8ff0259cf 100644 --- a/tests/Phinx/Config/AbstractConfigTest.php +++ b/tests/Phinx/Config/AbstractConfigTestCase.php @@ -5,13 +5,13 @@ use PHPUnit\Framework\TestCase; /** - * Class AbstractConfigTest + * Class AbstractConfigTestCase * * @package Test\Phinx\Config * @group config * @coversNothing */ -abstract class AbstractConfigTest extends TestCase +abstract class AbstractConfigTestCase extends TestCase { /** * @var string diff --git a/tests/Phinx/Config/ConfigDefaultEnvironmentTest.php b/tests/Phinx/Config/ConfigDefaultEnvironmentTest.php index 0f6273fab..7320d284c 100644 --- a/tests/Phinx/Config/ConfigDefaultEnvironmentTest.php +++ b/tests/Phinx/Config/ConfigDefaultEnvironmentTest.php @@ -12,7 +12,7 @@ * @group config * @covers \Phinx\Config\Config::getDefaultEnvironment */ -class ConfigDefaultEnvironmentTest extends AbstractConfigTest +class ConfigDefaultEnvironmentTest extends AbstractConfigTestCase { public function testGetDefaultEnvironment() { diff --git a/tests/Phinx/Config/ConfigDsnTest.php b/tests/Phinx/Config/ConfigDsnTest.php index 553c1ea71..859134eb3 100644 --- a/tests/Phinx/Config/ConfigDsnTest.php +++ b/tests/Phinx/Config/ConfigDsnTest.php @@ -11,7 +11,7 @@ * @group config * @covers \Phinx\Config\Config::getEnvironment */ -class ConfigDsnTest extends AbstractConfigTest +class ConfigDsnTest extends AbstractConfigTestCase { public function testConnectionOptionsCanBeSpecifiedWithDsn() { diff --git a/tests/Phinx/Config/ConfigMigrationPathsTest.php b/tests/Phinx/Config/ConfigMigrationPathsTest.php index 9cabcbe8a..41edee53a 100644 --- a/tests/Phinx/Config/ConfigMigrationPathsTest.php +++ b/tests/Phinx/Config/ConfigMigrationPathsTest.php @@ -12,7 +12,7 @@ * @group config * @covers \Phinx\Config\Config::getMigrationPaths */ -class ConfigMigrationPathsTest extends AbstractConfigTest +class ConfigMigrationPathsTest extends AbstractConfigTestCase { public function testGetMigrationPathsThrowsExceptionForNoPath() { diff --git a/tests/Phinx/Config/ConfigReplaceTokensTest.php b/tests/Phinx/Config/ConfigReplaceTokensTest.php index f606ca84f..672c442d7 100644 --- a/tests/Phinx/Config/ConfigReplaceTokensTest.php +++ b/tests/Phinx/Config/ConfigReplaceTokensTest.php @@ -10,7 +10,7 @@ * @package Test\Phinx\Config * @group config */ -class ConfigReplaceTokensTest extends AbstractConfigTest +class ConfigReplaceTokensTest extends AbstractConfigTestCase { /** * Data to be saved to $_SERVER and checked later diff --git a/tests/Phinx/Config/ConfigSeedPathsTest.php b/tests/Phinx/Config/ConfigSeedPathsTest.php index 69571f74e..14175e13c 100644 --- a/tests/Phinx/Config/ConfigSeedPathsTest.php +++ b/tests/Phinx/Config/ConfigSeedPathsTest.php @@ -12,7 +12,7 @@ * @group config * @covers \Phinx\Config\Config::getSeedPaths */ -class ConfigSeedPathsTest extends AbstractConfigTest +class ConfigSeedPathsTest extends AbstractConfigTestCase { public function testGetSeedPathsThrowsExceptionForNoPath() { diff --git a/tests/Phinx/Config/ConfigSeedTemplatePathsTest.php b/tests/Phinx/Config/ConfigSeedTemplatePathsTest.php index d2e294fdd..517126c39 100644 --- a/tests/Phinx/Config/ConfigSeedTemplatePathsTest.php +++ b/tests/Phinx/Config/ConfigSeedTemplatePathsTest.php @@ -11,7 +11,7 @@ * @group config * @covers \Phinx\Config\Config::getSeedTemplateFile */ -class ConfigSeedTemplatePathsTest extends AbstractConfigTest +class ConfigSeedTemplatePathsTest extends AbstractConfigTestCase { public function testTemplateAndPathAreSet() { diff --git a/tests/Phinx/Config/ConfigTest.php b/tests/Phinx/Config/ConfigTest.php index a189d74f3..105835042 100644 --- a/tests/Phinx/Config/ConfigTest.php +++ b/tests/Phinx/Config/ConfigTest.php @@ -14,7 +14,7 @@ * @package Test\Phinx\Config * @group config */ -class ConfigTest extends AbstractConfigTest +class ConfigTest extends AbstractConfigTestCase { /** * @covers \Phinx\Config\Config::getEnvironments @@ -313,7 +313,7 @@ public function testIsVersionOrderCreationTime($versionOrder, $expected) { // get config stub $configStub = $this->getMockBuilder('\Phinx\Config\Config') - ->setMethods(['getVersionOrder']) + ->onlyMethods(['getVersionOrder']) ->setConstructorArgs([[]]) ->getMock(); diff --git a/tests/Phinx/Console/Command/CreateTest.php b/tests/Phinx/Console/Command/CreateTest.php index f654d2b33..5c9f5f7cd 100644 --- a/tests/Phinx/Console/Command/CreateTest.php +++ b/tests/Phinx/Console/Command/CreateTest.php @@ -10,10 +10,10 @@ use Phinx\Console\Command\Create; use Phinx\Console\PhinxApplication; use Phinx\Util\Util; +use PHPUnit\Framework\TestCase; use Symfony\Component\Console\Input\ArrayInput; use Symfony\Component\Console\Output\StreamOutput; use Symfony\Component\Console\Tester\CommandTester; -use Test\Phinx\TestCase; use Test\Phinx\TestUtils; /** diff --git a/tests/Phinx/Console/Command/InitTest.php b/tests/Phinx/Console/Command/InitTest.php index f7ea49f65..4bfb9bfad 100644 --- a/tests/Phinx/Console/Command/InitTest.php +++ b/tests/Phinx/Console/Command/InitTest.php @@ -7,8 +7,8 @@ use Phinx\Console\Command\AbstractCommand; use Phinx\Console\Command\Init; use Phinx\Console\PhinxApplication; +use PHPUnit\Framework\TestCase; use Symfony\Component\Console\Tester\CommandTester; -use Test\Phinx\TestCase; class InitTest extends TestCase { diff --git a/tests/Phinx/Console/Command/SeedRunTest.php b/tests/Phinx/Console/Command/SeedRunTest.php index 0c6f7be5a..355e8c192 100644 --- a/tests/Phinx/Console/Command/SeedRunTest.php +++ b/tests/Phinx/Console/Command/SeedRunTest.php @@ -209,12 +209,17 @@ public function testExecuteMultipleSeeders() $managerStub = $this->getMockBuilder('\Phinx\Migration\Manager') ->setConstructorArgs([$this->config, $this->input, $this->output]) ->getMock(); - $managerStub->expects($this->exactly(3)) - ->method('seed')->withConsecutive( - [$this->identicalTo('development'), $this->identicalTo('One')], - [$this->identicalTo('development'), $this->identicalTo('Two')], - [$this->identicalTo('development'), $this->identicalTo('Three')], - ); + $matcher = $this->exactly(3); + $managerStub + ->expects($matcher) + ->method('seed') + ->willReturnCallback(function () use ($matcher) { + match ($matcher->numberOfInvocations()) { + 1 => [$this->identicalTo('development'), $this->identicalTo('One')], + 2 => [$this->identicalTo('development'), $this->identicalTo('Two')], + 3 => [$this->identicalTo('development'), $this->identicalTo('Three')], + }; + }); $command->setConfig($this->config); $command->setManager($managerStub); diff --git a/tests/Phinx/Db/Adapter/ProxyAdapterTest.php b/tests/Phinx/Db/Adapter/ProxyAdapterTest.php index 78a662903..d6493a020 100644 --- a/tests/Phinx/Db/Adapter/ProxyAdapterTest.php +++ b/tests/Phinx/Db/Adapter/ProxyAdapterTest.php @@ -18,10 +18,15 @@ class ProxyAdapterTest extends TestCase protected function setUp(): void { - $stub = $this->getMockBuilder('\Phinx\Db\Adapter\PdoAdapter') - ->setConstructorArgs([[]]) - ->setMethods([]) - ->getMock(); + $stub = $this->getMockForAbstractClass( + '\Phinx\Db\Adapter\PdoAdapter', + [[]], + '', + true, + true, + true, + ['getColumnForType', 'isValidColumnType'], + ); $stub->expects($this->any()) ->method('isValidColumnType') diff --git a/tests/Phinx/Db/Adapter/SQLiteAdapterTest.php b/tests/Phinx/Db/Adapter/SQLiteAdapterTest.php index 1c2bd74f3..433e618c5 100644 --- a/tests/Phinx/Db/Adapter/SQLiteAdapterTest.php +++ b/tests/Phinx/Db/Adapter/SQLiteAdapterTest.php @@ -18,6 +18,7 @@ use Phinx\Db\Table\ForeignKey; use Phinx\Util\Expression; use Phinx\Util\Literal; +use PHPUnit\Framework\TestCase; use ReflectionObject; use RuntimeException; use Symfony\Component\Console\Input\ArrayInput; @@ -25,7 +26,6 @@ use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\BufferedOutput; use Symfony\Component\Console\Output\NullOutput; -use Test\Phinx\TestCase; use UnexpectedValueException; class SQLiteAdapterTest extends TestCase diff --git a/tests/Phinx/Migration/Manager/EnvironmentTest.php b/tests/Phinx/Migration/Manager/EnvironmentTest.php index 9432a127b..458f8bcae 100644 --- a/tests/Phinx/Migration/Manager/EnvironmentTest.php +++ b/tests/Phinx/Migration/Manager/EnvironmentTest.php @@ -148,10 +148,15 @@ public function testExecutingAMigrationUp() $this->environment->setAdapter($adapterStub); // up - $upMigration = $this->getMockBuilder('\Phinx\Migration\AbstractMigration') - ->setConstructorArgs(['mockenv', '20110301080000']) - ->setMethods(['up']) - ->getMock(); + $upMigration = $this->getMockForAbstractClass( + '\Phinx\Migration\AbstractMigration', + ['mockenv', '20110301080000'], + '', + true, + true, + true, + ['up'], + ); $upMigration->expects($this->once()) ->method('up'); @@ -171,10 +176,15 @@ public function testExecutingAMigrationDown() $this->environment->setAdapter($adapterStub); // down - $downMigration = $this->getMockBuilder('\Phinx\Migration\AbstractMigration') - ->setConstructorArgs(['mockenv', '20110301080000']) - ->setMethods(['down']) - ->getMock(); + $downMigration = $this->getMockForAbstractClass( + '\Phinx\Migration\AbstractMigration', + ['mockenv', '20110301080000'], + '', + true, + true, + true, + ['down'], + ); $downMigration->expects($this->once()) ->method('down'); @@ -200,10 +210,15 @@ public function testExecutingAMigrationWithTransactions() $this->environment->setAdapter($adapterStub); // migrate - $migration = $this->getMockBuilder('\Phinx\Migration\AbstractMigration') - ->setConstructorArgs(['mockenv', '20110301080000']) - ->setMethods(['up']) - ->getMock(); + $migration = $this->getMockForAbstractClass( + '\Phinx\Migration\AbstractMigration', + ['mockenv', '20110301080000'], + '', + true, + true, + true, + ['up'], + ); $migration->expects($this->once()) ->method('up'); @@ -223,10 +238,15 @@ public function testExecutingAChangeMigrationUp() $this->environment->setAdapter($adapterStub); // migration - $migration = $this->getMockBuilder('\Phinx\Migration\AbstractMigration') - ->setConstructorArgs(['mockenv', '20130301080000']) - ->setMethods(['change']) - ->getMock(); + $migration = $this->getMockForAbstractClass( + '\Phinx\Migration\AbstractMigration', + ['mockenv', '20130301080000'], + '', + true, + true, + true, + ['change'], + ); $migration->expects($this->once()) ->method('change'); @@ -246,10 +266,15 @@ public function testExecutingAChangeMigrationDown() $this->environment->setAdapter($adapterStub); // migration - $migration = $this->getMockBuilder('\Phinx\Migration\AbstractMigration') - ->setConstructorArgs(['mockenv', '20130301080000']) - ->setMethods(['change']) - ->getMock(); + $migration = $this->getMockForAbstractClass( + '\Phinx\Migration\AbstractMigration', + ['mockenv', '20130301080000'], + '', + true, + true, + true, + ['change'], + ); $migration->expects($this->once()) ->method('change'); @@ -269,10 +294,15 @@ public function testExecutingAFakeMigration() $this->environment->setAdapter($adapterStub); // migration - $migration = $this->getMockBuilder('\Phinx\Migration\AbstractMigration') - ->setConstructorArgs(['mockenv', '20130301080000']) - ->setMethods(['change']) - ->getMock(); + $migration = $this->getMockForAbstractClass( + '\Phinx\Migration\AbstractMigration', + ['mockenv', '20130301080000'], + '', + true, + true, + true, + ['change'], + ); $migration->expects($this->never()) ->method('change'); @@ -301,10 +331,15 @@ public function testExecuteMigrationCallsInit() $this->environment->setAdapter($adapterStub); // up - $upMigration = $this->getMockBuilder('\Phinx\Migration\AbstractMigration') - ->setConstructorArgs(['mockenv', '20110301080000']) - ->setMethods(['up', 'init']) - ->getMock(); + $upMigration = $this->getMockForAbstractClass( + '\Phinx\Migration\AbstractMigration', + ['mockenv', '20130301080000'], + '', + true, + true, + true, + ['up', 'init'], + ); $upMigration->expects($this->once()) ->method('up'); $upMigration->expects($this->once()) @@ -323,9 +358,15 @@ public function testExecuteSeedInit() $this->environment->setAdapter($adapterStub); // up - $seed = $this->getMockBuilder('\Phinx\Seed\AbstractSeed') - ->setMethods(['run', 'init']) - ->getMock(); + $seed = $this->getMockForAbstractClass( + '\Phinx\Seed\AbstractSeed', + [], + '', + true, + true, + true, + ['run', 'init'], + ); $seed->expects($this->once()) ->method('run'); diff --git a/tests/Phinx/Migration/ManagerTest.php b/tests/Phinx/Migration/ManagerTest.php index d790d21e3..2d484b38c 100644 --- a/tests/Phinx/Migration/ManagerTest.php +++ b/tests/Phinx/Migration/ManagerTest.php @@ -9,11 +9,11 @@ use Phinx\Console\Command\AbstractCommand; use Phinx\Db\Adapter\AdapterInterface; use Phinx\Migration\Manager; +use PHPUnit\Framework\TestCase; use RuntimeException; use Symfony\Component\Console\Input\ArrayInput; use Symfony\Component\Console\Output\StreamOutput; use Test\Phinx\Console\Output\RawBufferedOutput; -use Test\Phinx\TestCase; class ManagerTest extends TestCase { diff --git a/tests/Phinx/TestCase.php b/tests/Phinx/TestCase.php deleted file mode 100644 index cd9473ede..000000000 --- a/tests/Phinx/TestCase.php +++ /dev/null @@ -1,48 +0,0 @@ -