From c4bc817c9f002f6a0f51184aa0ed4f66c1598c4c Mon Sep 17 00:00:00 2001 From: Evert Harmeling Date: Wed, 22 Nov 2023 16:48:13 +0100 Subject: [PATCH 1/5] Add memory_limit var to be able to run suite --- phpunit.xml.dist | 1 + 1 file changed, 1 insertion(+) diff --git a/phpunit.xml.dist b/phpunit.xml.dist index b9eae6ba26..37256f7c56 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -62,5 +62,6 @@ + From be0857049f8d0543693883f3faa57b7e34398cec Mon Sep 17 00:00:00 2001 From: Evert Harmeling Date: Wed, 22 Nov 2023 16:50:14 +0100 Subject: [PATCH 2/5] Allow Symfony 7 --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 48366b5ddc..f7cc10e1c8 100644 --- a/composer.json +++ b/composer.json @@ -46,7 +46,7 @@ "psr/clock": "^1.0", "symfony/polyfill-mbstring": "^1.0", "symfony/polyfill-php80": "^1.16", - "symfony/translation": "^3.4 || ^4.0 || ^5.0 || ^6.0" + "symfony/translation": "^3.4 || ^4.0 || ^5.0 || ^6.0 || ^7.0" }, "require-dev": { "doctrine/dbal": "^2.0 || ^3.1.4 || ^4.0", From ec03935992f8e6d307c34a0df4644a4ecc8458b5 Mon Sep 17 00:00:00 2001 From: Evert Harmeling Date: Wed, 22 Nov 2023 16:50:28 +0100 Subject: [PATCH 3/5] Fix compatibility with Symfony 7 --- lazy/Carbon/TranslatorImmutableStrongType.php | 38 +++++++ lazy/Carbon/TranslatorImmutableWeakType.php | 34 ++++++ lazy/Carbon/TranslatorStrongType.php | 9 ++ lazy/Carbon/TranslatorWeakType.php | 13 +++ src/Carbon/AbstractTranslator.php | 3 +- src/Carbon/AbstractTranslatorImmutable.php | 104 ++++++++++++++++++ src/Carbon/CarbonPeriod.php | 2 +- src/Carbon/TranslatorImmutable.php | 101 +++-------------- 8 files changed, 218 insertions(+), 86 deletions(-) create mode 100644 lazy/Carbon/TranslatorImmutableStrongType.php create mode 100644 lazy/Carbon/TranslatorImmutableWeakType.php create mode 100644 src/Carbon/AbstractTranslatorImmutable.php diff --git a/lazy/Carbon/TranslatorImmutableStrongType.php b/lazy/Carbon/TranslatorImmutableStrongType.php new file mode 100644 index 0000000000..fd50ed789e --- /dev/null +++ b/lazy/Carbon/TranslatorImmutableStrongType.php @@ -0,0 +1,38 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Carbon; + +use Symfony\Component\Config\ConfigCacheFactoryInterface; +use Symfony\Component\Translation\Exception\InvalidArgumentException; + +if (!class_exists(LazyTranslatorImmutable::class, false)) { + class LazyTranslatorImmutable extends AbstractTranslatorImmutable + { + /** + * @throws InvalidArgumentException + */ + public function setLocale(string $locale): void + { + $this->setLocaleIdentifier($locale); + } + + public function setConfigCacheFactory(ConfigCacheFactoryInterface $configCacheFactory): void + { + $this->setConfigCacheFactoryObject($configCacheFactory); + } + + public function setFallbackLocales(array $locales): void + { + $this->setFallbackLocalesArray($locales); + } + } +} diff --git a/lazy/Carbon/TranslatorImmutableWeakType.php b/lazy/Carbon/TranslatorImmutableWeakType.php new file mode 100644 index 0000000000..4a11f7207d --- /dev/null +++ b/lazy/Carbon/TranslatorImmutableWeakType.php @@ -0,0 +1,34 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Carbon; + +use Symfony\Component\Config\ConfigCacheFactoryInterface; + +if (!class_exists(LazyTranslatorImmutable::class, false)) { + class LazyTranslatorImmutable extends AbstractTranslatorImmutable + { + public function setLocale($locale) + { + $this->setLocaleIdentifier($locale); + } + + public function setConfigCacheFactory(ConfigCacheFactoryInterface $configCacheFactory) + { + $this->setConfigCacheFactoryObject($configCacheFactory); + } + + public function setFallbackLocales(array $locales) + { + $this->setFallbackLocalesArray($locales); + } + } +} diff --git a/lazy/Carbon/TranslatorStrongType.php b/lazy/Carbon/TranslatorStrongType.php index d35308a66c..57484f070c 100644 --- a/lazy/Carbon/TranslatorStrongType.php +++ b/lazy/Carbon/TranslatorStrongType.php @@ -11,6 +11,7 @@ namespace Carbon; +use Symfony\Component\Translation\Exception\InvalidArgumentException; use Symfony\Component\Translation\MessageCatalogueInterface; if (!class_exists(LazyTranslator::class, false)) { @@ -48,5 +49,13 @@ private function getPrivateProperty($instance, string $field) return $this->$field; })->call($instance, $field); } + + /** + * @throws InvalidArgumentException + */ + public function setLocale(string $locale): void + { + parent::setLocaleIdentifier($locale); + } } } diff --git a/lazy/Carbon/TranslatorWeakType.php b/lazy/Carbon/TranslatorWeakType.php index 94dbdc30ae..d2fa19894e 100644 --- a/lazy/Carbon/TranslatorWeakType.php +++ b/lazy/Carbon/TranslatorWeakType.php @@ -11,6 +11,8 @@ namespace Carbon; +use Symfony\Component\Translation\Exception\InvalidArgumentException; + if (!class_exists(LazyTranslator::class, false)) { class LazyTranslator extends AbstractTranslator { @@ -28,5 +30,16 @@ public function trans($id, array $parameters = [], $domain = null, $locale = nul { return $this->translate($id, $parameters, $domain, $locale); } + + public function setLocale($locale) + { + try { + parent::setLocaleIdentifier($locale); + } catch (InvalidArgumentException $e) { + return false; + } + + return true; + } } } diff --git a/src/Carbon/AbstractTranslator.php b/src/Carbon/AbstractTranslator.php index 8b8fe089ee..b7ba945c7d 100644 --- a/src/Carbon/AbstractTranslator.php +++ b/src/Carbon/AbstractTranslator.php @@ -300,13 +300,14 @@ public function getMessages($locale = null) } /** + * @internal * Set the current translator locale and indicate if the source locale file exists * * @param string $locale locale ex. en * * @return bool */ - public function setLocale($locale) + protected function setLocaleIdentifier($locale) { $locale = preg_replace_callback('/[-_]([a-z]{2,}|\d{2,})/', function ($matches) { // _2-letters or YUE is a region, _3+-letters is a variant diff --git a/src/Carbon/AbstractTranslatorImmutable.php b/src/Carbon/AbstractTranslatorImmutable.php new file mode 100644 index 0000000000..e0b5c9e4fa --- /dev/null +++ b/src/Carbon/AbstractTranslatorImmutable.php @@ -0,0 +1,104 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Carbon; + +use Carbon\Exceptions\ImmutableException; +use Symfony\Component\Config\ConfigCacheFactoryInterface; +use Symfony\Component\Translation\Formatter\MessageFormatterInterface; + +class AbstractTranslatorImmutable extends Translator +{ + /** @var bool */ + private $constructed = false; + + public function __construct($locale, MessageFormatterInterface $formatter = null, $cacheDir = null, $debug = false) + { + parent::__construct($locale, $formatter, $cacheDir, $debug); + $this->constructed = true; + } + + /** + * @codeCoverageIgnore + */ + public function setDirectories(array $directories) + { + $this->disallowMutation(__METHOD__); + + return parent::setDirectories($directories); + } + + /** + * @internal + */ + protected function setLocaleIdentifier($locale) + { + $this->disallowMutation(__METHOD__); + + parent::setLocale($locale); + } + + /** + * @codeCoverageIgnore + */ + public function setMessages($locale, $messages) + { + $this->disallowMutation(__METHOD__); + + return parent::setMessages($locale, $messages); + } + + /** + * @codeCoverageIgnore + */ + public function setTranslations($messages) + { + $this->disallowMutation(__METHOD__); + + return parent::setTranslations($messages); + } + + /** + * @internal + * @codeCoverageIgnore + */ + protected function setConfigCacheFactoryObject(ConfigCacheFactoryInterface $configCacheFactory) + { + $this->disallowMutation(__METHOD__); + + parent::setConfigCacheFactory($configCacheFactory); + } + + public function resetMessages($locale = null) + { + $this->disallowMutation(__METHOD__); + + return parent::resetMessages($locale); + } + + /** + * @internal + * @codeCoverageIgnore + */ + protected function setFallbackLocalesArray(array $locales) + { + $this->disallowMutation(__METHOD__); + + parent::setFallbackLocales($locales); + } + + private function disallowMutation($method) + { + if ($this->constructed) { + throw new ImmutableException($method.' not allowed on '.static::class); + } + } +} diff --git a/src/Carbon/CarbonPeriod.php b/src/Carbon/CarbonPeriod.php index b0e7e8b10d..654f783c4b 100644 --- a/src/Carbon/CarbonPeriod.php +++ b/src/Carbon/CarbonPeriod.php @@ -2319,7 +2319,7 @@ public function ceilUnit($unit, $precision = 1) public function round($precision = null, $function = 'round') { return $this->roundWith( - $precision ?? $this->getDateInterval()->setLocalTranslator(TranslatorImmutable::get('en'))->forHumans(), + $precision ?? $this->getDateInterval()->setLocalTranslator(AbstractTranslatorImmutable::get('en'))->forHumans(), $function ); } diff --git a/src/Carbon/TranslatorImmutable.php b/src/Carbon/TranslatorImmutable.php index ad36c6704f..d1b13851b1 100644 --- a/src/Carbon/TranslatorImmutable.php +++ b/src/Carbon/TranslatorImmutable.php @@ -11,89 +11,22 @@ namespace Carbon; -use Carbon\Exceptions\ImmutableException; -use Symfony\Component\Config\ConfigCacheFactoryInterface; -use Symfony\Component\Translation\Formatter\MessageFormatterInterface; - -class TranslatorImmutable extends Translator +use ReflectionMethod; +use Symfony\Component\Translation; +use Symfony\Contracts\Translation\TranslatorInterface; + +$transMethod = new ReflectionMethod( + class_exists(TranslatorInterface::class) + ? TranslatorInterface::class + : Translation\Translator::class, + 'trans' +); + +require $transMethod->hasReturnType() + ? __DIR__.'/../../lazy/Carbon/TranslatorImmutableStrongType.php' + : __DIR__.'/../../lazy/Carbon/TranslatorImmutableWeakType.php'; + +class TranslatorImmutable extends LazyTranslatorImmutable { - /** @var bool */ - private $constructed = false; - - public function __construct($locale, MessageFormatterInterface $formatter = null, $cacheDir = null, $debug = false) - { - parent::__construct($locale, $formatter, $cacheDir, $debug); - $this->constructed = true; - } - - /** - * @codeCoverageIgnore - */ - public function setDirectories(array $directories) - { - $this->disallowMutation(__METHOD__); - - return parent::setDirectories($directories); - } - - public function setLocale($locale) - { - $this->disallowMutation(__METHOD__); - - return parent::setLocale($locale); - } - - /** - * @codeCoverageIgnore - */ - public function setMessages($locale, $messages) - { - $this->disallowMutation(__METHOD__); - - return parent::setMessages($locale, $messages); - } - - /** - * @codeCoverageIgnore - */ - public function setTranslations($messages) - { - $this->disallowMutation(__METHOD__); - - return parent::setTranslations($messages); - } - - /** - * @codeCoverageIgnore - */ - public function setConfigCacheFactory(ConfigCacheFactoryInterface $configCacheFactory) - { - $this->disallowMutation(__METHOD__); - - parent::setConfigCacheFactory($configCacheFactory); - } - - public function resetMessages($locale = null) - { - $this->disallowMutation(__METHOD__); - - return parent::resetMessages($locale); - } - - /** - * @codeCoverageIgnore - */ - public function setFallbackLocales(array $locales) - { - $this->disallowMutation(__METHOD__); - - parent::setFallbackLocales($locales); - } - - private function disallowMutation($method) - { - if ($this->constructed) { - throw new ImmutableException($method.' not allowed on '.static::class); - } - } + // Proxy dynamically loaded LazyTranslator in a static way } From c6824fa04bb209b532cab5d83be03ad6e8ffdda5 Mon Sep 17 00:00:00 2001 From: Evert Harmeling Date: Wed, 22 Nov 2023 16:51:09 +0100 Subject: [PATCH 4/5] Fix testsuite --- tests/AbstractTestCase.php | 20 ++++++++ tests/Carbon/LocalizationTest.php | 44 ++++++++++++++-- tests/CarbonImmutable/LocalizationTest.php | 60 ++++++++++++++++++---- tests/Language/TranslatorTest.php | 6 +-- 4 files changed, 113 insertions(+), 17 deletions(-) diff --git a/tests/AbstractTestCase.php b/tests/AbstractTestCase.php index 5bdc253d32..88f37d2b5e 100644 --- a/tests/AbstractTestCase.php +++ b/tests/AbstractTestCase.php @@ -23,10 +23,15 @@ use Closure; use DateTime; use PHPUnit\Framework\TestCase; +use ReflectionMethod; use ReflectionProperty; +use Symfony\Component\Translation; +use Symfony\Contracts\Translation\TranslatorInterface; use Tests\PHPUnit\AssertObjectHasPropertyTrait; use Throwable; +use function class_exists; + /** * @SuppressWarnings(PHPMD.NumberOfChildren) */ @@ -344,4 +349,19 @@ protected function firstValidTimezoneAmong(array $timezones): CarbonTimeZone throw $firstError; } + + /** + * @return bool + */ + protected function translatorHasReturnType() + { + $transMethod = new ReflectionMethod( + class_exists(TranslatorInterface::class) + ? TranslatorInterface::class + : Translation\Translator::class, + 'trans' + ); + + return $transMethod->hasReturnType(); + } } diff --git a/tests/Carbon/LocalizationTest.php b/tests/Carbon/LocalizationTest.php index 3d6e7ba34c..8b44649037 100644 --- a/tests/Carbon/LocalizationTest.php +++ b/tests/Carbon/LocalizationTest.php @@ -375,16 +375,28 @@ public static function dataForTestSetLocaleWithMalformedLocale(): Generator */ public function testSetLocaleWithMalformedLocale($malformedLocale) { + if ($this->translatorHasReturnType()) { + $this->markTestSkipped('Translator::setLocale returns void'); + } + $this->assertTrue(Carbon::setLocale($malformedLocale)); } public function testSetLocaleWithNonExistingLocale() { + if ($this->translatorHasReturnType()) { + $this->markTestSkipped('Translator::setLocale returns void'); + } + $this->assertFalse(Carbon::setLocale('pt-XX')); } public function testSetLocaleWithUnknownLocale() { + if ($this->translatorHasReturnType()) { + $this->markTestSkipped('Translator::setLocale returns void'); + } + $this->assertFalse(Carbon::setLocale('zz')); } @@ -526,24 +538,42 @@ public function testAddAndRemoveDirectory() $translator = Carbon::getTranslator(); Carbon::setLocale('en'); - $this->assertFalse(Carbon::setLocale('foo')); + $setLocale = Carbon::setLocale('foo'); + if (!$this->translatorHasReturnType()) { + $this->assertFalse($setLocale); + } + $this->assertSame('Saturday', Carbon::parse('2018-07-07 00:00:00')->isoFormat('dddd')); $translator->addDirectory($directory); - $this->assertTrue(Carbon::setLocale('foo')); + $setLocale = Carbon::setLocale('foo'); + if (!$this->translatorHasReturnType()) { + $this->assertTrue($setLocale); + } + $this->assertSame('samedi', Carbon::parse('2018-07-07 00:00:00')->isoFormat('dddd')); Carbon::setLocale('en'); $translator->removeDirectory($directory); - $this->assertFalse(Carbon::setLocale('bar')); + $setLocale = Carbon::setLocale('bar'); + if (!$this->translatorHasReturnType()) { + $this->assertFalse($setLocale); + } + $this->assertSame('Saturday', Carbon::parse('2018-07-07 00:00:00')->isoFormat('dddd')); - $this->assertTrue(Carbon::setLocale('foo')); + $setLocale = Carbon::setLocale('foo'); + if (!$this->translatorHasReturnType()) { + $this->assertTrue($setLocale); + } + $this->assertSame('samedi', Carbon::parse('2018-07-07 00:00:00')->isoFormat('dddd')); - $this->assertTrue(Carbon::setLocale('en')); + if (!$this->translatorHasReturnType()) { + $this->assertTrue(Carbon::setLocale('en')); + } } public function testLocaleHasShortUnits() @@ -587,6 +617,10 @@ public function testLocaleHasShortUnits() public function testLocaleHasDiffSyntax() { + if ($this->translatorHasReturnType()) { + $this->markTestSkipped('Translator::setLocale returns void'); + } + $withDiffSyntax = [ 'year' => 'foo', 'ago' => ':time ago', diff --git a/tests/CarbonImmutable/LocalizationTest.php b/tests/CarbonImmutable/LocalizationTest.php index 9d3a3382ef..91456b8d69 100644 --- a/tests/CarbonImmutable/LocalizationTest.php +++ b/tests/CarbonImmutable/LocalizationTest.php @@ -377,16 +377,28 @@ public static function dataForTestSetLocaleWithMalformedLocale() */ public function testSetLocaleWithMalformedLocale($malformedLocale) { + if ($this->translatorHasReturnType()) { + $this->markTestSkipped('Translator::setLocale returns void'); + } + $this->assertTrue(Carbon::setLocale($malformedLocale)); } public function testSetLocaleWithNonExistingLocale() { + if ($this->translatorHasReturnType()) { + $this->markTestSkipped('Translator::setLocale returns void'); + } + $this->assertFalse(Carbon::setLocale('pt-XX')); } public function testSetLocaleWithUnknownLocale() { + if ($this->translatorHasReturnType()) { + $this->markTestSkipped('Translator::setLocale returns void'); + } + $this->assertFalse(Carbon::setLocale('zz')); } @@ -498,24 +510,42 @@ public function testAddAndRemoveDirectory() $translator = Carbon::getTranslator(); Carbon::setLocale('en'); - $this->assertFalse(Carbon::setLocale('foo')); + $setLocale = Carbon::setLocale('foo'); + if (!$this->translatorHasReturnType()) { + $this->assertFalse($setLocale); + } + $this->assertSame('Saturday', Carbon::parse('2018-07-07 00:00:00')->isoFormat('dddd')); $translator->addDirectory($directory); - $this->assertTrue(Carbon::setLocale('foo')); + $setLocale = Carbon::setLocale('foo'); + if (!$this->translatorHasReturnType()) { + $this->assertTrue($setLocale); + } + $this->assertSame('samedi', Carbon::parse('2018-07-07 00:00:00')->isoFormat('dddd')); Carbon::setLocale('en'); $translator->removeDirectory($directory); - $this->assertFalse(Carbon::setLocale('bar')); + $setLocale = Carbon::setLocale('bar'); + if (!$this->translatorHasReturnType()) { + $this->assertFalse($setLocale); + } + $this->assertSame('Saturday', Carbon::parse('2018-07-07 00:00:00')->isoFormat('dddd')); - $this->assertTrue(Carbon::setLocale('foo')); + $setLocale = Carbon::setLocale('foo'); + if (!$this->translatorHasReturnType()) { + $this->assertTrue($setLocale); + } + $this->assertSame('samedi', Carbon::parse('2018-07-07 00:00:00')->isoFormat('dddd')); - $this->assertTrue(Carbon::setLocale('en')); + if (!$this->translatorHasReturnType()) { + $this->assertTrue(Carbon::setLocale('en')); + } } public function testLocaleHasShortUnits() @@ -559,6 +589,10 @@ public function testLocaleHasShortUnits() public function testLocaleHasDiffSyntax() { + if ($this->translatorHasReturnType()) { + $this->markTestSkipped('Translator::setLocale returns void'); + } + $withDiffSyntax = [ 'year' => 'foo', 'ago' => ':time ago', @@ -577,11 +611,19 @@ public function testLocaleHasDiffSyntax() $translator->setMessages($withDiffSyntaxLocale, $withDiffSyntax); $translator->setMessages($withoutDiffSyntaxLocale, $withoutDiffSyntax); - $this->assertTrue(Carbon::localeHasDiffSyntax($withDiffSyntaxLocale)); - $this->assertFalse(Carbon::localeHasDiffSyntax($withoutDiffSyntaxLocale)); + if ($this->translatorHasReturnType()) { + $this->expectException(Symfony\Component\Translation\Exception\InvalidArgumentException::class); + Carbon::localeHasDiffSyntax($withoutDiffSyntaxLocale); - $this->assertTrue(Carbon::localeHasDiffSyntax('ka')); - $this->assertFalse(Carbon::localeHasDiffSyntax('foobar')); + $this->expectException(Symfony\Component\Translation\Exception\InvalidArgumentException::class); + Carbon::localeHasDiffSyntax('foobar'); + } else { + $this->assertTrue(Carbon::localeHasDiffSyntax($withDiffSyntaxLocale)); + $this->assertFalse(Carbon::localeHasDiffSyntax($withoutDiffSyntaxLocale)); + + $this->assertTrue(Carbon::localeHasDiffSyntax('ka')); + $this->assertFalse(Carbon::localeHasDiffSyntax('foobar')); + } } public function testLocaleHasDiffOneDayWords() diff --git a/tests/Language/TranslatorTest.php b/tests/Language/TranslatorTest.php index 853d972ce1..4cb8dc7273 100644 --- a/tests/Language/TranslatorTest.php +++ b/tests/Language/TranslatorTest.php @@ -18,7 +18,7 @@ use Carbon\Exceptions\ImmutableException; use Carbon\Exceptions\NotLocaleAwareException; use Carbon\Translator; -use Carbon\TranslatorImmutable; +use Carbon\AbstractTranslatorImmutable; use ReflectionMethod; use Tests\AbstractTestCase; @@ -83,8 +83,8 @@ public function testNotLocaleAwareException() public function testTranslatorImmutable() { $this->expectExceptionObject( - new ImmutableException('setTranslations not allowed on '.TranslatorImmutable::class) + new ImmutableException('setTranslations not allowed on '.AbstractTranslatorImmutable::class) ); - TranslatorImmutable::get('en')->setTranslations([]); + AbstractTranslatorImmutable::get('en')->setTranslations([]); } } From 45c4645fac464eeb64408c0d19de5d4df7d2945d Mon Sep 17 00:00:00 2001 From: Evert Harmeling Date: Wed, 22 Nov 2023 16:57:33 +0100 Subject: [PATCH 5/5] Use the specific classes in stead of the abstract classes --- src/Carbon/CarbonPeriod.php | 2 +- tests/AbstractTestCase.php | 2 -- tests/Language/TranslatorTest.php | 9 ++++----- 3 files changed, 5 insertions(+), 8 deletions(-) diff --git a/src/Carbon/CarbonPeriod.php b/src/Carbon/CarbonPeriod.php index 654f783c4b..b0e7e8b10d 100644 --- a/src/Carbon/CarbonPeriod.php +++ b/src/Carbon/CarbonPeriod.php @@ -2319,7 +2319,7 @@ public function ceilUnit($unit, $precision = 1) public function round($precision = null, $function = 'round') { return $this->roundWith( - $precision ?? $this->getDateInterval()->setLocalTranslator(AbstractTranslatorImmutable::get('en'))->forHumans(), + $precision ?? $this->getDateInterval()->setLocalTranslator(TranslatorImmutable::get('en'))->forHumans(), $function ); } diff --git a/tests/AbstractTestCase.php b/tests/AbstractTestCase.php index 88f37d2b5e..8ee350c894 100644 --- a/tests/AbstractTestCase.php +++ b/tests/AbstractTestCase.php @@ -30,8 +30,6 @@ use Tests\PHPUnit\AssertObjectHasPropertyTrait; use Throwable; -use function class_exists; - /** * @SuppressWarnings(PHPMD.NumberOfChildren) */ diff --git a/tests/Language/TranslatorTest.php b/tests/Language/TranslatorTest.php index 4cb8dc7273..94d23313e3 100644 --- a/tests/Language/TranslatorTest.php +++ b/tests/Language/TranslatorTest.php @@ -13,12 +13,11 @@ namespace Tests\Language; -use Carbon\AbstractTranslator; use Carbon\Carbon; use Carbon\Exceptions\ImmutableException; use Carbon\Exceptions\NotLocaleAwareException; use Carbon\Translator; -use Carbon\AbstractTranslatorImmutable; +use Carbon\TranslatorImmutable; use ReflectionMethod; use Tests\AbstractTestCase; @@ -62,7 +61,7 @@ public function testMethodsPriorities() public function testCompareChunkLists() { - $method = new ReflectionMethod(AbstractTranslator::class, 'compareChunkLists'); + $method = new ReflectionMethod(Translator::class, 'compareChunkLists'); $method->setAccessible(true); $this->assertSame(20, $method->invoke(null, ['a', 'b'], ['a', 'b'])); $this->assertSame(10, $method->invoke(null, ['a', 'b'], ['a', 'c'])); @@ -83,8 +82,8 @@ public function testNotLocaleAwareException() public function testTranslatorImmutable() { $this->expectExceptionObject( - new ImmutableException('setTranslations not allowed on '.AbstractTranslatorImmutable::class) + new ImmutableException('setTranslations not allowed on '.TranslatorImmutable::class) ); - AbstractTranslatorImmutable::get('en')->setTranslations([]); + TranslatorImmutable::get('en')->setTranslations([]); } }