/** * Returns the field type under test. * * @return \Netgen\TagsBundle\Core\FieldType\Tags\Type */ protected function createFieldTypeUnderTest() { $this->tagsService = $this->getMock('Netgen\\TagsBundle\\API\\Repository\\TagsService'); $this->tagsService->expects($this->any())->method('loadTag')->will($this->returnCallback(array($this, 'getTagsServiceLoadTagValues'))); $tagsType = new TagsType($this->tagsService); $tagsType->setEditViews(array('default' => array('identifier' => 'Default'), 'select' => array('identifier' => 'Select'))); return $tagsType; }
/** * @covers \Netgen\TagsBundle\Core\Pagination\Pagerfanta\RelatedContentAdapter::testGetSlice */ public function testGetSlice() { $offset = 2; $limit = 2; $nbResults = 5; $tag = new Tag(array('id' => 42)); $relatedContent = array(new Content(array('internalFields' => array())), new Content(array('internalFields' => array()))); $this->tagsService->expects($this->once())->method('getRelatedContentCount')->with($this->equalTo($tag))->will($this->returnValue($nbResults)); $this->tagsService->expects($this->once())->method('getRelatedContent')->with($this->equalTo($tag), $this->equalTo($offset), $this->equalTo($limit))->will($this->returnValue($relatedContent)); $adapter = $this->getAdapter($tag, $this->tagsService); $this->assertSame($relatedContent, $adapter->getSlice($offset, $limit)); $this->assertSame($nbResults, $adapter->getNbResults()); }
/** * @covers \Netgen\TagsBundle\Core\SignalSlot\TagsService::newTagUpdateStruct */ public function testNewTagUpdateStruct() { $this->tagsService->expects($this->once())->method('newTagUpdateStruct')->will($this->returnValue(new TagUpdateStruct())); $signalSlotService = $this->getSignalSlotService(); $tagUpdateStruct = $signalSlotService->newTagUpdateStruct(); $this->assertInstanceOf('Netgen\\TagsBundle\\API\\Repository\\Values\\Tags\\TagUpdateStruct', $tagUpdateStruct); }
/** * @covers \Netgen\TagsBundle\Core\Pagination\Pagerfanta\RelatedContentAdapter::__construct * @covers \Netgen\TagsBundle\Core\Pagination\Pagerfanta\RelatedContentAdapter::setTag * @covers \Netgen\TagsBundle\Core\Pagination\Pagerfanta\RelatedContentAdapter::getSlice */ public function testGetSliceWithoutTag() { $this->tagsService->expects($this->never())->method('getRelatedContentCount'); $this->tagsService->expects($this->never())->method('getRelatedContent'); $adapter = new RelatedContentAdapter($this->tagsService); $this->assertSame(array(), $adapter->getSlice(2, 2)); }
/** * @covers \Netgen\TagsBundle\Core\SignalSlot\TagsService::sudo */ public function testSudo() { $callback = function () { }; $this->tagsService->expects($this->once())->method('sudo')->will($this->returnValue('some_value')); $signalSlotService = $this->getSignalSlotService(); $value = $signalSlotService->sudo($callback); $this->assertEquals('some_value', $value); }
/** * Returns the field type under test. * * @return \Netgen\TagsBundle\Core\FieldType\Tags\Type */ protected function createFieldTypeUnderTest() { $this->tagsService = $this->getMock('Netgen\\TagsBundle\\API\\Repository\\TagsService'); $this->tagsService->expects($this->any())->method('loadTag')->will($this->returnCallback(array($this, 'getTagsServiceLoadTagValues'))); return new TagsType($this->tagsService); }