/** * Create a Collection of Tags from a simple array data * * @param \Domain\Core\Interfaces\TagInterfaceEntity $tagEntity * @param array $tags * * @return \Domain\Core\Tag */ public static function buildTagCollectionFromArray(TagInterfaceEntity $tagEntity, $tags) { $tagCollection = null; if (!empty($tags)) { $tagCollection = new TagCollection(); foreach ($tags as $tag) { $tagItem = TagFactory::buildTag($tagEntity, $tag); try { $tagCollection->add($tagItem); } catch (\Exception $e) { /** * You can choose what to do in this case. */ } } } return $tagCollection; }
/** * @test */ public function testPersist() { $this->expectOutputString('test tag'); $tag = new Tag(); $tag->persist(TagFactory::buildTag($tag, 'test tag')); }
/** * @test */ public function testBuildTagWithId() { $item = TagFactory::buildTag($this->dummyTagEntity, 'tag test', '1'); $this->assertEquals('1', $item->getId(), 'The value of the is not correct'); }