Beispiel #1
0
 /**
  * @covers \Netgen\TagsBundle\Core\Search\Solr\Query\Content\CriterionVisitor\Tags\TagKeyword::visit
  * @covers \Netgen\TagsBundle\Core\Search\Solr\Query\Content\CriterionVisitor\Tags::getTargetFieldNames
  */
 public function testVisitWithoutTarget()
 {
     $criterion = new Criterion\TagKeyword(Operator::IN, array('tag1', 'tag2'));
     $this->contentTypeHandler->expects($this->once())->method('getSearchableFieldMap')->will($this->returnValue(array('news' => array('tags_field' => array('field_type_identifier' => 'eztags')), 'article' => array('tags_field2' => array('field_type_identifier' => 'eztags')))));
     $this->fieldNameResolver->expects($this->at(0))->method('getFieldNames')->with($this->equalTo($criterion), $this->equalTo('tags_field'), 'eztags', 'tag_keywords')->will($this->returnValue(array('news_tags_field_s')));
     $this->fieldNameResolver->expects($this->at(1))->method('getFieldNames')->with($this->equalTo($criterion), $this->equalTo('tags_field2'), 'eztags', 'tag_keywords')->will($this->returnValue(array('article_tags_field2_s')));
     $this->assertEquals('(news_tags_field_s:"tag1" OR article_tags_field2_s:"tag1" OR news_tags_field_s:"tag2" OR article_tags_field2_s:"tag2")', $this->visitor->visit($criterion));
 }
 /**
  * @dataProvider providerForTestValidateError
  *
  * @param \eZ\Publish\API\Repository\Values\User\Limitation\ParentContentTypeLimitation $limitation
  * @param int $errorCount
  */
 public function testValidateError(ParentContentTypeLimitation $limitation, $errorCount)
 {
     if (!empty($limitation->limitationValues)) {
         $this->getPersistenceMock()->expects($this->any())->method("contentTypeHandler")->will($this->returnValue($this->contentTypeHandlerMock));
         foreach ($limitation->limitationValues as $key => $value) {
             $this->contentTypeHandlerMock->expects($this->at($key))->method("load")->with($value)->will($this->throwException(new NotFoundException('location', $value)));
         }
     } else {
         $this->getPersistenceMock()->expects($this->never())->method($this->anything());
     }
     // Need to create inline instead of depending on testConstruct() to get correct mock instance
     $limitationType = $this->testConstruct();
     $validationErrors = $limitationType->validate($limitation);
     self::assertCount($errorCount, $validationErrors);
 }