Пример #1
0
 /**
  * @dataProvider getIdsLists
  *
  * @param array $ids
  */
 public function testAddLabels(array $ids)
 {
     $labels = new ArrayCollection();
     $this->entity->expects($this->atLeastOnce())->method('getLabels')->will($this->returnValue($labels));
     if ($ids) {
         foreach ($ids as $id) {
             $label = $this->getMock('\\AnimeDb\\Bundle\\CatalogBundle\\Entity\\Label');
             $label->expects($this->atLeastOnce())->method('getId')->will($this->returnValue($id));
             $labels->add($label);
         }
         $that = $this;
         $this->add(function (\PHPUnit_Framework_MockObject_MockObject $query) use($that, $ids) {
             $query->expects($that->once())->method('innerJoin')->with('i.labels', 'l')->will($this->returnSelf());
             $query->expects($that->once())->method('andWhere')->with('l.id IN (' . implode(',', $ids) . ')')->will($this->returnSelf());
         });
     }
     $this->builder->addLabels($this->entity);
 }
Пример #2
0
 /**
  * @param Search $entity
  *
  * @return Builder
  */
 public function addStudio(Search $entity)
 {
     if ($entity->getStudio() instanceof Studio) {
         $this->add(function (QueryBuilder $query) use($entity) {
             $query->andWhere('i.studio = :studio')->setParameter('studio', $entity->getStudio()->getId());
         });
     }
     return $this;
 }