public function testSlugGeneration() { $category = new TestCategory(); $category->setName('Test category'); $this->assertAttributeEmpty('slug', $category, 'the slug is empty during creation'); $category->generateSlug(); $this->assertAttributeEquals('test-category', 'slug', $category, '::generateSlug() generates the slug from the name'); $this->assertEquals('test-category', $category->getSlug(), '::getSlug() gets the slug'); $category->setName('Renamed category'); $category->generateSlug(); $this->assertAttributeEquals('test-category', 'slug', $category, '::generateSlug() does not replace an existing slug'); $category->setSlug('custom-slug'); $this->assertAttributeEquals('custom-slug', 'slug', $category, '::setSlug() sets the slug'); $category->setSlug('Malformed slug...'); $this->assertAttributeEquals('malformed-slug', 'slug', $category, 'the slug is always formatted'); }