Skip to content
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

重複して在庫が登録されてしまう問題に対処 #6029

Merged
merged 14 commits into from
Oct 2, 2023
32 changes: 32 additions & 0 deletions codeception/_support/Page/Admin/ProductClassEditPage.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,22 @@ public function 入力_規格1($value)
return $this;
}

public function 無効_規格($rowNum)
{
--$rowNum;
$this->tester->uncheckOption(['id' => "product_class_matrix_product_classes_${rowNum}_checked"]);

return $this;
}

public function 有効_規格($rowNum)
{
--$rowNum;
$this->tester->checkOption(['id' => "product_class_matrix_product_classes_${rowNum}_checked"]);

return $this;
}

public function 入力_在庫数無制限($rowNum)
{
--$rowNum;
Expand All @@ -59,6 +75,14 @@ public function 入力_在庫数無制限($rowNum)
return $this;
}

public function 無効_在庫数無制限($rowNum)
{
--$rowNum;
$this->tester->uncheckOption(['id' => "product_class_matrix_product_classes_${rowNum}_stock_unlimited"]);

return $this;
}

public function 入力_販売価格($rowNum, $value)
{
--$rowNum;
Expand All @@ -67,6 +91,14 @@ public function 入力_販売価格($rowNum, $value)
return $this;
}

public function 入力_個数($rowNum, $value)
{
--$rowNum;
$this->tester->fillField(['id' => "product_class_matrix_product_classes_${rowNum}_stock"], $value);

return $this;
}

public function 選択($rowNum)
{
--$rowNum;
Expand Down
75 changes: 71 additions & 4 deletions codeception/acceptance/EA03ProductCest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
*/

use Codeception\Util\Fixtures;
use Doctrine\DBAL\Connection;
use Doctrine\ORM\EntityManager;
use Page\Admin\CategoryCsvUploadPage;
use Page\Admin\CategoryManagePage;
use Page\Admin\ClassCategoryManagePage;
Expand All @@ -31,6 +33,12 @@
*/
class EA03ProductCest
{
/** @var EntityManager */
private EntityManager $em;

/** @var Connection */
private $conn;
kiy0taka marked this conversation as resolved.
Show resolved Hide resolved

const ページタイトル = '#main .page-header';
const ページタイトルStyleGuide = '.c-pageTitle';

Expand All @@ -39,6 +47,8 @@ public function _before(AcceptanceTester $I)
// すべてのテストケース実施前にログインしておく
// ログイン後は管理アプリのトップページに遷移している
$I->loginAsAdmin();

$this->em = Fixtures::get('entityManager');
}

public function _after(AcceptanceTester $I)
Expand Down Expand Up @@ -264,9 +274,9 @@ public function product_一覧からの規格編集規格なし_(AcceptanceTeste
$I->seeElement(ProductClassEditPage::$初期化ボタン);
}

public function product_一覧からの規格編集規格あり2(AcceptanceTester $I)
public function product_一覧からの規格編集_規格あり_規格登録(AcceptanceTester $I)
{
$I->wantTo('EA0310-UC02-T02 一覧からの規格編集 規格あり2');
$I->wantTo('EA0310-UC02-T02 一覧からの規格編集 規格あり 規格登録');

$findProducts = Fixtures::get('findProducts');
$Products = array_filter($findProducts(), function ($Product) {
Expand Down Expand Up @@ -357,9 +367,9 @@ public function product_商品の廃止(AcceptanceTester $I)
/**
* ATTENTION 削除すると後続の規格編集関連のテストが失敗するため、最後に実行する
*/
public function product_一覧からの規格編集規格あり1(AcceptanceTester $I)
public function product_一覧からの規格編集規格あり(AcceptanceTester $I)
{
$I->wantTo('EA0310-UC02-T01 一覧からの規格編集 規格あり1');
$I->wantTo('EA0310-UC02-T01 一覧からの規格編集 規格あり');

$findProducts = Fixtures::get('findProducts');
$Products = array_filter($findProducts(), function ($Product) {
Expand Down Expand Up @@ -1006,4 +1016,61 @@ public function product_詳細検索_タグ(AcceptanceTester $I)

$I->see('検索結果:1件が該当しました', ProductManagePage::$検索結果_メッセージ);
}

/**
* @see https://github.com/EC-CUBE/ec-cube/pull/6029
*
* @throws \Doctrine\ORM\OptimisticLockException
* @throws \Doctrine\ORM\TransactionRequiredException
* @throws \Doctrine\ORM\Exception\ORMException
*/
public function product_一覧からの規格編集_規格あり_重複在庫の修正(AcceptanceTester $I)
{
$I->wantTo('EA0310-UC02-T03 一覧からの規格編集 規格あり 重複在庫の修正');

$findProducts = Fixtures::get('findProducts');
$Products = array_filter($findProducts(), function ($Product) {
return $Product->hasProductClass();
});
$Product = array_pop($Products);

// 先頭のproductClass要素に対してStockを登録する
ProductManagePage::go($I)
->検索($Product->getName())
->検索結果_選択(1);

ProductEditPage::at($I)
->規格管理();

ProductClassEditPage::at($I)
->入力_在庫数無制限(1)
->登録();

ProductClassEditPage::at($I)
->無効_在庫数無制限(1)
->入力_個数(1, 100)
->登録();

ProductClassEditPage::at($I)
->無効_規格(1)
->登録();

ProductClassEditPage::at($I)
->有効_規格(1)
->入力_個数(1, 10)
->入力_販売価格(1, 5000)
->登録();

// テストデータ投入時に、上記の規格在庫操作が反映されないためリフレッシュする。
$ProductClasses = $Product->getProductClasses();
$this->em->refresh($Product);
$this->em->refresh($ProductClasses[0]);
$ProductClass = $ProductClasses[0];

$stock = $ProductClass->getStock();

// 個数のズレがないか検査
$I->assertEquals('10', $stock, 'Stockが一致');
kiy0taka marked this conversation as resolved.
Show resolved Hide resolved
$I->see('保存しました', ProductClassEditPage::$登録完了メッセージ);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,7 @@ protected function saveProductClasses(Product $Product, $ProductClasses = [])
'create_date',
'update_date',
'Creator',
'ProductStock',
]);
$pc = $ExistsProductClass;
}
Expand Down
Loading