AbstractVoterTest.php 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  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 Knp\Menu\Matcher\Voter\VoterInterface;
  13. abstract class AbstractVoterTest extends \PHPUnit_Framework_TestCase
  14. {
  15. /**
  16. * @return array
  17. */
  18. abstract public function provideData();
  19. /**
  20. * @param mixed $itemData
  21. * @param mixed $voterData
  22. * @param mixed $route
  23. * @param bool|null $expected
  24. *
  25. * @dataProvider provideData
  26. */
  27. public function testMatching($itemData, $voterData, $route, $expected)
  28. {
  29. $item = $this->createItem($itemData);
  30. $voter = $this->createVoter($voterData, $route);
  31. $this->assertSame($expected, $voter->matchItem($item));
  32. }
  33. /**
  34. * @param mixed $dataVoter
  35. * @param mixed $route
  36. *
  37. * @return VoterInterface
  38. */
  39. abstract protected function createVoter($dataVoter, $route);
  40. /**
  41. * @param mixed $data
  42. *
  43. * @return ItemInterface
  44. */
  45. abstract protected function createItem($data);
  46. }