| 1 | <?php |
||
| 21 | class LegacyFormHelperTest extends \PHPUnit_Framework_TestCase |
||
| 22 | { |
||
| 23 | /** |
||
| 24 | * @dataProvider dataProviderForIsLegacyTest |
||
| 25 | */ |
||
| 26 | public function testIsLegacy($majorVersion, $expectedLegacyStatus) |
||
| 27 | { |
||
| 28 | $this->assertEquals($expectedLegacyStatus, LegacyFormHelper::isLegacy($majorVersion)); |
||
| 29 | } |
||
| 30 | |||
| 31 | public function dataProviderForIsLegacyTest() |
||
| 32 | { |
||
| 33 | return [ |
||
| 34 | [1, true], |
||
| 35 | [2, true], |
||
| 36 | [3, false], |
||
| 37 | ]; |
||
| 38 | } |
||
| 39 | |||
| 40 | /** |
||
| 41 | * @dataProvider dataProviderForGetTypeTest |
||
| 42 | */ |
||
| 43 | public function testGetType($majorVersion, $expectedFormType) |
||
| 44 | { |
||
| 45 | $this->assertEquals( |
||
| 46 | $expectedFormType, |
||
| 47 | LegacyFormHelper::getType('Symfony\Component\Form\Extension\Core\Type\ChoiceType', $majorVersion) |
||
| 48 | ); |
||
| 49 | } |
||
| 50 | |||
| 51 | public function dataProviderForGetTypeTest() |
||
| 52 | { |
||
| 53 | return [ |
||
| 54 | [2, 'choice'], |
||
| 55 | [3, 'Symfony\Component\Form\Extension\Core\Type\ChoiceType'], |
||
| 56 | ]; |
||
| 57 | } |
||
| 58 | |||
| 59 | /** |
||
| 60 | * @expectedException \InvalidArgumentException |
||
| 61 | * @expectedExceptionMessage Form type with class "Symfony\Component\Form\Extension\Core\Type\TextType" can not be found. Please check for typos or add it to the map in LegacyFormHelper |
||
| 62 | */ |
||
| 63 | public function testExceptionForGetUnsupportedType() |
||
| 64 | { |
||
| 65 | LegacyFormHelper::getType('Symfony\Component\Form\Extension\Core\Type\TextType', 2); |
||
| 66 | } |
||
| 67 | } |
||
| 68 |