Completed
Push — master ( 782aec...24395c )
by Artem
05:23 queued 01:53
created

testExceptionForGetUnsupportedType()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 1 Features 0
Metric Value
c 1
b 1
f 0
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
/*
3
 * This file is part of the FreshDoctrineEnumBundle
4
 *
5
 * (c) Artem Genvald <[email protected]>
6
 *
7
 * For the full copyright and license information, please view the LICENSE
8
 * file that was distributed with this source code.
9
 */
10
11
namespace Fresh\DoctrineEnumBundle\Tests\Util;
12
13
use Fresh\DoctrineEnumBundle\Util\LegacyFormHelper;
14
15
/**
16
 * LegacyFormHelperTest
17
 *
18
 * @author Jaik Dean <[email protected]>
19
 * @author Artem Genvald <[email protected]>
20
 */
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
    /**
52
     * @return array
53
     */
54
    public function dataProviderForGetTypeTest()
55
    {
56
        return [
57
            [2, 'choice'],
58
            [3, 'Symfony\Component\Form\Extension\Core\Type\ChoiceType'],
59
        ];
60
    }
61
62
    /**
63
     * @expectedException \InvalidArgumentException
64
     * @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
65
     */
66
    public function testExceptionForGetUnsupportedType()
67
    {
68
        LegacyFormHelper::getType('Symfony\Component\Form\Extension\Core\Type\TextType', 2);
69
    }
70
}
71