ConfigureQueryEventTest.php 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  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\Datagrid\ProxyQueryInterface;
  13. use Sonata\AdminBundle\Event\ConfigureQueryEvent;
  14. class ConfigureQueryEventTest extends \PHPUnit_Framework_TestCase
  15. {
  16. /**
  17. * @var ConfigureQueryEvent
  18. */
  19. private $event;
  20. /**
  21. * @var AdminInterface
  22. */
  23. private $admin;
  24. /**
  25. * @var ProxyQueryInterface
  26. */
  27. private $proxyQuery;
  28. protected function setUp()
  29. {
  30. $this->admin = $this->getMock('Sonata\AdminBundle\Admin\AdminInterface');
  31. $this->proxyQuery = $this->getMock('Sonata\AdminBundle\Datagrid\ProxyQueryInterface');
  32. $this->event = new ConfigureQueryEvent($this->admin, $this->proxyQuery, 'Foo');
  33. }
  34. public function testGetContext()
  35. {
  36. $this->assertEquals('Foo', $this->event->getContext());
  37. }
  38. public function testGetAdmin()
  39. {
  40. $result = $this->event->getAdmin();
  41. $this->assertInstanceOf('Sonata\AdminBundle\Admin\AdminInterface', $result);
  42. $this->assertEquals($this->admin, $result);
  43. }
  44. public function testGetProxyQuery()
  45. {
  46. $result = $this->event->getProxyQuery();
  47. $this->assertInstanceOf('Sonata\AdminBundle\Datagrid\ProxyQueryInterface', $result);
  48. $this->assertEquals($this->proxyQuery, $result);
  49. }
  50. }