Completed
Pull Request — develop (#8)
by
unknown
04:33
created

MetaTagTest::testRenderEmptyString()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 15

Duplication

Lines 15
Ratio 100 %

Importance

Changes 0
Metric Value
dl 15
loc 15
rs 9.7666
c 0
b 0
f 0
cc 1
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
            ->setTagName('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
            ->setTagName('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
            ->setTagName('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 View Code Duplication
    public function testRenderEmptyString()
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...
58
    {
59
        $metaTag = new MetaTag();
60
        $metaTag
61
            ->setType(MetaTag::PROPERTY_TYPE)
62
            ->setTagName('og:determiner')
63
            ->setContent('')
64
        ;
65
66
        // This is a valid use case, according to the opengraph specs an empty string is a valid value for determiner.
67
        $this->assertEquals(
68
            '<meta property="og:determiner" content="" />',
69
            $metaTag->render()
70
        );
71
    }
72
73
    public function testRenderNothing()
74
    {
75
        $metaTag = new MetaTag();
76
77
        $this->assertEquals('', $metaTag->render());
78
    }
79
80
    /**
81
     * @expectedException \InvalidArgumentException
82
     * @expectedExceptionMessage Meta tag of type "unknownType" doesn't exist. Existing types are: name, property and http-equiv.
83
     */
84
    public function testSetUnknownType()
85
    {
86
        $metaTag = new MetaTag();
87
        $metaTag->setType('unknownType');
88
    }
89
}
90