ChoicePluginTest.php 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. <?php
  2. /*
  3. * This file is part of the Symfony package.
  4. *
  5. * (c) Fabien Potencier <fabien.potencier@symfony-project.com>
  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 Symfony\Tests\Component\Form\Renderer\Plugin;
  11. use Symfony\Component\Form\Renderer\Plugin\ChoicePlugin;
  12. class ChoicePluginTest extends \PHPUnit_Framework_TestCase
  13. {
  14. public function testSetUp()
  15. {
  16. $choice = $this->getMock('Symfony\Component\Form\ChoiceList\ChoiceListInterface');
  17. $choice->expects($this->any())
  18. ->method('getOtherChoices')
  19. ->will($this->returnValue('somechoices'));
  20. $choice->expects($this->any())
  21. ->method('getPreferredChoices')
  22. ->will($this->returnValue('somethingelse'));
  23. $field = $this->getMock('Symfony\Tests\Component\Form\FormInterface');
  24. $renderer = $this->getMock('Symfony\Component\Form\Renderer\FormRendererInterface');
  25. $renderer->expects($this->at(0))
  26. ->method('setVar')
  27. ->with($this->equalTo('choices'), $this->equalTo('somechoices'));
  28. $renderer->expects($this->at(1))
  29. ->method('setVar')
  30. ->with($this->equalTo('preferred_choices'), $this->equalTo('somethingelse'));
  31. $renderer->expects($this->at(2))
  32. ->method('setVar')
  33. ->with($this->equalTo('separator'), $this->equalTo('-------------------'));
  34. $renderer->expects($this->at(3))
  35. ->method('setVar')
  36. ->with($this->equalTo('choice_list'), $this->equalTo($choice));
  37. $renderer->expects($this->at(4))
  38. ->method('setVar')
  39. ->with($this->equalTo('empty_value'), $this->equalTo(''));
  40. $plugin = new ChoicePlugin($choice);
  41. $plugin->setUp($field, $renderer);
  42. }
  43. }