/
githubmirror
/
magento2
Обзор
Документация
Войти
/
githubmirror
/
magento2
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
2.4-develop
dev/tests/integration/testsuite/Magento/Translation/Controller/AjaxTest.php
78 строк
2 KB
Raj Mohan R
AC-16236::Upgrade Core Test Framework to PHPUnit 12 and Migrate from PHPUnit 10
11 фев 2026, 13:51
11 фев 2026, 13:51
152ed41
Код
Авторство
О чём код?
<?php /** * Copyright 2014 Adobe * All Rights Reserved. */ namespace Magento\Translation\Controller; use Magento\Framework\Exception\NoSuchEntityException; use Magento\TestFramework\Helper\Bootstrap; use Magento\Translation\Model\ResourceModel\StringUtils; use PHPUnit\Framework\Attributes\DataProvider; /** * Test for Magento\Translation\Controller\Ajax class. * * @magentoDbIsolation disabled */ class AjaxTest extends \Magento\TestFramework\TestCase\AbstractController { /** * @magentoConfigFixture default_store dev/translate_inline/active 1 */ #[DataProvider('indexActionDataProvider')] public function testIndexAction(array $postData, string $expected): void { $this->getRequest()->setPostValue('translate', $postData); $this->dispatch('translation/ajax/index'); $result = $this->getResponse()->getBody(); $this->assertEquals($expected, $result); } public static function indexActionDataProvider(): array { return [ [ [ [ 'original' => 'phrase with &', 'custom' => 'phrase with & translated', ], ], '{"phrase with &":"phrase with & translated"}', ], [ [ [ 'original' => 'phrase with &', 'custom' => 'phrase with & translated (updated)', ], ], '{"phrase with &":"phrase with & translated (updated)"}', ], [ [ [ 'original' => 'phrase with &', 'custom' => 'phrase with &', ], ], '[]', ], ]; } /** * @inheritDoc */ public static function tearDownAfterClass(): void { try { Bootstrap::getObjectManager()->get(StringUtils::class)->deleteTranslate('phrase with &'); } catch (NoSuchEntityException $exception) { //translate already deleted } parent::tearDownAfterClass(); } }