From 89e03d9c8363940c325087060aad803d4355341f Mon Sep 17 00:00:00 2001 From: Pham Thanh Thao Date: Fri, 23 Feb 2024 08:48:34 +0700 Subject: [PATCH 1/8] Change the container retrieval method --- Tests/Web/Admin/MakerControllerTest.php | 2 +- Tests/Web/Admin/ProductMakerTest.php | 2 +- Tests/Web/ProductDetailTest.php | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Tests/Web/Admin/MakerControllerTest.php b/Tests/Web/Admin/MakerControllerTest.php index 9254d07..e748db0 100644 --- a/Tests/Web/Admin/MakerControllerTest.php +++ b/Tests/Web/Admin/MakerControllerTest.php @@ -37,7 +37,7 @@ protected function setUp(): void parent::setUp(); $this->deleteAllRows(['plg_maker']); - $this->makerRepository = self::$container->get(MakerRepository::class); + $this->makerRepository = self::getContainer()->get(MakerRepository::class); } /** diff --git a/Tests/Web/Admin/ProductMakerTest.php b/Tests/Web/Admin/ProductMakerTest.php index 5827a8f..1131be6 100644 --- a/Tests/Web/Admin/ProductMakerTest.php +++ b/Tests/Web/Admin/ProductMakerTest.php @@ -44,7 +44,7 @@ protected function setUp() :void parent::setUp(); $this->deleteAllRows(['plg_maker']); - $this->productRepository = self::$container->get(ProductRepository::class); + $this->productRepository = self::getContainer()->get(ProductRepository::class); } /** diff --git a/Tests/Web/ProductDetailTest.php b/Tests/Web/ProductDetailTest.php index 9d85c7f..771811e 100644 --- a/Tests/Web/ProductDetailTest.php +++ b/Tests/Web/ProductDetailTest.php @@ -50,7 +50,7 @@ protected function setUp(): void $this->Maker = $this->createMaker(); $this->Product = $this->createProductMaker($this->Maker); - $this->productRepository = self::$container->get(ProductRepository::class); + $this->productRepository = self::getContainer()->get(ProductRepository::class); } /** @@ -145,7 +145,7 @@ protected function createProductMaker(Maker $Maker, $Product = null) $client->followRedirect(); - $this->productRepository = self::$container->get(ProductRepository::class); + $this->productRepository = self::getContainer()->get(ProductRepository::class); $Product = $this->productRepository->find($productId); } From 1339c04840e6798af19a8323463fa3ff2cb9f7ff Mon Sep 17 00:00:00 2001 From: Pham Thanh Thao Date: Fri, 23 Feb 2024 10:28:54 +0700 Subject: [PATCH 2/8] Change system configuration to compatible with 4.3 version --- .github/workflows/main.yml | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 3f3a130..a157f56 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -17,14 +17,13 @@ on: jobs: run-on-linux: name: Run on Linux - runs-on: ${{ matrix.operating-system }} + runs-on: ubuntu-22.04 strategy: fail-fast: false matrix: - operating-system: [ ubuntu-18.04 ] - php: [ '7.4', '8.0', '8.1' ] + eccube_version: [ '4.2', '4.3-symfony6' ] + php: [ '7.4', '8.0', '8.1', '8.2', '8.3'] db: [ 'mysql', 'mysql8', 'pgsql' ] - eccube_version: [ '4.2' ] plugin_code: [ 'Maker42' ] include: - db: mysql @@ -39,6 +38,15 @@ jobs: database_url: postgres://postgres:password@127.0.0.1:5432/eccube_db database_server_version: 14 database_charset: utf8 + exclude: + - eccube_version: 4.2 + php: 8.2 + - eccube_version: 4.2 + php: 8.3 + - eccube_version: 4.3-symfony6 + php: 7.4 + - eccube_version: 4.3-symfony6 + php: 8.0 services: mysql: image: mysql:5.7 @@ -72,7 +80,6 @@ jobs: - 1080:1080 - 1025:1025 steps: - - run: sudo apt-get purge -y hhvm - name: Checkout uses: actions/checkout@v2 @@ -143,7 +150,7 @@ jobs: working-directory: 'ec-cube' run: | bin/console cache:clear --no-warmup - bin/phpunit -c app/Plugin/${PLUGIN_CODE}/phpunit.xml.dist app/Plugin/${PLUGIN_CODE}/Tests + ./vendor/bin/phpunit -c app/Plugin/${PLUGIN_CODE}/phpunit.xml.dist app/Plugin/${PLUGIN_CODE}/Tests - name: Disable Plugin working-directory: 'ec-cube' From 8097351a6b5aa26e03778cf7d5844e492d10116b Mon Sep 17 00:00:00 2001 From: Pham Thanh Thao Date: Fri, 23 Feb 2024 10:29:37 +0700 Subject: [PATCH 3/8] Update version to 4.3.0 --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index f9a98f4..5ae0727 100644 --- a/composer.json +++ b/composer.json @@ -1,6 +1,6 @@ { "name": "ec-cube/maker42", - "version": "4.2.2", + "version": "4.3.0", "description": "メーカー管理プラグイン", "type": "eccube-plugin", "require": { From a1d409fd3d9a3e8a330e6812ed9ab947f8d74892 Mon Sep 17 00:00:00 2001 From: Pham Thanh Thao Date: Fri, 23 Feb 2024 12:24:32 +0700 Subject: [PATCH 4/8] Change the correct param to display the message --- Controller/MakerController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Controller/MakerController.php b/Controller/MakerController.php index 3d2c888..bc34813 100644 --- a/Controller/MakerController.php +++ b/Controller/MakerController.php @@ -145,7 +145,7 @@ public function delete(Request $request, Maker $Maker) } catch (\Exception $e) { log_info('メーカー削除エラー', ['Maker id' => $Maker->getId(), $e]); - $message = trans('admin.delete.failed.foreign_key', ['%name%' => $Maker->getName()]); + $message = trans('admin.common.delete_error_foreign_key', ['%name%' => $Maker->getName()]); $this->addError($message, 'admin'); } From 2438e8089e96b46ed9f6fdcd0bd9796bac0c62d2 Mon Sep 17 00:00:00 2001 From: Pham Thanh Thao Date: Fri, 23 Feb 2024 15:37:05 +0700 Subject: [PATCH 5/8] Update test cases based on feature logic --- Tests/Web/Admin/ProductMakerTest.php | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/Tests/Web/Admin/ProductMakerTest.php b/Tests/Web/Admin/ProductMakerTest.php index 1131be6..08ac088 100644 --- a/Tests/Web/Admin/ProductMakerTest.php +++ b/Tests/Web/Admin/ProductMakerTest.php @@ -16,6 +16,7 @@ use Faker\Generator; use Plugin\Maker42\Tests\Web\MakerWebCommon; use Symfony\Component\HttpKernel\Client; +use Symfony\Component\DomCrawler\Crawler; use Eccube\Repository\ProductRepository; /** @@ -142,7 +143,10 @@ public function testProductNewWithAddMakerInvalid() ); // Check message - $this->assertStringContainsString('有効な値ではありません。', $crawler->filter('.form-error-message')->html()); + $errorMessages = $crawler->filter('.form-error-message')->each(function (Crawler $node): string { + return $node->text(); + }); + $this->assertStringContainsString('選択した値は無効です。', implode("\n", $errorMessages)); // Check database $Product = $this->productRepository->findOneBy([], ['id' => 'DESC']); @@ -220,7 +224,10 @@ public function testProductNewWithAddMakerAndMakerUrlInValid() ); // Check message - $this->assertStringContainsString('有効なURLではありません。', $crawler->filter('.form-error-message')->html()); + $errorMessages = $crawler->filter('.form-error-message')->each(function (Crawler $node): string { + return $node->text(); + }); + $this->assertStringContainsString('有効なURLではありません。', implode("\n", $errorMessages)); // Check database $Product = $this->productRepository->findOneBy([], ['id' => 'DESC']); @@ -407,7 +414,10 @@ public function testProductEditWithAddMakerInvalid() ); // Check message - $this->assertStringContainsString('有効な値ではありません。', $crawler->filter('.form-error-message')->html()); + $errorMessages = $crawler->filter('.form-error-message')->each(function (Crawler $node): string { + return $node->text(); + }); + $this->assertStringContainsString('選択した値は無効です。', implode("\n", $errorMessages)); // Check database $Product = $this->productRepository->findOneBy([], ['id' => 'DESC']); @@ -520,7 +530,10 @@ public function testProductEditWithAddMakerAndMakerUrlInValid() ); // Check message - $this->assertStringContainsString('有効なURLではありません。', $crawler->filter('.form-error-message')->html()); + $errorMessages = $crawler->filter('.form-error-message')->each(function (Crawler $node): string { + return $node->text(); + }); + $this->assertStringContainsString('有効なURLではありません。', implode("\n", $errorMessages)); // Check database $Product = $this->productRepository->findOneBy([], ['id' => 'DESC']); From 904776e5df724037cf694cd4638a1067a7423149 Mon Sep 17 00:00:00 2001 From: Pham Thanh Thao Date: Mon, 26 Feb 2024 09:41:27 +0700 Subject: [PATCH 6/8] Set expected message based on eccube version --- Tests/Web/Admin/ProductMakerTest.php | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/Tests/Web/Admin/ProductMakerTest.php b/Tests/Web/Admin/ProductMakerTest.php index 08ac088..7877b7c 100644 --- a/Tests/Web/Admin/ProductMakerTest.php +++ b/Tests/Web/Admin/ProductMakerTest.php @@ -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; @@ -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']); @@ -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']); From abccfdf19170063c691a4a385920173aaa25ef49 Mon Sep 17 00:00:00 2001 From: Pham Thanh Thao Date: Tue, 12 Mar 2024 10:01:16 +0700 Subject: [PATCH 7/8] Update eccube_version --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index a157f56..44a51b2 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -21,7 +21,7 @@ jobs: strategy: fail-fast: false matrix: - eccube_version: [ '4.2', '4.3-symfony6' ] + eccube_version: [ '4.2', '4.3' ] php: [ '7.4', '8.0', '8.1', '8.2', '8.3'] db: [ 'mysql', 'mysql8', 'pgsql' ] plugin_code: [ 'Maker42' ] From 3d24050cb1aa92d23059000014a8b25527cd620f Mon Sep 17 00:00:00 2001 From: Pham Thanh Thao Date: Tue, 12 Mar 2024 14:37:04 +0700 Subject: [PATCH 8/8] Update eccube_version --- .github/workflows/main.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 44a51b2..e4c479e 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -43,9 +43,9 @@ jobs: php: 8.2 - eccube_version: 4.2 php: 8.3 - - eccube_version: 4.3-symfony6 + - eccube_version: 4.3 php: 7.4 - - eccube_version: 4.3-symfony6 + - eccube_version: 4.3 php: 8.0 services: mysql: