1 | <?php |
---|
2 | |
---|
3 | require_once 'XML_Feed_Parser_TestCase.php'; |
---|
4 | |
---|
5 | class XML_Feed_Parser_AtomEntryOnly_TestCase extends XML_Feed_Parser_TestCase |
---|
6 | { |
---|
7 | function __construct($name) |
---|
8 | { |
---|
9 | $this->PHPUnit_TestCase($name); |
---|
10 | $sample_dir = XML_Feed_Parser_TestCase::getSampleDir(); |
---|
11 | $this->feed = new XML_Feed_Parser(file_get_contents($sample_dir . DIRECTORY_SEPARATOR . 'atom10-entryonly.xml')); |
---|
12 | $this->entry = $this->feed->getEntryByOffset(0); |
---|
13 | } |
---|
14 | |
---|
15 | function test_Title() |
---|
16 | { |
---|
17 | $value = 'Atom draft-07 snapshot'; |
---|
18 | $this->assertEquals($this->entry->title, $value); |
---|
19 | } |
---|
20 | |
---|
21 | function test_Id() |
---|
22 | { |
---|
23 | $value = 'tag:example.org,2003:3.2397'; |
---|
24 | $this->assertEquals($this->entry->id, $value); |
---|
25 | } |
---|
26 | |
---|
27 | function test_Updated() |
---|
28 | { |
---|
29 | $value = strtotime('2005-07-10T12:29:29Z'); |
---|
30 | $this->assertEquals($this->entry->updated, $value); |
---|
31 | } |
---|
32 | |
---|
33 | function test_Published() |
---|
34 | { |
---|
35 | $value = strtotime('2003-12-13T08:29:29-04:00'); |
---|
36 | $this->assertEquals($this->entry->published, $value); |
---|
37 | } |
---|
38 | |
---|
39 | function test_AuthorURI() |
---|
40 | { |
---|
41 | $value = 'http://example.org/'; |
---|
42 | $this->assertEquals($value, $this->entry->author(null, array('param' => 'uri'))); |
---|
43 | } |
---|
44 | |
---|
45 | function test_Contributor() |
---|
46 | { |
---|
47 | $value = 'Sam Ruby'; |
---|
48 | $this->assertEquals($this->entry->contributor, $value); |
---|
49 | } |
---|
50 | |
---|
51 | function test_Contributor2() |
---|
52 | { |
---|
53 | $value = 'Joe Gregorio'; |
---|
54 | $this->assertEquals($this->entry->contributor(1), $value); |
---|
55 | } |
---|
56 | |
---|
57 | function test_Content() |
---|
58 | { |
---|
59 | $value = '<p><i>[Update: The Atom draft is finished.]</i></p>'; |
---|
60 | $content = trim(preg_replace('/\t/', ' ', $this->entry->content)); |
---|
61 | $content = preg_replace('/(\s\s)+/', ' ', $content); |
---|
62 | $this->assertEquals($value, $content); |
---|
63 | } |
---|
64 | |
---|
65 | function test_Link() |
---|
66 | { |
---|
67 | $value = 'http://example.org/2005/04/02/atom'; |
---|
68 | $this->assertEquals($this->entry->link, $value); |
---|
69 | } |
---|
70 | |
---|
71 | function test_Enclosure() |
---|
72 | { |
---|
73 | $value = array ( |
---|
74 | 'url' => 'http://example.org/audio/ph34r_my_podcast.mp3', |
---|
75 | 'type' => 'audio/mpeg', |
---|
76 | 'length' => '1337'); |
---|
77 | $this->assertEquals($this->entry->enclosure, $value); |
---|
78 | } |
---|
79 | |
---|
80 | |
---|
81 | function test_entryXPath() |
---|
82 | { |
---|
83 | $this->assertEquals('http://example.org/2005/04/02/atom', |
---|
84 | $this->entry->link(0, 'href', array('rel'=>'alternate'))); |
---|
85 | } |
---|
86 | } |
---|
87 | |
---|
88 | $suite = new PHPUnit_TestSuite; |
---|
89 | $suite->addTestSuite('XML_Feed_Parser_AtomEntryOnly_TestCase'); |
---|
90 | $result = PHPUnit::run($suite, '123'); |
---|
91 | echo $result->toString(); |
---|
92 | |
---|
93 | ?> |
---|