Completed
Push — master ( 87bf0f...7cf916 )
by Artem
02:21
created

EnumTest::testConstructor()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 1 Features 1
Metric Value
c 1
b 1
f 1
dl 0
loc 8
rs 9.4286
cc 1
eloc 4
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\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
    /**
24
     * Test constructor
25
     */
26
    public function testConstructor()
27
    {
28
        $constraint = new Enum([
29
            'entity' => 'Fresh\DoctrineEnumBundle\Tests\Fixtures\DBAL\Types\BasketballPositionType',
30
        ]);
31
32
        $this->assertEquals(BasketballPositionType::getValues(), $constraint->choices);
33
    }
34
35
    /**
36
     * Test method missed required option `entity`
37
     *
38
     * @expectedException \Symfony\Component\Validator\Exception\MissingOptionsException
39
     */
40
    public function testMissedRequiredOption()
41
    {
42
        $constraint = new Enum();
43
44
        $this->assertEquals(['entity'], $constraint->getRequiredOptions());
45
    }
46
47
    /**
48
     * Test method getRequiredOptions
49
     */
50
    public function testGetRequiredOptions()
51
    {
52
        $constraint = new Enum([
53
            'entity' => 'Fresh\DoctrineEnumBundle\Tests\Fixtures\DBAL\Types\BasketballPositionType',
54
        ]);
55
56
        $this->assertEquals(['entity'], $constraint->getRequiredOptions());
57
    }
58
59
    /**
60
     * Test method getDefaultOption
61
     */
62
    public function testGetDefaultOption()
63
    {
64
        $constraint = new Enum([
65
            'entity' => 'Fresh\DoctrineEnumBundle\Tests\Fixtures\DBAL\Types\BasketballPositionType',
66
        ]);
67
68
        $this->assertEquals('choices', $constraint->getDefaultOption());
69
    }
70
}
71