Skip to content

Improve JS Translation DataProviderTest #32689

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: 2.4-develop
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@
*/
class DataProviderTest extends TestCase
{
private const STRING_TO_TRANSLATE = 'Proceed to Checkout';

private const STRING_TRANSLATION = 'Proceed to Checkout - Translated';

/**
* @var StringUtils
*/
Expand Down Expand Up @@ -52,12 +56,11 @@ protected function setUp(): void
*/
public function testGetData()
{
$expectedDictionary = ['Proceed to Checkout' => 'Proceed to Checkout - Translated'];

$this->stringUtils->saveTranslate('Proceed to Checkout', 'Proceed to Checkout - Translated');
$this->stringUtils->saveTranslate(self::STRING_TO_TRANSLATE, self::STRING_TRANSLATION);
$this->translate->setLocale('en_US')->loadData('frontend', true);
$dictionary = $this->translationDataProvider->getData('Magento/luma');
$this->assertEquals($expectedDictionary, $dictionary);
$this->assertArrayHasKey(self::STRING_TO_TRANSLATE, $dictionary);
$this->assertEquals(self::STRING_TRANSLATION, $dictionary[self::STRING_TO_TRANSLATE]);
}

/**
Expand All @@ -66,7 +69,7 @@ public function testGetData()
protected function tearDown(): void
{
try {
$this->stringUtils->deleteTranslate('Proceed to Checkout');
$this->stringUtils->deleteTranslate(self::STRING_TO_TRANSLATE);
} catch (NoSuchEntityException $exception) {
// translate already deleted
}
Expand Down