CheckedPluginTest.php 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  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\CheckedPlugin;
  12. class CheckedPluginTest extends \PHPUnit_Framework_TestCase
  13. {
  14. public function testSetUpTrue()
  15. {
  16. $field = $this->getMock('Symfony\Tests\Component\Form\FormInterface');
  17. $field->expects($this->once())
  18. ->method('getData')
  19. ->will($this->returnValue(1));
  20. $renderer = $this->getMock('Symfony\Component\Form\Renderer\FormRendererInterface');
  21. $renderer->expects($this->once())
  22. ->method('setVar')
  23. ->with($this->equalTo('checked'), $this->equalTo(true));
  24. $plugin = new CheckedPlugin();
  25. $plugin->setUp($field, $renderer);
  26. }
  27. public function testSetUpFalse()
  28. {
  29. $field = $this->getMock('Symfony\Tests\Component\Form\FormInterface');
  30. $field->expects($this->once())
  31. ->method('getData')
  32. ->will($this->returnValue(0));
  33. $renderer = $this->getMock('Symfony\Component\Form\Renderer\FormRendererInterface');
  34. $renderer->expects($this->once())
  35. ->method('setVar')
  36. ->with($this->equalTo('checked'), $this->equalTo(false));
  37. $plugin = new CheckedPlugin();
  38. $plugin->setUp($field, $renderer);
  39. }
  40. }