diff --git a/Tests/DataCollector/TranslationDataCollectorTest.php b/Tests/DataCollector/TranslationDataCollectorTest.php index e1c5f67f..39e74fac 100644 --- a/Tests/DataCollector/TranslationDataCollectorTest.php +++ b/Tests/DataCollector/TranslationDataCollectorTest.php @@ -12,6 +12,7 @@ namespace Symfony\Component\Translation\Tests\DataCollector; use PHPUnit\Framework\TestCase; +use Symfony\Component\HttpKernel\DataCollector\DataCollector; use Symfony\Component\Translation\DataCollector\TranslationDataCollector; use Symfony\Component\Translation\DataCollectorTranslator; @@ -19,7 +20,7 @@ class TranslationDataCollectorTest extends TestCase { protected function setUp(): void { - if (!class_exists(\Symfony\Component\HttpKernel\DataCollector\DataCollector::class)) { + if (!class_exists(DataCollector::class)) { $this->markTestSkipped('The "DataCollector" is not available'); } } diff --git a/Tests/DependencyInjection/TranslationExtractorPassTest.php b/Tests/DependencyInjection/TranslationExtractorPassTest.php index 6364b9bc..bcb2ccd4 100644 --- a/Tests/DependencyInjection/TranslationExtractorPassTest.php +++ b/Tests/DependencyInjection/TranslationExtractorPassTest.php @@ -13,6 +13,7 @@ use PHPUnit\Framework\TestCase; use Symfony\Component\DependencyInjection\ContainerBuilder; +use Symfony\Component\DependencyInjection\Exception\RuntimeException; use Symfony\Component\DependencyInjection\Reference; use Symfony\Component\Translation\DependencyInjection\TranslationExtractorPass; @@ -48,7 +49,7 @@ public function testProcessNoDefinitionFound() public function testProcessMissingAlias() { - $this->expectException(\Symfony\Component\DependencyInjection\Exception\RuntimeException::class); + $this->expectException(RuntimeException::class); $this->expectExceptionMessage('The alias for the tag "translation.extractor" of service "foo.id" must be set.'); $container = new ContainerBuilder(); $container->register('translation.extractor'); diff --git a/Tests/Loader/CsvFileLoaderTest.php b/Tests/Loader/CsvFileLoaderTest.php index 44cba5f3..062ea538 100644 --- a/Tests/Loader/CsvFileLoaderTest.php +++ b/Tests/Loader/CsvFileLoaderTest.php @@ -13,6 +13,8 @@ use PHPUnit\Framework\TestCase; use Symfony\Component\Config\Resource\FileResource; +use Symfony\Component\Translation\Exception\InvalidResourceException; +use Symfony\Component\Translation\Exception\NotFoundResourceException; use Symfony\Component\Translation\Loader\CsvFileLoader; class CsvFileLoaderTest extends TestCase @@ -41,7 +43,7 @@ public function testLoadDoesNothingIfEmpty() public function testLoadNonExistingResource() { - $this->expectException(\Symfony\Component\Translation\Exception\NotFoundResourceException::class); + $this->expectException(NotFoundResourceException::class); $loader = new CsvFileLoader(); $resource = __DIR__.'/../fixtures/not-exists.csv'; $loader->load($resource, 'en', 'domain1'); @@ -49,7 +51,7 @@ public function testLoadNonExistingResource() public function testLoadNonLocalResource() { - $this->expectException(\Symfony\Component\Translation\Exception\InvalidResourceException::class); + $this->expectException(InvalidResourceException::class); $loader = new CsvFileLoader(); $resource = 'http://example.com/resources.csv'; $loader->load($resource, 'en', 'domain1'); diff --git a/Tests/Loader/IcuDatFileLoaderTest.php b/Tests/Loader/IcuDatFileLoaderTest.php index fe107210..0f7ffa6f 100644 --- a/Tests/Loader/IcuDatFileLoaderTest.php +++ b/Tests/Loader/IcuDatFileLoaderTest.php @@ -12,6 +12,8 @@ namespace Symfony\Component\Translation\Tests\Loader; use Symfony\Component\Config\Resource\FileResource; +use Symfony\Component\Translation\Exception\InvalidResourceException; +use Symfony\Component\Translation\Exception\NotFoundResourceException; use Symfony\Component\Translation\Loader\IcuDatFileLoader; /** @@ -21,7 +23,7 @@ class IcuDatFileLoaderTest extends LocalizedTestCase { public function testLoadInvalidResource() { - $this->expectException(\Symfony\Component\Translation\Exception\InvalidResourceException::class); + $this->expectException(InvalidResourceException::class); $loader = new IcuDatFileLoader(); $loader->load(__DIR__.'/../fixtures/resourcebundle/corrupted/resources', 'es', 'domain2'); } @@ -53,7 +55,7 @@ public function testDatFrenchLoad() public function testLoadNonExistingResource() { - $this->expectException(\Symfony\Component\Translation\Exception\NotFoundResourceException::class); + $this->expectException(NotFoundResourceException::class); $loader = new IcuDatFileLoader(); $loader->load(__DIR__.'/../fixtures/non-existing.txt', 'en', 'domain1'); } diff --git a/Tests/Loader/IcuResFileLoaderTest.php b/Tests/Loader/IcuResFileLoaderTest.php index c3346522..1388f8a9 100644 --- a/Tests/Loader/IcuResFileLoaderTest.php +++ b/Tests/Loader/IcuResFileLoaderTest.php @@ -12,6 +12,8 @@ namespace Symfony\Component\Translation\Tests\Loader; use Symfony\Component\Config\Resource\DirectoryResource; +use Symfony\Component\Translation\Exception\InvalidResourceException; +use Symfony\Component\Translation\Exception\NotFoundResourceException; use Symfony\Component\Translation\Loader\IcuResFileLoader; /** @@ -33,14 +35,14 @@ public function testLoad() public function testLoadNonExistingResource() { - $this->expectException(\Symfony\Component\Translation\Exception\NotFoundResourceException::class); + $this->expectException(NotFoundResourceException::class); $loader = new IcuResFileLoader(); $loader->load(__DIR__.'/../fixtures/non-existing.txt', 'en', 'domain1'); } public function testLoadInvalidResource() { - $this->expectException(\Symfony\Component\Translation\Exception\InvalidResourceException::class); + $this->expectException(InvalidResourceException::class); $loader = new IcuResFileLoader(); $loader->load(__DIR__.'/../fixtures/resourcebundle/corrupted', 'en', 'domain1'); } diff --git a/Tests/Loader/IniFileLoaderTest.php b/Tests/Loader/IniFileLoaderTest.php index 3330e7e3..9e2027c4 100644 --- a/Tests/Loader/IniFileLoaderTest.php +++ b/Tests/Loader/IniFileLoaderTest.php @@ -13,6 +13,7 @@ use PHPUnit\Framework\TestCase; use Symfony\Component\Config\Resource\FileResource; +use Symfony\Component\Translation\Exception\NotFoundResourceException; use Symfony\Component\Translation\Loader\IniFileLoader; class IniFileLoaderTest extends TestCase @@ -41,7 +42,7 @@ public function testLoadDoesNothingIfEmpty() public function testLoadNonExistingResource() { - $this->expectException(\Symfony\Component\Translation\Exception\NotFoundResourceException::class); + $this->expectException(NotFoundResourceException::class); $loader = new IniFileLoader(); $resource = __DIR__.'/../fixtures/non-existing.ini'; $loader->load($resource, 'en', 'domain1'); diff --git a/Tests/Loader/JsonFileLoaderTest.php b/Tests/Loader/JsonFileLoaderTest.php index c3ef1f76..6dfaec8d 100644 --- a/Tests/Loader/JsonFileLoaderTest.php +++ b/Tests/Loader/JsonFileLoaderTest.php @@ -13,6 +13,8 @@ use PHPUnit\Framework\TestCase; use Symfony\Component\Config\Resource\FileResource; +use Symfony\Component\Translation\Exception\InvalidResourceException; +use Symfony\Component\Translation\Exception\NotFoundResourceException; use Symfony\Component\Translation\Loader\JsonFileLoader; class JsonFileLoaderTest extends TestCase @@ -41,7 +43,7 @@ public function testLoadDoesNothingIfEmpty() public function testLoadNonExistingResource() { - $this->expectException(\Symfony\Component\Translation\Exception\NotFoundResourceException::class); + $this->expectException(NotFoundResourceException::class); $loader = new JsonFileLoader(); $resource = __DIR__.'/../fixtures/non-existing.json'; $loader->load($resource, 'en', 'domain1'); @@ -49,7 +51,7 @@ public function testLoadNonExistingResource() public function testParseException() { - $this->expectException(\Symfony\Component\Translation\Exception\InvalidResourceException::class); + $this->expectException(InvalidResourceException::class); $this->expectExceptionMessage('Error parsing JSON: Syntax error, malformed JSON'); $loader = new JsonFileLoader(); $resource = __DIR__.'/../fixtures/malformed.json'; diff --git a/Tests/Loader/MoFileLoaderTest.php b/Tests/Loader/MoFileLoaderTest.php index 8da81ba8..637fb1c7 100644 --- a/Tests/Loader/MoFileLoaderTest.php +++ b/Tests/Loader/MoFileLoaderTest.php @@ -13,6 +13,8 @@ use PHPUnit\Framework\TestCase; use Symfony\Component\Config\Resource\FileResource; +use Symfony\Component\Translation\Exception\InvalidResourceException; +use Symfony\Component\Translation\Exception\NotFoundResourceException; use Symfony\Component\Translation\Loader\MoFileLoader; class MoFileLoaderTest extends TestCase @@ -44,7 +46,7 @@ public function testLoadPlurals() public function testLoadNonExistingResource() { - $this->expectException(\Symfony\Component\Translation\Exception\NotFoundResourceException::class); + $this->expectException(NotFoundResourceException::class); $loader = new MoFileLoader(); $resource = __DIR__.'/../fixtures/non-existing.mo'; $loader->load($resource, 'en', 'domain1'); @@ -52,7 +54,7 @@ public function testLoadNonExistingResource() public function testLoadInvalidResource() { - $this->expectException(\Symfony\Component\Translation\Exception\InvalidResourceException::class); + $this->expectException(InvalidResourceException::class); $loader = new MoFileLoader(); $resource = __DIR__.'/../fixtures/empty.mo'; $loader->load($resource, 'en', 'domain1'); diff --git a/Tests/Loader/PhpFileLoaderTest.php b/Tests/Loader/PhpFileLoaderTest.php index 1b2c9fac..ec6ad37b 100644 --- a/Tests/Loader/PhpFileLoaderTest.php +++ b/Tests/Loader/PhpFileLoaderTest.php @@ -13,6 +13,8 @@ use PHPUnit\Framework\TestCase; use Symfony\Component\Config\Resource\FileResource; +use Symfony\Component\Translation\Exception\InvalidResourceException; +use Symfony\Component\Translation\Exception\NotFoundResourceException; use Symfony\Component\Translation\Loader\PhpFileLoader; class PhpFileLoaderTest extends TestCase @@ -30,7 +32,7 @@ public function testLoad() public function testLoadNonExistingResource() { - $this->expectException(\Symfony\Component\Translation\Exception\NotFoundResourceException::class); + $this->expectException(NotFoundResourceException::class); $loader = new PhpFileLoader(); $resource = __DIR__.'/../fixtures/non-existing.php'; $loader->load($resource, 'en', 'domain1'); @@ -38,7 +40,7 @@ public function testLoadNonExistingResource() public function testLoadThrowsAnExceptionIfFileNotLocal() { - $this->expectException(\Symfony\Component\Translation\Exception\InvalidResourceException::class); + $this->expectException(InvalidResourceException::class); $loader = new PhpFileLoader(); $resource = 'http://example.com/resources.php'; $loader->load($resource, 'en', 'domain1'); diff --git a/Tests/Loader/PoFileLoaderTest.php b/Tests/Loader/PoFileLoaderTest.php index 04c084ea..c346a4be 100644 --- a/Tests/Loader/PoFileLoaderTest.php +++ b/Tests/Loader/PoFileLoaderTest.php @@ -13,6 +13,7 @@ use PHPUnit\Framework\TestCase; use Symfony\Component\Config\Resource\FileResource; +use Symfony\Component\Translation\Exception\NotFoundResourceException; use Symfony\Component\Translation\Loader\PoFileLoader; class PoFileLoaderTest extends TestCase @@ -55,7 +56,7 @@ public function testLoadDoesNothingIfEmpty() public function testLoadNonExistingResource() { - $this->expectException(\Symfony\Component\Translation\Exception\NotFoundResourceException::class); + $this->expectException(NotFoundResourceException::class); $loader = new PoFileLoader(); $resource = __DIR__.'/../fixtures/non-existing.po'; $loader->load($resource, 'en', 'domain1'); diff --git a/Tests/Loader/QtFileLoaderTest.php b/Tests/Loader/QtFileLoaderTest.php index 0d2817b3..0ab69414 100644 --- a/Tests/Loader/QtFileLoaderTest.php +++ b/Tests/Loader/QtFileLoaderTest.php @@ -13,6 +13,8 @@ use PHPUnit\Framework\TestCase; use Symfony\Component\Config\Resource\FileResource; +use Symfony\Component\Translation\Exception\InvalidResourceException; +use Symfony\Component\Translation\Exception\NotFoundResourceException; use Symfony\Component\Translation\Loader\QtFileLoader; class QtFileLoaderTest extends TestCase @@ -34,7 +36,7 @@ public function testLoad() public function testLoadNonExistingResource() { - $this->expectException(\Symfony\Component\Translation\Exception\NotFoundResourceException::class); + $this->expectException(NotFoundResourceException::class); $loader = new QtFileLoader(); $resource = __DIR__.'/../fixtures/non-existing.ts'; $loader->load($resource, 'en', 'domain1'); @@ -42,7 +44,7 @@ public function testLoadNonExistingResource() public function testLoadNonLocalResource() { - $this->expectException(\Symfony\Component\Translation\Exception\InvalidResourceException::class); + $this->expectException(InvalidResourceException::class); $loader = new QtFileLoader(); $resource = 'http://domain1.com/resources.ts'; $loader->load($resource, 'en', 'domain1'); @@ -50,7 +52,7 @@ public function testLoadNonLocalResource() public function testLoadInvalidResource() { - $this->expectException(\Symfony\Component\Translation\Exception\InvalidResourceException::class); + $this->expectException(InvalidResourceException::class); $loader = new QtFileLoader(); $resource = __DIR__.'/../fixtures/invalid-xml-resources.xlf'; $loader->load($resource, 'en', 'domain1'); @@ -61,7 +63,7 @@ public function testLoadEmptyResource() $loader = new QtFileLoader(); $resource = __DIR__.'/../fixtures/empty.xlf'; - $this->expectException(\Symfony\Component\Translation\Exception\InvalidResourceException::class); + $this->expectException(InvalidResourceException::class); $this->expectExceptionMessage(sprintf('Unable to load "%s".', $resource)); $loader->load($resource, 'en', 'domain1'); diff --git a/Tests/Loader/XliffFileLoaderTest.php b/Tests/Loader/XliffFileLoaderTest.php index ace7b84d..9836ff1c 100644 --- a/Tests/Loader/XliffFileLoaderTest.php +++ b/Tests/Loader/XliffFileLoaderTest.php @@ -13,6 +13,8 @@ use PHPUnit\Framework\TestCase; use Symfony\Component\Config\Resource\FileResource; +use Symfony\Component\Translation\Exception\InvalidResourceException; +use Symfony\Component\Translation\Exception\NotFoundResourceException; use Symfony\Component\Translation\Loader\XliffFileLoader; class XliffFileLoaderTest extends TestCase @@ -112,21 +114,21 @@ public function testTargetAttributesAreStoredCorrectly() public function testLoadInvalidResource() { - $this->expectException(\Symfony\Component\Translation\Exception\InvalidResourceException::class); + $this->expectException(InvalidResourceException::class); $loader = new XliffFileLoader(); $loader->load(__DIR__.'/../fixtures/resources.php', 'en', 'domain1'); } public function testLoadResourceDoesNotValidate() { - $this->expectException(\Symfony\Component\Translation\Exception\InvalidResourceException::class); + $this->expectException(InvalidResourceException::class); $loader = new XliffFileLoader(); $loader->load(__DIR__.'/../fixtures/non-valid.xlf', 'en', 'domain1'); } public function testLoadNonExistingResource() { - $this->expectException(\Symfony\Component\Translation\Exception\NotFoundResourceException::class); + $this->expectException(NotFoundResourceException::class); $loader = new XliffFileLoader(); $resource = __DIR__.'/../fixtures/non-existing.xlf'; $loader->load($resource, 'en', 'domain1'); @@ -134,7 +136,7 @@ public function testLoadNonExistingResource() public function testLoadThrowsAnExceptionIfFileNotLocal() { - $this->expectException(\Symfony\Component\Translation\Exception\InvalidResourceException::class); + $this->expectException(InvalidResourceException::class); $loader = new XliffFileLoader(); $resource = 'http://example.com/resources.xlf'; $loader->load($resource, 'en', 'domain1'); @@ -142,7 +144,7 @@ public function testLoadThrowsAnExceptionIfFileNotLocal() public function testDocTypeIsNotAllowed() { - $this->expectException(\Symfony\Component\Translation\Exception\InvalidResourceException::class); + $this->expectException(InvalidResourceException::class); $this->expectExceptionMessage('Document types are not allowed.'); $loader = new XliffFileLoader(); $loader->load(__DIR__.'/../fixtures/withdoctype.xlf', 'en', 'domain1'); @@ -153,7 +155,7 @@ public function testParseEmptyFile() $loader = new XliffFileLoader(); $resource = __DIR__.'/../fixtures/empty.xlf'; - $this->expectException(\Symfony\Component\Translation\Exception\InvalidResourceException::class); + $this->expectException(InvalidResourceException::class); $this->expectExceptionMessage(sprintf('Unable to load "%s":', $resource)); $loader->load($resource, 'en', 'domain1'); diff --git a/Tests/Loader/YamlFileLoaderTest.php b/Tests/Loader/YamlFileLoaderTest.php index f1e6f4ae..230c02e5 100644 --- a/Tests/Loader/YamlFileLoaderTest.php +++ b/Tests/Loader/YamlFileLoaderTest.php @@ -13,6 +13,8 @@ use PHPUnit\Framework\TestCase; use Symfony\Component\Config\Resource\FileResource; +use Symfony\Component\Translation\Exception\InvalidResourceException; +use Symfony\Component\Translation\Exception\NotFoundResourceException; use Symfony\Component\Translation\Loader\YamlFileLoader; class YamlFileLoaderTest extends TestCase @@ -41,7 +43,7 @@ public function testLoadDoesNothingIfEmpty() public function testLoadNonExistingResource() { - $this->expectException(\Symfony\Component\Translation\Exception\NotFoundResourceException::class); + $this->expectException(NotFoundResourceException::class); $loader = new YamlFileLoader(); $resource = __DIR__.'/../fixtures/non-existing.yml'; $loader->load($resource, 'en', 'domain1'); @@ -49,7 +51,7 @@ public function testLoadNonExistingResource() public function testLoadThrowsAnExceptionIfFileNotLocal() { - $this->expectException(\Symfony\Component\Translation\Exception\InvalidResourceException::class); + $this->expectException(InvalidResourceException::class); $loader = new YamlFileLoader(); $resource = 'http://example.com/resources.yml'; $loader->load($resource, 'en', 'domain1'); @@ -57,7 +59,7 @@ public function testLoadThrowsAnExceptionIfFileNotLocal() public function testLoadThrowsAnExceptionIfNotAnArray() { - $this->expectException(\Symfony\Component\Translation\Exception\InvalidResourceException::class); + $this->expectException(InvalidResourceException::class); $loader = new YamlFileLoader(); $resource = __DIR__.'/../fixtures/non-valid.yml'; $loader->load($resource, 'en', 'domain1'); diff --git a/Tests/LoggingTranslatorTest.php b/Tests/LoggingTranslatorTest.php index 3c0a643c..3578f83b 100644 --- a/Tests/LoggingTranslatorTest.php +++ b/Tests/LoggingTranslatorTest.php @@ -12,6 +12,7 @@ namespace Symfony\Component\Translation\Tests; use PHPUnit\Framework\TestCase; +use Psr\Log\LoggerInterface; use Symfony\Component\Translation\LoggingTranslator; use Symfony\Component\Translation\Translator; @@ -19,7 +20,7 @@ class LoggingTranslatorTest extends TestCase { public function testTransWithNoTranslationIsLogged() { - $logger = $this->getMockBuilder(\Psr\Log\LoggerInterface::class)->getMock(); + $logger = $this->createMock(LoggerInterface::class); $logger->expects($this->exactly(1)) ->method('warning') ->with('Translation not found.') diff --git a/Tests/MessageCatalogueTest.php b/Tests/MessageCatalogueTest.php index 151fb2dc..788a7258 100644 --- a/Tests/MessageCatalogueTest.php +++ b/Tests/MessageCatalogueTest.php @@ -12,6 +12,8 @@ namespace Symfony\Component\Translation\Tests; use PHPUnit\Framework\TestCase; +use Symfony\Component\Config\Resource\ResourceInterface; +use Symfony\Component\Translation\Exception\LogicException; use Symfony\Component\Translation\MessageCatalogue; class MessageCatalogueTest extends TestCase @@ -126,10 +128,10 @@ public function testReplace() public function testAddCatalogue() { - $r = $this->getMockBuilder(\Symfony\Component\Config\Resource\ResourceInterface::class)->getMock(); + $r = $this->createMock(ResourceInterface::class); $r->expects($this->any())->method('__toString')->willReturn('r'); - $r1 = $this->getMockBuilder(\Symfony\Component\Config\Resource\ResourceInterface::class)->getMock(); + $r1 = $this->createMock(ResourceInterface::class); $r1->expects($this->any())->method('__toString')->willReturn('r1'); $catalogue = new MessageCatalogue('en', ['domain1' => ['foo' => 'foo']]); @@ -150,13 +152,13 @@ public function testAddCatalogue() public function testAddFallbackCatalogue() { - $r = $this->getMockBuilder(\Symfony\Component\Config\Resource\ResourceInterface::class)->getMock(); + $r = $this->createMock(ResourceInterface::class); $r->expects($this->any())->method('__toString')->willReturn('r'); - $r1 = $this->getMockBuilder(\Symfony\Component\Config\Resource\ResourceInterface::class)->getMock(); + $r1 = $this->createMock(ResourceInterface::class); $r1->expects($this->any())->method('__toString')->willReturn('r1'); - $r2 = $this->getMockBuilder(\Symfony\Component\Config\Resource\ResourceInterface::class)->getMock(); + $r2 = $this->createMock(ResourceInterface::class); $r2->expects($this->any())->method('__toString')->willReturn('r2'); $catalogue = new MessageCatalogue('fr_FR', ['domain1' => ['foo' => 'foo'], 'domain2' => ['bar' => 'bar']]); @@ -179,7 +181,7 @@ public function testAddFallbackCatalogue() public function testAddFallbackCatalogueWithParentCircularReference() { - $this->expectException(\Symfony\Component\Translation\Exception\LogicException::class); + $this->expectException(LogicException::class); $main = new MessageCatalogue('en_US'); $fallback = new MessageCatalogue('fr_FR'); @@ -189,7 +191,7 @@ public function testAddFallbackCatalogueWithParentCircularReference() public function testAddFallbackCatalogueWithFallbackCircularReference() { - $this->expectException(\Symfony\Component\Translation\Exception\LogicException::class); + $this->expectException(LogicException::class); $fr = new MessageCatalogue('fr'); $en = new MessageCatalogue('en'); $es = new MessageCatalogue('es'); @@ -201,7 +203,7 @@ public function testAddFallbackCatalogueWithFallbackCircularReference() public function testAddCatalogueWhenLocaleIsNotTheSameAsTheCurrentOne() { - $this->expectException(\Symfony\Component\Translation\Exception\LogicException::class); + $this->expectException(LogicException::class); $catalogue = new MessageCatalogue('en'); $catalogue->addCatalogue(new MessageCatalogue('fr', [])); } @@ -209,11 +211,11 @@ public function testAddCatalogueWhenLocaleIsNotTheSameAsTheCurrentOne() public function testGetAddResource() { $catalogue = new MessageCatalogue('en'); - $r = $this->getMockBuilder(\Symfony\Component\Config\Resource\ResourceInterface::class)->getMock(); + $r = $this->createMock(ResourceInterface::class); $r->expects($this->any())->method('__toString')->willReturn('r'); $catalogue->addResource($r); $catalogue->addResource($r); - $r1 = $this->getMockBuilder(\Symfony\Component\Config\Resource\ResourceInterface::class)->getMock(); + $r1 = $this->createMock(ResourceInterface::class); $r1->expects($this->any())->method('__toString')->willReturn('r1'); $catalogue->addResource($r1); diff --git a/Tests/TranslatorCacheTest.php b/Tests/TranslatorCacheTest.php index a523b2bb..a4906878 100644 --- a/Tests/TranslatorCacheTest.php +++ b/Tests/TranslatorCacheTest.php @@ -101,7 +101,7 @@ public function testCatalogueIsReloadedWhenResourcesAreNoLongerFresh() $catalogue->addResource(new StaleResource()); // better use a helper class than a mock, because it gets serialized in the cache and re-loaded /** @var LoaderInterface|MockObject $loader */ - $loader = $this->getMockBuilder(LoaderInterface::class)->getMock(); + $loader = $this->createMock(LoaderInterface::class); $loader ->expects($this->exactly(2)) ->method('load') @@ -248,8 +248,8 @@ public function testPrimaryAndFallbackCataloguesContainTheSameMessagesRegardless public function testRefreshCacheWhenResourcesAreNoLongerFresh() { - $resource = $this->getMockBuilder(SelfCheckingResourceInterface::class)->getMock(); - $loader = $this->getMockBuilder(LoaderInterface::class)->getMock(); + $resource = $this->createMock(SelfCheckingResourceInterface::class); + $loader = $this->createMock(LoaderInterface::class); $resource->method('isFresh')->willReturn(false); $loader ->expects($this->exactly(2)) @@ -305,7 +305,7 @@ public function runForDebugAndProduction() private function createFailingLoader(): LoaderInterface { - $loader = $this->getMockBuilder(LoaderInterface::class)->getMock(); + $loader = $this->createMock(LoaderInterface::class); $loader ->expects($this->never()) ->method('load'); diff --git a/Tests/TranslatorTest.php b/Tests/TranslatorTest.php index 26d5587b..63ed59dd 100644 --- a/Tests/TranslatorTest.php +++ b/Tests/TranslatorTest.php @@ -12,6 +12,8 @@ namespace Symfony\Component\Translation\Tests; use PHPUnit\Framework\TestCase; +use Symfony\Component\Translation\Exception\InvalidArgumentException; +use Symfony\Component\Translation\Exception\NotFoundResourceException; use Symfony\Component\Translation\Exception\RuntimeException; use Symfony\Component\Translation\Loader\ArrayLoader; use Symfony\Component\Translation\MessageCatalogue; @@ -37,7 +39,7 @@ protected function tearDown(): void */ public function testConstructorInvalidLocale($locale) { - $this->expectException(\Symfony\Component\Translation\Exception\InvalidArgumentException::class); + $this->expectException(InvalidArgumentException::class); new Translator($locale); } @@ -66,7 +68,7 @@ public function testSetGetLocale() */ public function testSetInvalidLocale($locale) { - $this->expectException(\Symfony\Component\Translation\Exception\InvalidArgumentException::class); + $this->expectException(InvalidArgumentException::class); $translator = new Translator('fr'); $translator->setLocale($locale); } @@ -149,7 +151,7 @@ public function testSetFallbackLocalesMultiple() */ public function testSetFallbackInvalidLocales($locale) { - $this->expectException(\Symfony\Component\Translation\Exception\InvalidArgumentException::class); + $this->expectException(InvalidArgumentException::class); $translator = new Translator('fr'); $translator->setFallbackLocales(['fr', $locale]); } @@ -181,7 +183,7 @@ public function testTransWithFallbackLocale() */ public function testAddResourceInvalidLocales($locale) { - $this->expectException(\Symfony\Component\Translation\Exception\InvalidArgumentException::class); + $this->expectException(InvalidArgumentException::class); $translator = new Translator('fr'); $translator->addResource('array', ['foo' => 'foofoo'], $locale); } @@ -216,7 +218,7 @@ public function testAddResourceAfterTrans() */ public function testTransWithoutFallbackLocaleFile($format, $loader) { - $this->expectException(\Symfony\Component\Translation\Exception\NotFoundResourceException::class); + $this->expectException(NotFoundResourceException::class); $loaderClass = 'Symfony\\Component\\Translation\\Loader\\'.$loader; $translator = new Translator('en'); $translator->addLoader($format, new $loaderClass()); @@ -386,7 +388,7 @@ public function testTrans($expected, $id, $translation, $parameters, $locale, $d */ public function testTransInvalidLocale($locale) { - $this->expectException(\Symfony\Component\Translation\Exception\InvalidArgumentException::class); + $this->expectException(InvalidArgumentException::class); $translator = new Translator('en'); $translator->addLoader('array', new ArrayLoader()); $translator->addResource('array', ['foo' => 'foofoo'], 'en'); diff --git a/Tests/Writer/TranslationWriterTest.php b/Tests/Writer/TranslationWriterTest.php index 4150f155..5be07135 100644 --- a/Tests/Writer/TranslationWriterTest.php +++ b/Tests/Writer/TranslationWriterTest.php @@ -20,7 +20,7 @@ class TranslationWriterTest extends TestCase { public function testWrite() { - $dumper = $this->getMockBuilder(DumperInterface::class)->getMock(); + $dumper = $this->createMock(DumperInterface::class); $dumper ->expects($this->once()) ->method('dump');