PersistenceEventTest.php 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. <?php
  2. /*
  3. * This file is part of the Sonata package.
  4. *
  5. * (c) Thomas Rabaix <thomas.rabaix@sonata-project.org>
  6. *
  7. * For the full copyright and license information, please view the LICENSE
  8. * file that was distributed with this source code.
  9. */
  10. namespace Sonata\AdminBundle\Tests\Event;
  11. use Sonata\AdminBundle\Admin\AdminInterface;
  12. use Sonata\AdminBundle\Event\PersistenceEvent;
  13. class PersistenceEventTest extends \PHPUnit_Framework_TestCase
  14. {
  15. /**
  16. * @var PersistenceEvent
  17. */
  18. private $event;
  19. /**
  20. * @var AdminInterface
  21. */
  22. private $admin;
  23. /**
  24. * @var mixed
  25. */
  26. private $object;
  27. protected function setUp()
  28. {
  29. $this->admin = $this->getMock('Sonata\AdminBundle\Admin\AdminInterface');
  30. $this->object = new \stdClass();
  31. $this->event = new PersistenceEvent($this->admin, $this->object, 'Foo');
  32. }
  33. public function testGetType()
  34. {
  35. $this->assertEquals('Foo', $this->event->getType());
  36. }
  37. public function testGetAdmin()
  38. {
  39. $result = $this->event->getAdmin();
  40. $this->assertInstanceOf('Sonata\AdminBundle\Admin\AdminInterface', $result);
  41. $this->assertEquals($this->admin, $result);
  42. }
  43. public function testGetObject()
  44. {
  45. $this->assertEquals($this->object, $this->event->getObject());
  46. }
  47. }