|
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
|
|
|
|