BoxTest::testBox()   B
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 27
Code Lines 18

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 27
rs 8.8571
c 0
b 0
f 0
cc 1
eloc 18
nc 1
nop 0
1
<?php
2
3
class BoxTest extends \WebCMS\Tests\EntityTestCase
4
{
5
    protected $box;
6
7
    public function testBox()
8
    {
9
        $this->initBox();
10
11
        $this->em->persist($this->box);
12
        $this->em->flush();
13
14
        $boxes = $this->em->getRepository('WebCMS\Entity\Box')->findAll();
15
16
        $this->assertEquals(1, count($boxes));
17
        $this->assertEquals('box1', $boxes[0]->getBox());
18
        $this->assertEquals('function', $boxes[0]->getFunction());
19
        $this->assertEquals('presenter', $boxes[0]->getPresenter());
20
        $this->assertEquals('Module', $boxes[0]->getModuleName());
21
        $this->assertInstanceOf('WebCMS\Entity\Page', $boxes[0]->getPageFrom());
22
        $this->assertInstanceOf('WebCMS\Entity\Page', $boxes[0]->getPageTo());
23
24
        $this->em->remove($boxes[0]->getPageFrom());
25
        $this->em->remove($boxes[0]->getPageTo());
26
        $this->em->remove($boxes[0]);
27
28
        $this->em->flush();
29
30
        $boxes = $this->em->getRepository('WebCMS\Entity\Box')->findAll();
31
32
        $this->assertEquals(0, count($boxes));
33
    }
34
35 View Code Duplication
    private function setPage($text = 'test')
0 ignored issues
show
Duplication introduced by
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...
36
    {
37
        $page = new \WebCMS\Entity\Page();
38
        $page->setTitle($text);
39
        $page->setPresenter($text);
40
        $page->setPath($text);
41
        $page->setVisible(true);
42
        $page->setDefault(true);
43
        $page->setClass('');
44
45
        return $page;
46
    }
47
48
    private function initBox()
49
    {
50
        $pageFrom = $this->setPage('Page from');
51
        $pageTo = $this->setPage('Page to');
52
53
        $this->em->persist($pageFrom);
54
        $this->em->persist($pageTo);
55
56
        $this->box = new WebCMS\Entity\Box();
57
        $this->box->setBox('box1');
58
        $this->box->setFunction('function');
59
        $this->box->setPresenter('presenter');
60
        $this->box->setModuleName('Module');
61
        $this->box->setPageFrom($pageFrom);
62
        $this->box->setPageTo($pageTo);
63
    }
64
}
65