public function testName() { $withoutName = new Tag(); $this->assertSame([], $withoutName->getName()); $withName = new Tag(['fr' => 'test name']); $this->assertSame(['fr' => 'test name'], $withName->getName()); }
public function testCanSaveVariantsInDatabase() { $variants = ['test tags', 'Test tag']; $tag = new Tag(['fr' => 'test tag']); $tag->setVariants($variants); $this->getEntityManager()->persist($tag); $this->getEntityManager()->flush(); // Test we can reload $this->getEntityManager()->clear(); $tagRepository = $this->getEntityManager()->getRepository(Tag::class); $reloadedTag = $tagRepository->findOneById($tag->getId()); $reloadedVariants = $reloadedTag->getVariants(); $this->assertSame($variants, $reloadedVariants); }
public function removeTag(Tag $t) { if (!$this->getId()) { return; } if (!$t->getId()) { return; } /* @var $dt_t Table */ $dt_t = $this->getServiceLocator()->get('Table.Application.Model.DokumentHasTag'); /* @var $dt DokumentHasTag */ $dt = $dt_t->findOne(['dokumente_id' => $this->getId(), 'tags_id' => $t->getId()]); if (!$dt) { return; } $dt->delete(); }