ConfigureEventTest.php 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  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\Mapper\BaseMapper;
  13. use Sonata\AdminBundle\Event\ConfigureEvent;
  14. class ConfigureEventTest extends \PHPUnit_Framework_TestCase
  15. {
  16. /**
  17. * @var ConfigureEvent
  18. */
  19. private $event;
  20. /**
  21. * @var AdminInterface
  22. */
  23. private $admin;
  24. /**
  25. * @var BaseMapper
  26. */
  27. private $mapper;
  28. protected function setUp()
  29. {
  30. $this->admin = $this->getMock('Sonata\AdminBundle\Admin\AdminInterface');
  31. $this->mapper = $this->getMockBuilder('Sonata\AdminBundle\Mapper\BaseMapper')
  32. ->disableOriginalConstructor()
  33. ->getMock();
  34. $this->event = new ConfigureEvent($this->admin, $this->mapper, 'Foo');
  35. }
  36. public function testGetType()
  37. {
  38. $this->assertEquals('Foo', $this->event->getType());
  39. }
  40. public function testGetAdmin()
  41. {
  42. $result = $this->event->getAdmin();
  43. $this->assertInstanceOf('Sonata\AdminBundle\Admin\AdminInterface', $result);
  44. $this->assertEquals($this->admin, $result);
  45. }
  46. public function testGetMapper()
  47. {
  48. $result = $this->event->getMapper();
  49. $this->assertInstanceOf('Sonata\AdminBundle\Mapper\BaseMapper', $result);
  50. $this->assertEquals($this->mapper, $result);
  51. }
  52. }