/** * @test */ public function shouldAllowForcingEmptySlugAndRegenerateIfNullIssue807() { $article = $this->em->find(self::ARTICLE, $this->articleId); $article->setSlug(''); $this->em->persist($article); $this->em->flush(); $this->assertSame('', $article->getSlug()); $article->setSlug(null); $this->em->persist($article); $this->em->flush(); $this->assertSame('the-title-my-code', $article->getSlug()); $same = new Article(); $same->setTitle('any'); $same->setCode('any'); $same->setSlug('the-title-my-code'); $this->em->persist($same); $this->em->flush(); $this->assertSame('the-title-my-code-1', $same->getSlug()); }
/** * @test */ function shouldBeAbleToForceTheSlug() { $article = $this->em->find(self::ARTICLE, $this->articleId); $article->setSlug('my forced slug'); $this->em->persist($article); $new = new Article(); $new->setTitle('hey'); $new->setCode('cc'); $new->setSlug('forced'); $this->em->persist($new); $this->em->flush(); $this->assertSame('my-forced-slug', $article->getSlug()); $this->assertSame('forced', $new->getSlug()); }