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

LegacyFormHelperTest   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 50
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 2
Bugs 1 Features 1
Metric Value
wmc 5
c 2
b 1
f 1
lcom 0
cbo 2
dl 0
loc 50
rs 10

5 Methods

Rating   Name   Duplication   Size   Complexity  
A testIsLegacy() 0 4 1
A dataProviderForIsLegacyTest() 0 8 1
A testGetType() 0 7 1
A dataProviderForGetTypeTest() 0 7 1
A testExceptionForGetUnsupportedType() 0 4 1
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