Skip to content

Commit

Permalink
Merge pull request #1072 from greg0ire/upgrade-phpunit
Browse files Browse the repository at this point in the history
Upgrade phpunit
  • Loading branch information
greg0ire authored Nov 8, 2020
2 parents f918b95 + b6b3961 commit 9b69ae5
Show file tree
Hide file tree
Showing 16 changed files with 85 additions and 81 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ reports/
dist/
tests/phpunit.xml
phpunit.xml
/.phpunit.result.cache
/composer.lock
vendor/
/phpcs.xml
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"phpstan/phpstan-deprecation-rules": "^0.10",
"phpstan/phpstan-phpunit": "^0.10",
"phpstan/phpstan-strict-rules": "^0.10",
"phpunit/phpunit": "^7.0",
"phpunit/phpunit": "^7.5 || ^8.5 || ^9.4",
"symfony/process": "^3.4||^4.0||^5.0",
"symfony/yaml": "^3.4||^4.0||^5.0"
},
Expand Down
6 changes: 3 additions & 3 deletions tests/Doctrine/Migrations/Tests/AbstractMigrationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,13 @@ public function testGetDescriptionReturnsEmptyString() : void
public function testWarnIfOutputMessage() : void
{
$this->migration->warnIf(true, 'Warning was thrown');
self::assertContains('Warning during No State: Warning was thrown', $this->getOutputStreamContent($this->output));
self::assertStringContainsString('Warning during No State: Warning was thrown', $this->getOutputStreamContent($this->output));
}

public function testWarnIfAddDefaultMessage() : void
{
$this->migration->warnIf(true);
self::assertContains('Warning during No State: Unknown Reason', $this->getOutputStreamContent($this->output));
self::assertStringContainsString('Warning during No State: Unknown Reason', $this->getOutputStreamContent($this->output));
}

public function testWarnIfDontOutputMessageIfFalse() : void
Expand All @@ -75,7 +75,7 @@ public function testWarnIfDontOutputMessageIfFalse() : void
public function testWriteInvokesOutputWriter() : void
{
$this->migration->exposedWrite('Message');
self::assertContains('Message', $this->getOutputStreamContent($this->output));
self::assertStringContainsString('Message', $this->getOutputStreamContent($this->output));
}

public function testAbortIfThrowsException() : void
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,11 +165,11 @@ public function testLoadMigrationsList() : void
{
$configuration1 = $this->loadConfiguration('migrations_list');

self::assertContains('migrations_list', $configuration1->getFile());
self::assertStringContainsString('migrations_list', $configuration1->getFile());

$configuration2 = $this->loadConfiguration('migrations_list2');

self::assertContains('migrations_list2', $configuration2->getFile());
self::assertStringContainsString('migrations_list2', $configuration2->getFile());
}

/**
Expand All @@ -179,7 +179,7 @@ public function testThatTheOrderOfConfigKeysDoesNotMatter(string $file) : void
{
$configuration = $this->loadConfiguration($file);

self::assertContains($file, $configuration->getFile());
self::assertStringContainsString($file, $configuration->getFile());
}

/** @return string[][] */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
use Doctrine\Migrations\Tests\MigrationTestCase;
use Doctrine\Migrations\Tests\Stub\Configuration\AutoloadVersions\Version1Test;
use Doctrine\Migrations\Version\Version;
use PHPUnit_Framework_MockObject_MockObject;
use PHPUnit\Framework\MockObject\MockObject;
use Symfony\Component\Stopwatch\Stopwatch as SymfonyStopwatch;
use function array_keys;
use function call_user_func_array;
Expand Down Expand Up @@ -317,15 +317,15 @@ public function testGetSetCheckDatabasePlatform() : void
}

/**
* @return PHPUnit_Framework_MockObject_MockObject|Connection
* @return MockObject|Connection
*/
private function getConnectionMock()
{
return $this->createMock(Connection::class);
}

/**
* @return PHPUnit_Framework_MockObject_MockObject|OutputWriter
* @return MockObject|OutputWriter
*/
private function getOutputWriterMock()
{
Expand Down
3 changes: 2 additions & 1 deletion tests/Doctrine/Migrations/Tests/FileQueryWriterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ public function testWrite(

foreach ($files as $file) {
$contents = file_get_contents($file);
self::assertNotFalse($contents);

unlink($file);

Expand All @@ -81,7 +82,7 @@ public function testWrite(
}

self::assertNotEmpty($contents);
self::assertContains($expectedSql, $contents);
self::assertStringContainsString($expectedSql, $contents);
}
}

Expand Down
48 changes: 24 additions & 24 deletions tests/Doctrine/Migrations/Tests/Functional/CliTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public function testMigrationLifecycleFromCommandLine() : void
self::assertRegExp('/new migrations:\s+1/im', $output);

$output = $this->executeCommand('migrations:latest');
self::assertContains('20150426000000', $output);
self::assertStringContainsString('20150426000000', $output);

$this->executeCommand('migrations:migrate', 'config.yml', ['--no-interaction']);
self::assertSuccessfulExit();
Expand Down Expand Up @@ -119,10 +119,10 @@ public function testMigrationDiffWritesNewMigrationWithExpectedSql() : void

$versionClassContents = $this->getFileContentsForLatestVersion();

self::assertContains('CREATE TABLE foo', $versionClassContents);
self::assertContains('CREATE TABLE bar', $versionClassContents);
self::assertContains('DROP TABLE foo', $versionClassContents);
self::assertContains('DROP TABLE bar', $versionClassContents);
self::assertStringContainsString('CREATE TABLE foo', $versionClassContents);
self::assertStringContainsString('CREATE TABLE bar', $versionClassContents);
self::assertStringContainsString('DROP TABLE foo', $versionClassContents);
self::assertStringContainsString('DROP TABLE bar', $versionClassContents);
}

public function testMigrationDiffWritesNewMigrationWithFormattedSql() : void
Expand All @@ -146,10 +146,10 @@ public function testMigrationDiffWritesNewMigrationWithFormattedSql() : void

$versionClassContents = $this->getFileContentsForLatestVersion();

self::assertContains("CREATE TABLE foo (\n", $versionClassContents);
self::assertContains("CREATE TABLE bar (\n", $versionClassContents);
self::assertContains('DROP TABLE foo', $versionClassContents);
self::assertContains('DROP TABLE bar', $versionClassContents);
self::assertStringContainsString("CREATE TABLE foo (\n", $versionClassContents);
self::assertStringContainsString("CREATE TABLE bar (\n", $versionClassContents);
self::assertStringContainsString('DROP TABLE foo', $versionClassContents);
self::assertStringContainsString('DROP TABLE bar', $versionClassContents);
}

public function testMigrationDiffFromEmptySchemaGeneratesFullMigration() : void
Expand All @@ -166,10 +166,10 @@ public function testMigrationDiffFromEmptySchemaGeneratesFullMigration() : void

$versionClassContents = $this->getFileContentsForLatestVersion();

self::assertNotContains('CREATE TABLE foo', $versionClassContents);
self::assertContains('CREATE TABLE bar', $versionClassContents);
self::assertNotContains('DROP TABLE foo', $versionClassContents);
self::assertContains('DROP TABLE bar', $versionClassContents);
self::assertStringNotContainsString('CREATE TABLE foo', $versionClassContents);
self::assertStringContainsString('CREATE TABLE bar', $versionClassContents);
self::assertStringNotContainsString('DROP TABLE foo', $versionClassContents);
self::assertStringContainsString('DROP TABLE bar', $versionClassContents);

$this->deleteMigrationFiles();

Expand All @@ -180,10 +180,10 @@ public function testMigrationDiffFromEmptySchemaGeneratesFullMigration() : void

$versionClassContents = $this->getFileContentsForLatestVersion();

self::assertContains('CREATE TABLE foo', $versionClassContents);
self::assertContains('CREATE TABLE bar', $versionClassContents);
self::assertContains('DROP TABLE foo', $versionClassContents);
self::assertContains('DROP TABLE bar', $versionClassContents);
self::assertStringContainsString('CREATE TABLE foo', $versionClassContents);
self::assertStringContainsString('CREATE TABLE bar', $versionClassContents);
self::assertStringContainsString('DROP TABLE foo', $versionClassContents);
self::assertStringContainsString('DROP TABLE bar', $versionClassContents);
}

public function testMigrationDiffWithEntityManagerGeneratesMigrationFromEntities() : void
Expand All @@ -206,8 +206,8 @@ public function testMigrationDiffWithEntityManagerGeneratesMigrationFromEntities
self::assertRegExp('/available migrations:\s+2/im', $output);

$versionClassContents = $this->getFileContentsForLatestVersion();
self::assertContains('CREATE TABLE sample_entity', $versionClassContents);
self::assertContains('DROP TABLE sample_entity', $versionClassContents);
self::assertStringContainsString('CREATE TABLE sample_entity', $versionClassContents);
self::assertStringContainsString('DROP TABLE sample_entity', $versionClassContents);
}

public function testDiffCommandWithSchemaFilterOnlyWorksWithTablesThatMatchFilter() : void
Expand All @@ -229,9 +229,9 @@ static function ($assetName) {
self::assertVersionCount(1, 'diff command should add one version');

$versionClassContents = $this->getFileContentsForLatestVersion();
self::assertContains('CREATE TABLE bar', $versionClassContents);
self::assertContains('DROP TABLE bar', $versionClassContents);
self::assertNotContains(
self::assertStringContainsString('CREATE TABLE bar', $versionClassContents);
self::assertStringContainsString('DROP TABLE bar', $versionClassContents);
self::assertStringNotContainsString(
'CREATE TABLE foo',
$versionClassContents,
'should ignore the "foo" table due to schema asset filter'
Expand Down Expand Up @@ -267,8 +267,8 @@ static function ($assetName) {
self::assertVersionCount(1, 'diff command should add one version');

$versionClassContents = $this->getFileContentsForLatestVersion();
self::assertContains('CREATE TABLE FOO', $versionClassContents);
self::assertContains('DROP TABLE FOO', $versionClassContents);
self::assertStringContainsString('CREATE TABLE FOO', $versionClassContents);
self::assertStringContainsString('DROP TABLE FOO', $versionClassContents);
}

protected function setUp() : void
Expand Down
22 changes: 11 additions & 11 deletions tests/Doctrine/Migrations/Tests/Functional/FunctionalTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,13 +70,13 @@ public function testDoctrineMigrationsBin() : void

self::assertNotEmpty($output);

self::assertContains('migrations:execute', $output);
self::assertContains('migrations:generate', $output);
self::assertContains('migrations:latest', $output);
self::assertContains('migrations:migrate', $output);
self::assertContains('migrations:status', $output);
self::assertContains('migrations:up-to-date', $output);
self::assertContains('migrations:version', $output);
self::assertStringContainsString('migrations:execute', $output);
self::assertStringContainsString('migrations:generate', $output);
self::assertStringContainsString('migrations:latest', $output);
self::assertStringContainsString('migrations:migrate', $output);
self::assertStringContainsString('migrations:status', $output);
self::assertStringContainsString('migrations:up-to-date', $output);
self::assertStringContainsString('migrations:version', $output);
}

public function testMigrateUp() : void
Expand Down Expand Up @@ -395,8 +395,8 @@ public function testSchemaChangeAreNotTakenIntoAccountInPreAndPostMethod() : voi
self::assertFalse($schema->hasTable('bar2'), 'The table bar2 is present');

foreach ($queries as $query) {
self::assertNotContains('bar', $query);
self::assertNotContains('bar2', $query);
self::assertStringNotContainsString('bar', $query);
self::assertStringNotContainsString('bar2', $query);
}

$queries = $version->execute('down')->getSql();
Expand All @@ -407,8 +407,8 @@ public function testSchemaChangeAreNotTakenIntoAccountInPreAndPostMethod() : voi
self::assertFalse($schema->hasTable('bar2'), 'The table bar2 is present');

foreach ($queries as $query) {
self::assertNotContains('bar', $query);
self::assertNotContains('bar2', $query);
self::assertStringNotContainsString('bar', $query);
self::assertStringNotContainsString('bar2', $query);
}
}

Expand Down
5 changes: 3 additions & 2 deletions tests/Doctrine/Migrations/Tests/Generator/GeneratorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,9 @@ public function testGenerateMigration() : void

$migrationCode = file_get_contents($path);

self::assertContains('// up', $migrationCode);
self::assertContains('// down', $migrationCode);
self::assertNotFalse($migrationCode);
self::assertStringContainsString('// up', $migrationCode);
self::assertStringContainsString('// down', $migrationCode);

include $path;

Expand Down
8 changes: 4 additions & 4 deletions tests/Doctrine/Migrations/Tests/MigratorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ public function testMigrateWithNoMigrationsDontThrowsExceptionIfContiniousIntegr
$migrator->migrate(null, $migratorConfiguration);

self::assertCount(2, $messages, 'should output header and no migrations message');
self::assertContains('No migrations', $messages[1]);
self::assertStringContainsString('No migrations', $messages[1]);
}

/**
Expand Down Expand Up @@ -178,7 +178,7 @@ public function testWriteSqlFile(string $path, string $from, ?string $to, array
$outputWriter->expects(self::atLeastOnce())
->method('write');

/** @var Configuration|PHPUnit_Framework_MockObject_MockObject $migration */
/** @var Configuration|MockObject $migration */
$config = $this->createMock(Configuration::class);

$dependencyFactory = $this->createMock(DependencyFactory::class);
Expand Down Expand Up @@ -207,7 +207,7 @@ public function testWriteSqlFile(string $path, string $from, ?string $to, array

if ($to === null) { // this will always just test the "up" direction
$config->method('getLatestVersion')
->willReturn((int) $from + 1);
->willReturn((string) ((int) $from + 1));
}

/** @var Migrator|MockObject $migration */
Expand Down Expand Up @@ -261,7 +261,7 @@ public function testMigrateWithMigrationsAndAddTheCurrentVersionOutputsANoMigrat
$migration->migrate();

self::assertCount(1, $messages, 'should output the no migrations message');
self::assertContains('No migrations', $messages[0]);
self::assertStringContainsString('No migrations', $messages[0]);
}

public function testMigrateAllOrNothing() : void
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
use Doctrine\Migrations\Configuration\Configuration;
use Doctrine\Migrations\Tests\MigrationTestCase;
use Doctrine\Migrations\Tools\Console\Command\AbstractCommand;
use PHPUnit_Framework_MockObject_MockObject;
use PHPUnit\Framework\MockObject\MockObject;
use Symfony\Component\Console\Application;
use Symfony\Component\Console\Tester\CommandTester;
use function array_replace;
Expand All @@ -23,7 +23,7 @@ abstract class CommandTestCase extends MigrationTestCase
/** @var Application */
protected $app;

/** @var Configuration|PHPUnit_Framework_MockObject_MockObject */
/** @var Configuration|MockObject */
protected $config;

/** @var Connection */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@

namespace Doctrine\Migrations\Tests\Tools\Console\Command;

use PHPUnit_Framework_MockObject_MockObject;
use PHPUnit\Framework\MockObject\MockObject;
use Symfony\Component\Console\Application;
use Symfony\Component\Console\Helper\QuestionHelper;

trait DialogSupport
{
/** @var QuestionHelper|PHPUnit_Framework_MockObject_MockObject */
/** @var QuestionHelper|MockObject */
protected $questions;

protected function configureDialogs(Application $app) : void
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,6 @@ public function testDeleteOptionIfVersionFileDoesNotExist() : void
['interactive' => false]
);

self::assertContains('1233 deleted from the version table.', $commandTester->getDisplay());
self::assertStringContainsString('1233 deleted from the version table.', $commandTester->getDisplay());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@

use Doctrine\Migrations\Tools\Console\ConsoleRunner;
use Doctrine\ORM\Tools\Console\Helper\EntityManagerHelper;
use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\TestCase;
use PHPUnit_Framework_MockObject_MockObject;
use Symfony\Component\Console\Application;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Helper\HelperSet;
Expand All @@ -17,7 +17,7 @@
*/
class ConsoleRunnerTest extends TestCase
{
/** @var PHPUnit_Framework_MockObject_MockObject|EntityManagerHelper */
/** @var MockObject|EntityManagerHelper */
private $entityManagerHelper;

/** @var Application */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public function getAliases() : array
['prev', '4', 'getPrevVersion', null],
['next', '6', 'getNextVersion', null],
['latest', '7', 'getLatestVersion', null],
['current-5', '2', 'getDeltaVersion', -5],
['current-5', '2', 'getDeltaVersion', '-5'],
['test-5', null, null, null],
];
}
Expand Down
Loading

0 comments on commit 9b69ae5

Please sign in to comment.