Skip to content

Commit

Permalink
stop using deprecated PHPUnit APIs
Browse files Browse the repository at this point in the history
  • Loading branch information
xabbuh committed Aug 17, 2020
1 parent 83956b6 commit a1be26b
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 13 deletions.
4 changes: 2 additions & 2 deletions Tests/Command/TranslationDebugCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,8 @@ public function testDebugLegacyDefaultDirectory()
$tester = $this->createCommandTester(['foo' => 'foo'], ['bar' => 'bar']);
$tester->execute(['locale' => 'en']);

$this->assertRegExp('/missing/', $tester->getDisplay());
$this->assertRegExp('/unused/', $tester->getDisplay());
$this->assertMatchesRegularExpression('/missing/', $tester->getDisplay());
$this->assertMatchesRegularExpression('/unused/', $tester->getDisplay());
}

public function testDebugDefaultRootDirectory()
Expand Down
16 changes: 8 additions & 8 deletions Tests/Command/TranslationUpdateCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,31 +36,31 @@ public function testDumpSortedMessagesAndClean()
{
$tester = $this->createCommandTester(['messages' => ['foo' => 'foo', 'test' => 'test', 'bar' => 'bar']]);
$tester->execute(['command' => 'translation:update', 'locale' => 'en', 'bundle' => 'foo', '--dump-messages' => true, '--clean' => true, '--sort' => 'asc']);
$this->assertRegExp("/\*bar\*foo\*test/", preg_replace('/\s+/', '', $tester->getDisplay()));
$this->assertRegExp('/3 messages were successfully extracted/', $tester->getDisplay());
$this->assertMatchesRegularExpression("/\*bar\*foo\*test/", preg_replace('/\s+/', '', $tester->getDisplay()));
$this->assertMatchesRegularExpression('/3 messages were successfully extracted/', $tester->getDisplay());
}

public function testDumpReverseSortedMessagesAndClean()
{
$tester = $this->createCommandTester(['messages' => ['foo' => 'foo', 'test' => 'test', 'bar' => 'bar']]);
$tester->execute(['command' => 'translation:update', 'locale' => 'en', 'bundle' => 'foo', '--dump-messages' => true, '--clean' => true, '--sort' => 'desc']);
$this->assertRegExp("/\*test\*foo\*bar/", preg_replace('/\s+/', '', $tester->getDisplay()));
$this->assertRegExp('/3 messages were successfully extracted/', $tester->getDisplay());
$this->assertMatchesRegularExpression("/\*test\*foo\*bar/", preg_replace('/\s+/', '', $tester->getDisplay()));
$this->assertMatchesRegularExpression('/3 messages were successfully extracted/', $tester->getDisplay());
}

public function testDumpSortWithoutValueAndClean()
{
$tester = $this->createCommandTester(['messages' => ['foo' => 'foo', 'test' => 'test', 'bar' => 'bar']]);
$tester->execute(['command' => 'translation:update', 'locale' => 'en', 'bundle' => 'foo', '--dump-messages' => true, '--clean' => true, '--sort']);
$this->assertRegExp("/\*bar\*foo\*test/", preg_replace('/\s+/', '', $tester->getDisplay()));
$this->assertRegExp('/3 messages were successfully extracted/', $tester->getDisplay());
$this->assertMatchesRegularExpression("/\*bar\*foo\*test/", preg_replace('/\s+/', '', $tester->getDisplay()));
$this->assertMatchesRegularExpression('/3 messages were successfully extracted/', $tester->getDisplay());
}

public function testDumpWrongSortAndClean()
{
$tester = $this->createCommandTester(['messages' => ['foo' => 'foo', 'test' => 'test', 'bar' => 'bar']]);
$tester->execute(['command' => 'translation:update', 'locale' => 'en', 'bundle' => 'foo', '--dump-messages' => true, '--clean' => true, '--sort' => 'test']);
$this->assertRegExp('/\[ERROR\] Wrong sort order/', $tester->getDisplay());
$this->assertMatchesRegularExpression('/\[ERROR\] Wrong sort order/', $tester->getDisplay());
}

public function testDumpMessagesAndCleanInRootDirectory()
Expand Down Expand Up @@ -126,7 +126,7 @@ public function testWriteMessagesInLegacyRootDirectory()

$tester = $this->createCommandTester(['messages' => ['foo' => 'foo']]);
$tester->execute(['command' => 'translation:update', 'locale' => 'en', '--force' => true]);
$this->assertRegExp('/Translation files were successfully updated./', $tester->getDisplay());
$this->assertMatchesRegularExpression('/Translation files were successfully updated./', $tester->getDisplay());
}

public function testWriteMessagesForSpecificDomain()
Expand Down
6 changes: 3 additions & 3 deletions Tests/Console/ApplicationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -232,19 +232,19 @@ public function testRunOnlyWarnsOnUnregistrableCommandAtTheEnd()
public function testSuggestingPackagesWithExactMatch()
{
$result = $this->createEventForSuggestingPackages('server:dump', []);
$this->assertRegExp('/You may be looking for a command provided by/', $result);
$this->assertMatchesRegularExpression('/You may be looking for a command provided by/', $result);
}

public function testSuggestingPackagesWithPartialMatchAndNoAlternatives()
{
$result = $this->createEventForSuggestingPackages('server', []);
$this->assertRegExp('/You may be looking for a command provided by/', $result);
$this->assertMatchesRegularExpression('/You may be looking for a command provided by/', $result);
}

public function testSuggestingPackagesWithPartialMatchAndAlternatives()
{
$result = $this->createEventForSuggestingPackages('server', ['server:run']);
$this->assertNotRegExp('/You may be looking for a command provided by/', $result);
$this->assertDoesNotMatchRegularExpression('/You may be looking for a command provided by/', $result);
}

private function createEventForSuggestingPackages(string $command, array $alternatives = []): string
Expand Down

0 comments on commit a1be26b

Please sign in to comment.