ButtonBuilderTest.php 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. <?php
  2. /*
  3. * This file is part of the Symfony package.
  4. *
  5. * (c) Fabien Potencier <fabien@symfony.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\Component\Form\Tests;
  11. use PHPUnit\Framework\TestCase;
  12. use Symfony\Component\Form\ButtonBuilder;
  13. /**
  14. * @author Alexander Cheprasov <cheprasov.84@ya.ru>
  15. */
  16. class ButtonBuilderTest extends TestCase
  17. {
  18. public function getValidNames()
  19. {
  20. return array(
  21. array('reset'),
  22. array('submit'),
  23. array('foo'),
  24. array('0'),
  25. array(0),
  26. array('button[]'),
  27. );
  28. }
  29. /**
  30. * @dataProvider getValidNames
  31. */
  32. public function testValidNames($name)
  33. {
  34. $this->assertInstanceOf('\Symfony\Component\Form\ButtonBuilder', new ButtonBuilder($name));
  35. }
  36. public function getInvalidNames()
  37. {
  38. return array(
  39. array(''),
  40. array(false),
  41. array(null),
  42. );
  43. }
  44. /**
  45. * @dataProvider getInvalidNames
  46. */
  47. public function testInvalidNames($name)
  48. {
  49. $this->{method_exists($this, $_ = 'expectException') ? $_ : 'setExpectedException'}(
  50. '\Symfony\Component\Form\Exception\InvalidArgumentException',
  51. 'Buttons cannot have empty names.'
  52. );
  53. new ButtonBuilder($name);
  54. }
  55. }