123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869 |
- <?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>
- * @package Gedmo.Sluggable
- * @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,
- );
- }
- }
|