Completed
Push — master ( db5e85...36b1aa )
by Artem
02:41
created

LegacyFormHelperTest   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 47
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 3
Bugs 2 Features 1
Metric Value
wmc 5
c 3
b 2
f 1
lcom 0
cbo 2
dl 0
loc 47
rs 10
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
    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