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\SeoBundle\Tests\Entity; |
||
4 | |||
5 | use Kunstmaan\SeoBundle\Entity\Seo; |
||
6 | use Kunstmaan\SeoBundle\Twig\SeoTwigExtension; |
||
7 | |||
8 | |||
9 | /** |
||
10 | * Generated by PHPUnit_SkeletonGenerator on 2012-09-18 at 12:21:52. |
||
11 | */ |
||
12 | class TwigExtensionTests extends \PHPUnit_Framework_TestCase |
||
13 | { |
||
14 | protected $emMock; |
||
15 | protected $entityMock; |
||
16 | protected $seoRepoMock; |
||
17 | |||
18 | /** |
||
19 | * Sets up the fixture, for example, opens a network connection. |
||
20 | * This method is called before a test is executed. |
||
21 | */ |
||
22 | protected function setUp() |
||
23 | { |
||
24 | $this->emMock = $this->getMock('\Doctrine\ORM\EntityManager', |
||
0 ignored issues
–
show
|
|||
25 | array('getRepository', 'getClassMetadata', 'persist', 'flush'), array(), '', false); |
||
26 | } |
||
27 | |||
28 | /** |
||
29 | * testShouldReturnNameForEntityWhenNoSEO |
||
30 | */ |
||
31 | View Code Duplication | public function testShouldReturnNameForEntityWhenNoSEO() |
|
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...
|
|||
32 | { |
||
33 | $name = 'OK'; |
||
34 | |||
35 | $this->entityWithName($name); |
||
36 | $this->noSeoFound(); |
||
37 | |||
38 | $object = new SeoTwigExtension($this->emMock); |
||
39 | |||
40 | |||
41 | $result = $object->getTitleFor($this->entityMock); |
||
42 | |||
43 | |||
44 | $this->assertEquals($name, $result); |
||
45 | } |
||
46 | |||
47 | /** |
||
48 | * testShouldReturnNameForEntityWhenSEOWithTitleFound |
||
49 | */ |
||
50 | View Code Duplication | public function testShouldReturnNameForEntityWhenSEOWithTitleFound() |
|
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...
|
|||
51 | { |
||
52 | $nokName = 'NOK'; |
||
53 | $name = 'OK'; |
||
54 | |||
55 | $this->entityWithName($nokName); |
||
56 | $this->seoFoundWithTitle($name); |
||
57 | |||
58 | $object = new SeoTwigExtension($this->emMock); |
||
59 | |||
60 | |||
61 | $result = $object->getTitleFor($this->entityMock); |
||
62 | |||
63 | |||
64 | $this->assertEquals($name, $result); |
||
65 | } |
||
66 | |||
67 | /** |
||
68 | * @param string $name |
||
69 | */ |
||
70 | protected function entityWithName($name) |
||
71 | { |
||
72 | $this->entityMock = $this->getMock('Kunstmaan\NodeBundle\Entity\AbstractPage'); |
||
0 ignored issues
–
show
The method
PHPUnit_Framework_TestCase::getMock() has been deprecated with message: Method deprecated since Release 5.4.0; use createMock() or getMockBuilder() instead
This method has been deprecated. The supplier of the class has supplied an explanatory message. The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.
Loading history...
|
|||
73 | $this->entityMock->expects($this->once())->method('getTitle')->will($this->returnValue($name)); |
||
74 | } |
||
75 | |||
76 | /** |
||
77 | * NoSeoFound |
||
78 | */ |
||
79 | protected function noSeoFound() |
||
80 | { |
||
81 | $this->ensureSeoRepoMock(); |
||
82 | $this->seoRepoMock->expects($this->once()) |
||
83 | ->method('findFor') |
||
84 | ->will($this->returnValue(null)); |
||
85 | |||
86 | $this->wireUpSeoRepo(); |
||
87 | } |
||
88 | |||
89 | /** |
||
90 | * ensureSeoRepoMock |
||
91 | */ |
||
92 | protected function ensureSeoRepoMock() |
||
93 | { |
||
94 | if (is_null($this->seoRepoMock)) { |
||
95 | $this->seoRepoMock = $this->getMock('Kunstmaan\SeoBundle\Repository\SeoRepository', array(), array(), '', false); |
||
96 | } |
||
97 | } |
||
98 | |||
99 | /** |
||
100 | * wireUpSeoRepo |
||
101 | */ |
||
102 | protected function wireUpSeoRepo() |
||
103 | { |
||
104 | $this->emMock->expects($this->once()) |
||
105 | ->method('getRepository') |
||
106 | ->with($this->equalTo('KunstmaanSeoBundle:Seo')) |
||
107 | ->will($this->returnValue($this->seoRepoMock)); |
||
108 | } |
||
109 | |||
110 | /** |
||
111 | * @param string $title |
||
112 | */ |
||
113 | protected function seoFoundWithTitle($title) |
||
114 | { |
||
115 | $this->ensureSeoRepoMock(); |
||
116 | |||
117 | $seoMock = new Seo(); |
||
118 | $seoMock->setRef($this->entityMock); |
||
119 | $seoMock->setMetaTitle($title); |
||
120 | |||
121 | $this->seoRepoMock->expects($this->once()) |
||
122 | ->method('findFor') |
||
123 | ->will($this->returnValue($seoMock)); |
||
124 | |||
125 | $this->wireUpSeoRepo(); |
||
126 | } |
||
127 | |||
128 | } |
||
129 |
This method has been deprecated. The supplier of the class has supplied an explanatory message.
The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.