NoInterfaceTest.php 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. <?php
  2. namespace Gedmo\Timestampable;
  3. use Doctrine\Common\EventManager;
  4. use Tool\BaseTestCaseORM;
  5. use Doctrine\Common\Util\Debug,
  6. Timestampable\Fixture\WithoutInterface;
  7. /**
  8. * These are tests for Timestampable behavior
  9. *
  10. * @author Gediminas Morkevicius <gediminas.morkevicius@gmail.com>
  11. * @link http://www.gediminasm.org
  12. * @license MIT License (http://www.opensource.org/licenses/mit-license.php)
  13. */
  14. class NoInterfaceTest extends BaseTestCaseORM
  15. {
  16. const FIXTURE = "Timestampable\\Fixture\\WithoutInterface";
  17. protected function setUp()
  18. {
  19. parent::setUp();
  20. $evm = new EventManager;
  21. $evm->addEventSubscriber(new TimestampableListener);
  22. $this->getMockSqliteEntityManager($evm);
  23. }
  24. public function testTimestampableNoInterface()
  25. {
  26. $test = new WithoutInterface();
  27. $test->setTitle('Test');
  28. $date = new \DateTime('now');
  29. $this->em->persist($test);
  30. $this->em->flush();
  31. $this->em->clear();
  32. $test = $this->em->getRepository(self::FIXTURE)->findOneByTitle('Test');
  33. $this->assertEquals(
  34. $date->format('Y-m-d 00:00:00'),
  35. $test->getCreated()->format('Y-m-d H:i:s')
  36. );
  37. $this->assertEquals(
  38. $date->format('Y-m-d H:i'),
  39. $test->getUpdated()->format('Y-m-d H:i')
  40. );
  41. }
  42. protected function getUsedEntityFixtures()
  43. {
  44. return array(
  45. self::FIXTURE,
  46. );
  47. }
  48. }