Skip to content

Commit

Permalink
ユニットテスト修正
Browse files Browse the repository at this point in the history
  • Loading branch information
h.matsuo committed Nov 26, 2021
1 parent 0f67030 commit ebc8a8b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,12 @@ protected function createFavorites($Customer)
*/
protected function setProductTags(Product $Product, array $tagIds)
{
$ProductTags = $Product->getProductTag();
foreach ($ProductTags as $ProductTag) {
$Product->removeProductTag($ProductTag);
$this->entityManager->remove($ProductTag);
}

$Tags = $this->tagRepository->findBy(['id' => $tagIds]);
foreach ($Tags as $Tag) {
$ProductTag = new ProductTag();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -400,8 +400,9 @@ public function testTagSearch()
// * 商品B に タグ 2, 2 を設定
$Products = $this->productRepository->findAll();
$Products[1]->setName('りんご');
$this->setProductTags($Products[1], [1]);
$this->setProductTags($Products[2], [1, 2]);
$this->setProductTags($Products[0], [1]);
$this->setProductTags($Products[1], [1, 2]);
$this->setProductTags($Products[2], []);
$this->entityManager->flush();

// タグ 1 で検索
Expand Down

0 comments on commit ebc8a8b

Please sign in to comment.