testHeadingIsTypeCastToString()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 8
rs 9.4286
cc 1
eloc 5
nc 1
nop 1
1
<?php
2
3
/**
4
 * This file is part of the Axstrad library.
5
 *
6
 * (c) Dan Kempster <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 *
11
 * @copyright 2014-2015 Dan Kempster <[email protected]>
12
 */
13
14
namespace Axstrad\Component\Content\Tests\Functional;
15
16
use Axstrad\Component\Content\Article;
17
use Axstrad\Component\Content\Entity;
18
use Axstrad\Component\Content\Model;
19
20
/**
21
 * Axstrad\Component\Content\Tests\Functional\SatisfiesArticleInterfaceTest
22
 *
23
 * @author Dan Kempster <[email protected]>
24
 * @license MIT
25
 * @package Axstrad/Content
26
 * @subpackage Tests
27
 * @group functional
28
 */
29
class SatisfiesArticleInterfaceTest extends SatisfiesCopyInterfaceTest
30
{
31
    public function fixtureProvider()
32
    {
33
        return array(
34
35
            // Model
36
            [new Model\Article],
37
            [new Model\ArticleIntroduction],
38
39
            // Doctrine/ORM
40
            [new Entity\Article],
41
            [new Entity\ArticleIntroduction],
42
        );
43
    }
44
45
    public function classNameProvider()
46
    {
47
        return array(
48
            // Model
49
            ['Axstrad\Component\Content\Model\Article'],
50
            ['Axstrad\Component\Content\Model\ArticleIntroduction'],
51
52
            // Doctrine/ORM
53
            ['Axstrad\Component\Content\Entity\Article'],
54
            ['Axstrad\Component\Content\Entity\ArticleIntroduction'],
55
        );
56
    }
57
58
    /**
59
     * @dataProvider classNAmeProvider
60
     * @param Article $fixture
61
     */
62
    public function testImplementsArticleInterface($fixture)
63
    {
64
        $this->assertTrue(
65
            is_a($fixture, 'Axstrad\Component\Content\Article', true),
66
            sprintf(
67
                '%s doesn\'t implement the %s interface',
68
                $fixture,
69
                'Axstrad\Component\Content\Article'
70
            )
71
        );
72
    }
73
74
    /**
75
     * @dataProvider fixtureProvider
76
     * @param Article $fixture
77
     */
78
    public function testCanSetHeading($fixture)
79
    {
80
        $fixture->setHeading('A New Heading.');
81
        $this->assertEquals(
82
            'A New Heading.',
83
            $fixture->getHeading()
84
        );
85
    }
86
87
    /**
88
     * @dataProvider fixtureProvider
89
     * @param Article $fixture
90
     */
91
    public function testSetHeadingReturnsSelf($fixture)
92
    {
93
        $this->assertSame(
94
            $fixture,
95
            $fixture->setHeading('')
96
        );
97
    }
98
99
    /**
100
     * @dataProvider fixtureProvider
101
     * @param Article $fixture
102
     */
103
    public function testHeadingIsTypeCastToString($fixture)
104
    {
105
        $fixture->setHeading(1.1);
106
        $this->assertSame(
107
            '1.1',
108
            $fixture->getHeading()
109
        );
110
    }
111
112
    /**
113
     * @dataProvider fixtureProvider
114
     * @param Article $fixture
115
     */
116
    public function testNullIsTypeCastToString($fixture)
117
    {
118
        $fixture->setHeading(null);
119
        $this->assertSame(
120
            '',
121
            $fixture->getHeading()
122
        );
123
    }
124
}
125