MetaTagTest::testRenderNothing()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 9
rs 9.6666
c 0
b 0
f 0
cc 1
eloc 5
nc 1
nop 0
1
<?php
2
3
namespace Leogout\Bundle\SeoBundle\Tests\Model;
4
5
use Leogout\Bundle\SeoBundle\Model\MetaTag;
6
use Leogout\Bundle\SeoBundle\Tests\TestCase;
7
8
/**
9
 * Description of MetaTagTest.
10
 *
11
 * @author: leogout
12
 */
13
class MetaTagTest extends TestCase
14
{
15 View Code Duplication
    public function testRenderName()
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...
16
    {
17
        $metaTag = new MetaTag();
18
        $metaTag
19
            ->setType(MetaTag::NAME_TYPE)
20
            ->setValue('keywords')
21
            ->setContent('your, tags');
22
23
        $this->assertEquals(
24
            '<meta name="keywords" content="your, tags" />',
25
            $metaTag->render()
26
        );
27
    }
28
29 View Code Duplication
    public function testRenderProperty()
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...
30
    {
31
        $metaTag = new MetaTag();
32
        $metaTag
33
            ->setType(MetaTag::PROPERTY_TYPE)
34
            ->setValue('og:title')
35
            ->setContent('My awesome site');
36
37
        $this->assertEquals(
38
            '<meta property="og:title" content="My awesome site" />',
39
            $metaTag->render()
40
        );
41
    }
42
43 View Code Duplication
    public function testRenderHttpEquiv()
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...
44
    {
45
        $metaTag = new MetaTag();
46
        $metaTag
47
            ->setType(MetaTag::HTTP_EQUIV_TYPE)
48
            ->setValue('Cache-Control')
49
            ->setContent('no-cache');
50
51
        $this->assertEquals(
52
            '<meta http-equiv="Cache-Control" content="no-cache" />',
53
            $metaTag->render()
54
        );
55
    }
56
57
    public function testRenderNothing()
58
    {
59
        $metaTag = new MetaTag();
60
61
        $this->assertEquals(
62
            '<meta name="" content="" />',
63
            $metaTag->render()
64
        );
65
    }
66
67
    /**
68
     * @expectedException \InvalidArgumentException
69
     * @expectedExceptionMessage Meta tag of type "unknownType" doesn't exist. Existing types are: name, property and http-equiv.
70
     */
71
    public function testSetUnknownType()
72
    {
73
        $metaTag = new MetaTag();
74
        $metaTag->setType('unknownType');
75
    }
76
}
77