ActiveVoterTest.php 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. <?php
  2. /*
  3. * This file is part of the Sonata Project 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\Menu\Matcher\Voter;
  11. use Knp\Menu\ItemInterface;
  12. use Sonata\AdminBundle\Menu\Matcher\Voter\ActiveVoter;
  13. class ActiveVoterTest extends AbstractVoterTest
  14. {
  15. /**
  16. * {@inheritdoc}
  17. */
  18. public function createVoter($dataVoter)
  19. {
  20. return new ActiveVoter();
  21. }
  22. /**
  23. * {@inheritdoc}
  24. */
  25. public function provideData()
  26. {
  27. return array(
  28. 'active' => array(true, null, true),
  29. 'no active' => array(false, null, false),
  30. 'null' => array(null, null, null),
  31. );
  32. }
  33. /**
  34. * @param mixed $data
  35. *
  36. * @return ItemInterface
  37. */
  38. protected function createItem($data)
  39. {
  40. $item = $this->getMock('Knp\Menu\ItemInterface');
  41. $item->expects($this->any())
  42. ->method('getExtra')
  43. ->with('active')
  44. ->will($this->returnValue($data))
  45. ;
  46. return $item;
  47. }
  48. }