Completed
Push — master ( 6e92d2...d7f3a5 )
by
unknown
109:07 queued 86:32
created

NodeBundle/Tests/Entity/NodeVersionTest.php (1 issue)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
3
namespace Kunstmaan\NodeBundle\Tests\Entity;
4
5
use Doctrine\ORM\EntityManager;
6
use Doctrine\ORM\EntityRepository;
7
use Kunstmaan\NodeBundle\Entity\NodeTranslation;
8
use Kunstmaan\NodeBundle\Entity\NodeVersion;
9
use PHPUnit_Framework_TestCase;
10
11
/**
12
 * Class NodeVersionTest
13
 * @package Tests\Kunstmaan\NodeBundle\Entity
14
 */
15
class NodeVersionTest extends PHPUnit_Framework_TestCase
16
{
17
    /**
18
     * @var NodeVersion
19
     */
20
    protected $object;
21
22
    /**
23
     * Sets up the fixture, for example, opens a network connection.
24
     * This method is called before a test is executed.
25
     */
26
    protected function setUp()
27
    {
28
        $this->object = new NodeVersion();
29
    }
30
31
    public function testSetGetNodeTranslation()
32
    {
33
        $nodeTrans = new NodeTranslation();
34
        $this->object->setNodeTranslation($nodeTrans);
35
        $this->assertEquals($nodeTrans, $this->object->getNodeTranslation());
36
    }
37
38
    public function testSetGetType()
39
    {
40
        $this->object->setType(NodeVersion::DRAFT_VERSION);
41
        $this->assertEquals(NodeVersion::DRAFT_VERSION, $this->object->getType());
42
    }
43
44
    public function testSetGetOwner()
45
    {
46
        $this->object->setOwner('owner');
47
        $this->assertEquals('owner', $this->object->getOwner());
48
    }
49
50
    public function testSetGetCreated()
51
    {
52
        $created = new \DateTime();
53
        $this->object->setCreated($created);
54
        $this->assertEquals($created, $this->object->getCreated());
55
    }
56
57
    public function testSetGetUpdated()
58
    {
59
        $updated = new \DateTime();
60
        $this->object->setUpdated($updated);
61
        $this->assertEquals($updated, $this->object->getUpdated());
62
    }
63
64 View Code Duplication
    public function testGetSetRef()
0 ignored issues
show
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
65
    {
66
        $entity = new TestEntity(1);
67
68
        $em = $this->getMockBuilder(EntityManager::class)
69
            ->disableOriginalConstructor()
70
            ->getMock();
71
72
        $repo = $this->getMockBuilder(EntityRepository::class)
73
            ->disableOriginalConstructor()
74
            ->getMock();
75
76
        $repo->expects($this->any())
77
            ->method('find')
78
            ->will($this->returnValue($entity));
79
80
        $em->expects($this->any())
81
            ->method('getRepository')
82
            ->will($this->returnValue($repo));
83
84
        $this->object->setRef($entity);
85
        $this->assertEquals(1, $this->object->getRefId());
86
        $this->assertEquals('Kunstmaan\NodeBundle\Tests\Entity\TestEntity', $this->object->getRefEntityName());
87
        $this->assertInstanceOf(TestEntity::class, $this->object->getRef($em));
88
    }
89
90
    public function testGetDefaultAdminType()
91
    {
92
        $this->assertNull($this->object->getDefaultAdminType());
93
    }
94
95
    public function testGetSetOrigin()
96
    {
97
        $entity = new NodeVersion();
98
        $this->object->setOrigin($entity);
99
        $this->assertInstanceOf(NodeVersion::class, $this->object->getOrigin());
100
    }
101
102
    public function testIsPublic()
103
    {
104
        $this->object->setType(NodeVersion::PUBLIC_VERSION);
105
        $this->assertTrue($this->object->isPublic());
106
    }
107
}
108