public function testSlugRegexp() { Table13Query::create()->deleteAll(); $con = Propel::getConnection(Table13Peer::DATABASE_NAME); for ($i = 0; $i < 3; $i++) { $t = new Table13(); $t->setTitle('Hello, World'); $t->save($con); } $this->assertEquals('hello-world-2', $t->getSlug()); $t = new Table13(); $t->setTitle('World'); $t->save($con); $this->assertEquals('world', $t->getSlug()); $t = new Table13(); $t->setTitle('World'); $t->save($con); $this->assertEquals('world-1', $t->getSlug()); $t = new Table13(); $t->setTitle('Hello, World'); $t->save($con); $this->assertEquals('hello-world-3', $t->getSlug()); $t = new Table13(); $t->setTitle('World'); $t->save($con); $this->assertEquals('world-2', $t->getSlug()); }
public function testObjectSlugAutoUpdate() { Table13Query::create()->deleteAll(); $t = new Table13(); $t->setTitle('Hello, World'); $t->save(); $this->assertEquals('hello-world', $t->getSlug(), 'preSave() creates a slug for new objects'); $t->setTitle('Hello, My World'); $t->save(); $this->assertEquals('hello-my-world', $t->getSlug(), 'preSave() autoupdates slug on object change'); $t->setTitle('Hello, My Whole New World'); $t->setSlug('hello-bar'); $t->save(); $this->assertEquals('hello-bar', $t->getSlug(), 'preSave() does not autoupdate slug when it was set by the user'); }