scratch – Blame information for rev 87
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
87 | office | 1 | <?php |
2 | |||
3 | namespace Fusonic\OpenGraph\Test; |
||
4 | |||
5 | use Fusonic\OpenGraph\Publisher; |
||
6 | use Fusonic\OpenGraph\Test\TestData\TestPublishObject; |
||
7 | |||
8 | class PublisherTest extends \PHPUnit_Framework_TestCase |
||
9 | { |
||
10 | /** |
||
11 | * @var Publisher |
||
12 | */ |
||
13 | private $publisher; |
||
14 | |||
15 | protected function setUp() |
||
16 | { |
||
17 | $this->publisher = new Publisher(); |
||
18 | |||
19 | parent::setUp(); |
||
20 | } |
||
21 | |||
22 | public function testGenerateHtmlNull() |
||
23 | { |
||
24 | $object = new TestPublishObject(null); |
||
25 | |||
26 | $result = $this->publisher->generateHtml($object); |
||
27 | |||
28 | $this->assertEquals("", $result); |
||
29 | } |
||
30 | |||
31 | public function testGenerateHtmlValuesProvider() |
||
32 | { |
||
33 | return [ |
||
34 | [ true, "1" ], |
||
35 | [ false, "0" ], |
||
36 | [ 1, "1" ], |
||
37 | [ -1, "-1" ], |
||
38 | [ 1.11111, "1.11111" ], |
||
39 | [ -1.11111, "-1.11111" ], |
||
40 | [ new \DateTime("2014-07-21T20:14:00+02:00"), "2014-07-21T20:14:00+02:00" ], |
||
41 | [ "string", "string" ], |
||
42 | [ "some \" quotes", "some " quotes" ], |
||
43 | [ "some & ampersand", "some & ampersand" ], |
||
44 | ]; |
||
45 | } |
||
46 | |||
47 | /** |
||
48 | * @dataProvider testGenerateHtmlValuesProvider |
||
49 | */ |
||
50 | public function testGenerateHtmlValues($value, $expectedContent) |
||
51 | { |
||
52 | $object = new TestPublishObject($value); |
||
53 | |||
54 | $result = $this->publisher->generateHtml($object); |
||
55 | |||
56 | $this->assertEquals('<meta property="' . TestPublishObject::KEY . '" content="' . $expectedContent . '">', $result); |
||
57 | } |
||
58 | |||
59 | /** |
||
60 | * @expectedException \UnexpectedValueException |
||
61 | */ |
||
62 | public function testGenerateHtmlUnsupportedObject() |
||
63 | { |
||
64 | $object = new TestPublishObject(new \stdClass()); |
||
65 | |||
66 | $this->publisher->generateHtml($object); |
||
67 | } |
||
68 | } |