Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ jobs:
if [[ ${{ matrix.db-type }} == 'pgsql' ]]; then export PGSQL_DSN='pgsql://postgres:[email protected]/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
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the biggest change would be no longer printing out the skipped tests, but I think that's actually preferable as they were essentially just noise for the most part and something to annoyingly scroll past to see actual test errors.

If we wanted to bring back the behavior, can use the new --display-skipped flag or displayDetailsOnSkippedTests XML option.

else
vendor/bin/phpunit
fi
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Renamed this as it wasn't a file that had tests, but rather something the concrete Config*Test files extended to make use of the same helper functions. phpunit 10 starting having a warning about this, so renaming to AbstractConfigTestCase seemed most in keeping with the naming scheme that phpunit uses, and avoids the warning.

{
/**
* @var string
Expand Down
2 changes: 1 addition & 1 deletion tests/Phinx/Config/ConfigDefaultEnvironmentTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
* @group config
* @covers \Phinx\Config\Config::getDefaultEnvironment
*/
class ConfigDefaultEnvironmentTest extends AbstractConfigTest
class ConfigDefaultEnvironmentTest extends AbstractConfigTestCase
{
public function testGetDefaultEnvironment()
{
Expand Down
2 changes: 1 addition & 1 deletion tests/Phinx/Config/ConfigDsnTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
* @group config
* @covers \Phinx\Config\Config::getEnvironment
*/
class ConfigDsnTest extends AbstractConfigTest
class ConfigDsnTest extends AbstractConfigTestCase
{
public function testConnectionOptionsCanBeSpecifiedWithDsn()
{
Expand Down
2 changes: 1 addition & 1 deletion tests/Phinx/Config/ConfigMigrationPathsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
* @group config
* @covers \Phinx\Config\Config::getMigrationPaths
*/
class ConfigMigrationPathsTest extends AbstractConfigTest
class ConfigMigrationPathsTest extends AbstractConfigTestCase
{
public function testGetMigrationPathsThrowsExceptionForNoPath()
{
Expand Down
2 changes: 1 addition & 1 deletion tests/Phinx/Config/ConfigReplaceTokensTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion tests/Phinx/Config/ConfigSeedPathsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
* @group config
* @covers \Phinx\Config\Config::getSeedPaths
*/
class ConfigSeedPathsTest extends AbstractConfigTest
class ConfigSeedPathsTest extends AbstractConfigTestCase
{
public function testGetSeedPathsThrowsExceptionForNoPath()
{
Expand Down
2 changes: 1 addition & 1 deletion tests/Phinx/Config/ConfigSeedTemplatePathsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
* @group config
* @covers \Phinx\Config\Config::getSeedTemplateFile
*/
class ConfigSeedTemplatePathsTest extends AbstractConfigTest
class ConfigSeedTemplatePathsTest extends AbstractConfigTestCase
{
public function testTemplateAndPathAreSet()
{
Expand Down
4 changes: 2 additions & 2 deletions tests/Phinx/Config/ConfigTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* @package Test\Phinx\Config
* @group config
*/
class ConfigTest extends AbstractConfigTest
class ConfigTest extends AbstractConfigTestCase
{
/**
* @covers \Phinx\Config\Config::getEnvironments
Expand Down Expand Up @@ -313,7 +313,7 @@ public function testIsVersionOrderCreationTime($versionOrder, $expected)
{
// get config stub
$configStub = $this->getMockBuilder('\Phinx\Config\Config')
->setMethods(['getVersionOrder'])
->onlyMethods(['getVersionOrder'])
->setConstructorArgs([[]])
->getMock();

Expand Down
2 changes: 1 addition & 1 deletion tests/Phinx/Console/Command/CreateTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

/**
Expand Down
2 changes: 1 addition & 1 deletion tests/Phinx/Console/Command/InitTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down
17 changes: 11 additions & 6 deletions tests/Phinx/Console/Command/SeedRunTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
13 changes: 9 additions & 4 deletions tests/Phinx/Db/Adapter/ProxyAdapterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down
2 changes: 1 addition & 1 deletion tests/Phinx/Db/Adapter/SQLiteAdapterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@
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;
use Symfony\Component\Console\Input\InputDefinition;
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
Expand Down
103 changes: 72 additions & 31 deletions tests/Phinx/Migration/Manager/EnvironmentTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');

Expand All @@ -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');

Expand All @@ -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');

Expand All @@ -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');

Expand All @@ -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');

Expand All @@ -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');

Expand Down Expand Up @@ -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())
Expand All @@ -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');
Expand Down
2 changes: 1 addition & 1 deletion tests/Phinx/Migration/ManagerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down
Loading