12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667 |
- <?php
- namespace Gedmo\Sluggable;
- use Doctrine\Common\EventManager;
- use Tool\BaseTestCaseORM;
- use Sluggable\Fixture\Identifier;
- /**
- * These are tests for Sluggable behavior
- *
- * @author Gediminas Morkevicius <gediminas.morkevicius@gmail.com>
- * @link http://www.gediminasm.org
- * @license MIT License (http://www.opensource.org/licenses/mit-license.php)
- */
- class SluggableIdentifierTest extends BaseTestCaseORM
- {
- const TARGET = 'Sluggable\\Fixture\\Identifier';
- protected function setUp()
- {
- parent::setUp();
- $evm = new EventManager;
- $evm->addEventSubscriber(new SluggableListener);
- $this->getMockSqliteEntityManager($evm);
- }
- /**
- * @test
- */
- function shouldBePossibleToSlugIdentifiers()
- {
- $sport = new Identifier;
- $sport->setTitle('Sport');
- $this->em->persist($sport);
- $this->em->flush();
- $this->assertEquals('sport', $sport->getId());
- }
- /**
- * @test
- */
- function shouldPersistMultipleNonConflictingIdentifierSlugs()
- {
- $sport = new Identifier;
- $sport->setTitle('Sport');
- $this->em->persist($sport);
- $sport2 = new Identifier;
- $sport2->setTitle('Sport');
- $this->em->persist($sport2);
- $this->em->flush();
- $this->assertEquals('sport', $sport->getId());
- $this->assertEquals('sport_1', $sport2->getId());
- }
- protected function getUsedEntityFixtures()
- {
- return array(
- self::TARGET,
- );
- }
- }
|