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

Kunstmaan/SeoBundle/Tests/unit/Entity/SeoTest.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\SeoBundle\Tests\Entity;
4
5
use Doctrine\ORM\EntityManager;
6
use Doctrine\ORM\EntityRepository;
7
use Kunstmaan\RedirectBundle\Entity\Redirect;
8
use Kunstmaan\SeoBundle\Entity\Seo;
9
use PHPUnit_Framework_TestCase;
10
11
/**
12
 * Generated by PHPUnit_SkeletonGenerator on 2012-09-18 at 12:21:52.
13
 */
14
class SeoTest extends PHPUnit_Framework_TestCase
15
{
16
    /**
17
     * @var Seo
18
     */
19
    protected $object;
20
21
    /**
22
     * Sets up the fixture, for example, opens a network connection.
23
     * This method is called before a test is executed.
24
     */
25
    protected function setUp()
26
    {
27
        $this->object = new Seo();
28
    }
29
30
    public function testGetSetMetaAuthor()
31
    {
32
        $this->object->setMetaAuthor('Author Name');
33
        $this->assertEquals('Author Name', $this->object->getMetaAuthor());
34
    }
35
36
    public function testGetSetMetaDescription()
37
    {
38
        $this->object->setMetaDescription('Meta Description');
39
        $this->assertEquals('Meta Description', $this->object->getMetaDescription());
40
    }
41
42
    public function testGetSetMetaRobots()
43
    {
44
        $this->object->setMetaRobots('noindex, nofollow');
45
        $this->assertEquals('noindex, nofollow', $this->object->getMetaRobots());
46
    }
47
48
    public function testGetSetExtraMetadata()
49
    {
50
        $this->object->setExtraMetadata('Extra Metadata');
51
        $this->assertEquals('Extra Metadata', $this->object->getExtraMetadata());
52
    }
53
54
    public function testGetSetOgDescription()
55
    {
56
        $this->object->setOgDescription('OpenGraph description');
57
        $this->assertEquals('OpenGraph description', $this->object->getOgDescription());
58
    }
59
60
    public function testGetSetOgImageWithImage()
61
    {
62
        $media = $this->createMock('Kunstmaan\MediaBundle\Entity\Media');
63
        $this->object->setOgImage($media);
64
        $this->assertEquals($media, $this->object->getOgImage());
65
    }
66
67
    public function testGetSetOgImageWithNullValue()
68
    {
69
        $this->object->setOgImage(null);
70
        $this->assertEquals(null, $this->object->getOgImage());
71
    }
72
73
    public function testGetSetOgTitle()
74
    {
75
        $this->object->setOgTitle('OpenGraph title');
76
        $this->assertEquals('OpenGraph title', $this->object->getOgTitle());
77
    }
78
79
    public function testGetSetOgType()
80
    {
81
        $this->object->setOgType('website');
82
        $this->assertEquals('website', $this->object->getOgType());
83
    }
84
85
    public function testGetSetTwitterTitle()
86
    {
87
        $this->object->setTwitterTitle('twitter title');
88
        $this->assertEquals('twitter title', $this->object->getTwitterTitle());
89
    }
90
91
    public function testGetSetTwitterDescription()
92
    {
93
        $this->object->setTwitterDescription('twitter description');
94
        $this->assertEquals('twitter description', $this->object->getTwitterDescription());
95
    }
96
97
    public function testGetSetTwitterSite()
98
    {
99
        $this->object->setTwitterSite('@kunstmaan');
100
        $this->assertEquals('@kunstmaan', $this->object->getTwitterSite());
101
    }
102
103
    public function testGetSetTwitterCreator()
104
    {
105
        $this->object->setTwitterCreator('@denbatte');
106
        $this->assertEquals('@denbatte', $this->object->getTwitterCreator());
107
    }
108
109
    public function testGetSetTwitterImageWithImage()
110
    {
111
        $media = $this->createMock('Kunstmaan\MediaBundle\Entity\Media');
112
        $this->object->setTwitterImage($media);
113
        $this->assertEquals($media, $this->object->getTwitterImage());
114
    }
115
116
    public function testGetSetTwitterImageWithNullValue()
117
    {
118
        $this->object->setTwitterImage(null);
119
        $this->assertEquals(null, $this->object->getTwitterImage());
120
    }
121
122
    public function testGetDefaultAdminType()
123
    {
124
        $this->assertEquals('Kunstmaan\SeoBundle\Form\SeoType', $this->object->getDefaultAdminType());
125
    }
126
127
    public function testGettersSetters()
128
    {
129
        $this->object->setOgUrl('https://nasa.gov');
130
        $this->object->setMetaTitle('NASA');
131
        $this->object->setOgArticlePublisher('NASA PR dept');
132
        $this->object->setOgArticleSection('Mars');
133
        $this->object->setOgArticleAuthor('delboy1978uk');
134
135
        $this->assertEquals('https://nasa.gov', $this->object->getOgUrl());
136
        $this->assertEquals('NASA', $this->object->getMetaTitle());
137
        $this->assertEquals('NASA PR dept', $this->object->getOgArticlePublisher());
138
        $this->assertEquals('Mars', $this->object->getOgArticleSection());
139
        $this->assertEquals('delboy1978uk', $this->object->getOgArticleAuthor());
140
    }
141
142 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...
143
    {
144
        $ref = new Redirect();
145
        $ref->setId(666);
146
147
        $this->object->setRef($ref);
148
149
        $em = $this->getMockBuilder(EntityManager::class)
150
            ->disableOriginalConstructor()
151
            ->getMock();
152
153
        $repo = $this->getMockBuilder(EntityRepository::class)
154
            ->disableOriginalConstructor()
155
            ->getMock();
156
157
        $repo->expects($this->any())
158
            ->method('find')
159
            ->will($this->returnValue($ref));
160
161
        $em->expects($this->any())
162
            ->method('getRepository')
163
            ->will($this->returnValue($repo));
164
165
        $this->assertInstanceOf(Redirect::class, $this->object->getRef($em));
166
        $this->assertEquals('666', $this->object->getRefId());
167
        $this->assertEquals(Redirect::class, $this->object->getRefEntityName());
168
    }
169
}
170