Completed
Branch master (3b8125)
by
unknown
01:23
created

PropertyManagerTest::testManger()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 11
rs 9.9
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
namespace HelloWordPl\SimpleEntityGeneratorBundle\Tests\Lib\Items;
4
5
use HelloWordPl\SimpleEntityGeneratorBundle\Lib\Items\PropertyManager;
6
7
/**
8
 * PropertyManager Test
9
 *
10
 * @author Sławomir Kania <[email protected]>
11
 */
12
class PropertyManagerTest extends BaseManager
13
{
14
15
    /**
16
     * @var PropertyManager
17
     */
18
    protected $propertyManager = null;
19
20
    /**
21
     * SET UP
22
     */
23
    public function setUp()
24
    {
25
        parent::setUp();
26
        $this->propertyManager = $this->preapareClassManager()->getProperties()->last();
27
    }
28
29
    public function testManger()
30
    {
31
        $this->assertInstanceOf('\HelloWordPl\SimpleEntityGeneratorBundle\Lib\Interfaces\RenderableInterface', $this->propertyManager);
32
        $this->assertInstanceOf('\HelloWordPl\SimpleEntityGeneratorBundle\Lib\Items\PropertyManager', $this->propertyManager);
33
        $this->assertEquals('User new posts', $this->propertyManager->getComment());
34
        $this->assertEquals('new_posts', $this->propertyManager->getName());
35
        $this->assertEquals('newPosts', $this->propertyManager->getPreparedName());
36
        $this->assertEquals('Doctrine\Common\Collections\ArrayCollection<AppBundle\Entity\Post>', $this->propertyManager->getType());
37
        $this->assertEquals('Doctrine\Common\Collections\ArrayCollection', $this->propertyManager->getTypeName());
38
        $this->assertEquals(2, count($this->propertyManager->getConstraints()));
39
    }
40
41
    public function testValidManagerWhenValid()
42
    {
43
        $errors = $this->getValidator()->validate($this->propertyManager);
44
        $this->assertEquals(0, $errors->count());
45
    }
46
47
    public function testValidManagerWhenEmpty()
48
    {
49
        $errors = $this->getValidator()->validate(new PropertyManager());
50
        $this->assertEquals(4, $errors->count());
51
    }
52
}
53