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

EnumTest   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 39
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 6
Bugs 3 Features 3
Metric Value
wmc 4
c 6
b 3
f 3
lcom 1
cbo 3
dl 0
loc 39
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\Validator;
12
13
use Fresh\DoctrineEnumBundle\Tests\Fixtures\DBAL\Types\BasketballPositionType;
14
use Fresh\DoctrineEnumBundle\Validator\Constraints\Enum;
15
16
/**
17
 * EnumTest.
18
 *
19
 * @author Artem Genvald <[email protected]>
20
 */
21
class EnumTest extends \PHPUnit_Framework_TestCase
22
{
23
    public function testConstructor()
24
    {
25
        $constraint = new Enum([
26
            'entity' => 'Fresh\DoctrineEnumBundle\Tests\Fixtures\DBAL\Types\BasketballPositionType',
27
        ]);
28
29
        $this->assertEquals(BasketballPositionType::getValues(), $constraint->choices);
30
    }
31
32
    /**
33
     * @expectedException \Symfony\Component\Validator\Exception\MissingOptionsException
34
     */
35
    public function testMissedRequiredOption()
36
    {
37
        $constraint = new Enum();
38
39
        $this->assertEquals(['entity'], $constraint->getRequiredOptions());
40
    }
41
42
    public function testGetRequiredOptions()
43
    {
44
        $constraint = new Enum([
45
            'entity' => 'Fresh\DoctrineEnumBundle\Tests\Fixtures\DBAL\Types\BasketballPositionType',
46
        ]);
47
48
        $this->assertEquals(['entity'], $constraint->getRequiredOptions());
49
    }
50
51
    public function testGetDefaultOption()
52
    {
53
        $constraint = new Enum([
54
            'entity' => 'Fresh\DoctrineEnumBundle\Tests\Fixtures\DBAL\Types\BasketballPositionType',
55
        ]);
56
57
        $this->assertEquals('choices', $constraint->getDefaultOption());
58
    }
59
}
60