AbstractVoterTest.php 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  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 $dataVoter
  21. *
  22. * @return VoterInterface
  23. */
  24. abstract protected function createVoter($dataVoter);
  25. /**
  26. * @param mixed $data
  27. *
  28. * @return ItemInterface
  29. */
  30. abstract protected function createItem($data);
  31. /**
  32. * @param mixed $itemData
  33. * @param mixed $voterData
  34. * @param bool|null $expected
  35. *
  36. * @dataProvider provideData
  37. */
  38. public function testMatching($itemData, $voterData, $expected)
  39. {
  40. $item = $this->createItem($itemData);
  41. $voter = $this->createVoter($voterData);
  42. $this->assertSame($expected, $voter->matchItem($item));
  43. }
  44. }