Skip to content

Commit

Permalink
Set expected message based on eccube version
Browse files Browse the repository at this point in the history
  • Loading branch information
ptthao-yrglmvn committed Feb 26, 2024
1 parent 2438e80 commit 904776e
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions Tests/Web/Admin/ProductMakerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
namespace Plugin\Maker42\Tests\Web\Admin;

use Faker\Generator;
use Eccube\Common\Constant;
use Plugin\Maker42\Tests\Web\MakerWebCommon;
use Symfony\Component\HttpKernel\Client;
use Symfony\Component\DomCrawler\Crawler;
Expand Down Expand Up @@ -146,7 +147,9 @@ public function testProductNewWithAddMakerInvalid()
$errorMessages = $crawler->filter('.form-error-message')->each(function (Crawler $node): string {
return $node->text();
});
$this->assertStringContainsString('選択した値は無効です。', implode("\n", $errorMessages));
$versionParts = explode('-', Constant::VERSION);
$expectedMessage = version_compare(reset($versionParts), '4.3.0', '<') ? '有効な値ではありません。' : '選択した値は無効です。';
$this->assertStringContainsString($expectedMessage, implode("\n", $errorMessages));

// Check database
$Product = $this->productRepository->findOneBy([], ['id' => 'DESC']);
Expand Down Expand Up @@ -417,7 +420,9 @@ public function testProductEditWithAddMakerInvalid()
$errorMessages = $crawler->filter('.form-error-message')->each(function (Crawler $node): string {
return $node->text();
});
$this->assertStringContainsString('選択した値は無効です。', implode("\n", $errorMessages));
$versionParts = explode('-', Constant::VERSION);
$expectedMessage = version_compare(reset($versionParts), '4.3.0', '<') ? '有効な値ではありません。' : '選択した値は無効です。';
$this->assertStringContainsString($expectedMessage, implode("\n", $errorMessages));

// Check database
$Product = $this->productRepository->findOneBy([], ['id' => 'DESC']);
Expand Down

0 comments on commit 904776e

Please sign in to comment.