FieldPluginTest.php 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  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\FieldPlugin;
  12. class FieldPluginTest extends \PHPUnit_Framework_TestCase
  13. {
  14. public function testSetUp()
  15. {
  16. $field = $this->getMock('Symfony\Tests\Component\Form\FormInterface');
  17. $field->expects($this->any())
  18. ->method('getClientData')
  19. ->will($this->returnValue('bar'));
  20. $field->expects($this->any())
  21. ->method('hasParent')
  22. ->will($this->returnValue(false));
  23. $field->expects($this->any())
  24. ->method('getName')
  25. ->will($this->returnValue('The_Name'));
  26. $field->expects($this->any())
  27. ->method('getErrors')
  28. ->will($this->returnValue('someerrors'));
  29. $field->expects($this->any())
  30. ->method('isDisabled')
  31. ->will($this->returnValue(false));
  32. $field->expects($this->any())
  33. ->method('isRequired')
  34. ->will($this->returnValue(true));
  35. $renderer = $this->getMock('Symfony\Component\Form\Renderer\FormRendererInterface');
  36. $renderer->expects($this->at(0))
  37. ->method('setVar')
  38. ->with($this->equalTo('renderer'), $this->equalTo($renderer));
  39. $renderer->expects($this->at(1))
  40. ->method('setVar')
  41. ->with($this->equalTo('id'), $this->equalTo('The_Name'));
  42. $renderer->expects($this->at(2))
  43. ->method('setVar')
  44. ->with($this->equalTo('name'), $this->equalTo('The_Name'));
  45. $renderer->expects($this->at(3))
  46. ->method('setVar')
  47. ->with($this->equalTo('errors'), $this->equalTo('someerrors'));
  48. $renderer->expects($this->at(4))
  49. ->method('setVar')
  50. ->with($this->equalTo('value'), $this->equalTo('bar'));
  51. $renderer->expects($this->at(5))
  52. ->method('setVar')
  53. ->with($this->equalTo('disabled'), $this->equalTo(false));
  54. $renderer->expects($this->at(6))
  55. ->method('setVar')
  56. ->with($this->equalTo('required'), $this->equalTo(true));
  57. $renderer->expects($this->at(7))
  58. ->method('setVar')
  59. ->with($this->equalTo('class'), $this->equalTo(null));
  60. $renderer->expects($this->at(8))
  61. ->method('setVar')
  62. ->with($this->equalTo('max_length'), $this->equalTo(null));
  63. $renderer->expects($this->at(9))
  64. ->method('setVar')
  65. ->with($this->equalTo('size'), $this->equalTo(null));
  66. $renderer->expects($this->at(10))
  67. ->method('setVar')
  68. ->with($this->equalTo('label'), $this->equalTo('The name'));
  69. $plugin = new FieldPlugin();
  70. $plugin->setUp($field, $renderer);
  71. }
  72. }