TagBuilderTest::setUp()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
3
namespace Leogout\Bundle\SeoBundle\Tests\Builder;
4
5
use Leogout\Bundle\SeoBundle\Builder\TagBuilder;
6
use Leogout\Bundle\SeoBundle\Factory\TagFactory;
7
use Leogout\Bundle\SeoBundle\Model\MetaTag;
8
use Leogout\Bundle\SeoBundle\Tests\TestCase;
9
10
/**
11
 * Description of TagBuilderTest.
12
 *
13
 * @author: leogout
14
 */
15
class TagBuilderTest extends TestCase
16
{
17
    /**
18
     * @var TagBuilder
19
     */
20
    protected $tagBuilder;
21
22
    protected function setUp()
23
    {
24
        $this->tagBuilder = new TagBuilder(new TagFactory());
25
    }
26
27
    public function testRenderAll()
28
    {
29
        $this->tagBuilder->setTitle('Awesonme | Site');
30
        $this->tagBuilder->addMeta('keywords', MetaTag::NAME_TYPE, 'keywords', 'your, tags');
31
        $this->tagBuilder->addLink('rss',
32
            'http://symfony.com/blog',
33
            'alternate',
34
            'application/rss+xml',
35
            'RSS'
36
        );
37
38
        $this->assertEquals(
39
            "<title>Awesonme | Site</title>\n".
40
            "<meta name=\"keywords\" content=\"your, tags\" />\n".
41
            "<link href=\"http://symfony.com/blog\" rel=\"alternate\" type=\"application/rss+xml\" title=\"RSS\" />",
42
            $this->tagBuilder->render()
43
        );
44
    }
45
46
    public function testRenderTitle()
47
    {
48
        $this->tagBuilder->setTitle('Awesonme | Site');
49
50
        $this->assertEquals(
51
            '<title>Awesonme | Site</title>',
52
            $this->tagBuilder->render()
53
        );
54
    }
55
56
    public function testRenderMeta()
57
    {
58
        $this->tagBuilder->addMeta('keywords', MetaTag::NAME_TYPE, 'keywords', 'your, tags');
59
60
        $this->assertEquals(
61
            '<meta name="keywords" content="your, tags" />',
62
            $this->tagBuilder->render()
63
        );
64
    }
65
66
    public function testRenderLink()
67
    {
68
        $this->tagBuilder->addLink('rss',
69
            'http://symfony.com/blog',
70
            'alternate',
71
            'application/rss+xml',
72
            'RSS'
73
        );
74
75
        $this->assertEquals(
76
            '<link href="http://symfony.com/blog" rel="alternate" type="application/rss+xml" title="RSS" />',
77
            $this->tagBuilder->render()
78
        );
79
    }
80
81
    public function testRenderNothing()
82
    {
83
        $this->assertEquals(
84
            '',
85
            $this->tagBuilder->render()
86
        );
87
    }
88
}
89