Set Creator
public setCreator ( Eccube\Entity\Member $creator ) : |
||
$creator | Eccube\Entity\Member | |
return |
/** * EC-CUBE本体のエンティティとjoinし, 検索するテスト */ public function testWhereWithJoinEntity() { // `新商品`のTagが登録されたProductを生成 $Tag = $this->app['eccube.repository.master.tag']->find(1); $Member = $this->app['eccube.repository.member']->find(2); $Product = $this->app['eccube.repository.product']->find(reset($this->expectedIds)); $ProductTag = new ProductTag(); $ProductTag->setCreator($Member); $ProductTag->setProduct($Product); $ProductTag->setTag($Tag); $Product->addProductTag($ProductTag); $this->app['orm.em']->persist($ProductTag); $this->app['orm.em']->flush(array($Product, $ProductTag)); $qb = $this->app['eccube.repository.product']->getQueryBuilderBySearchData(array()); // 商品タグとjoinして検索 $qb->innerJoin('p.ProductTag', 'ptag')->innerJoin('ptag.Tag', 'tag')->andWhere($qb->expr()->in('ptag.Tag', ':Tag'))->setParameter(':Tag', $Tag); $expectedIds = array(); $results = $qb->getQuery()->getResult(); foreach ($results as $result) { $expectedIds[] = $result->getId(); } $pagination = $this->app['paginator']()->paginate($qb, 1, 30, array('wrap-queries' => true)); $actualIds = array(); foreach ($pagination as $result) { $actualIds[] = $result->getId(); } $this->expected = $expectedIds; $this->actual = $actualIds; // tagが登録されたProductは1件のみ. $this->assertTrue(count($this->actual) === 1); $this->verify(); }