source: branches/beta/html/test/adachi/PLLagger/Lib/XML/Feed/tests/rss1Values.php @ 15120

Revision 15120, 5.3 KB checked in by adati, 17 years ago (diff)

1.4.2betaのマージ

Line 
1<?php
2
3require_once 'XML_Feed_Parser_TestCase.php';
4
5class XML_Feed_Parser_RSS1_valueValidity_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->file = file_get_contents($sample_dir . DIRECTORY_SEPARATOR . "rss10-example2.xml");
12        $this->feed = new XML_Feed_Parser($this->file);
13        $this->entry = $this->feed->getEntryByOffset(0);
14    }
15
16    function setup()
17    {
18    }
19
20    function test_feedNumberItems()
21    {
22        $value = 1;
23        $this->assertEquals($value, $this->feed->numberEntries);
24    }
25    function test_feedTitle()
26    {
27        $value = "Meerkat";
28        $this->assertEquals($value, $this->feed->title);
29    }
30   
31    function test_feedLink()
32    {
33        $value = "http://meerkat.oreillynet.com";
34        $this->assertEquals($value, $this->feed->link);
35    }
36   
37    function test_feedDescription()
38    {
39        $value = "Meerkat: An Open Wire Service";
40        $this->assertEquals($value, $this->feed->description);
41    }
42   
43    function test_feedSubtitleEquivalence()
44    {
45        $value = "Meerkat: An Open Wire Service";
46        $this->assertEquals($value, $this->feed->subtitle);
47    }
48   
49    function test_feedPublisher()
50    {
51        $value = "The O'Reilly Network";
52        $this->assertEquals($value, $this->feed->publisher);
53    }
54   
55    function test_feedCreator()
56    {
57        $value = "Rael Dornfest (mailto:rael@oreilly.com)";
58        $this->assertEquals($value, $this->feed->creator);
59    }
60   
61    function test_feedAuthorEquivalence()
62    {
63        $value = "Rael Dornfest (mailto:rael@oreilly.com)";
64        $this->assertEquals($value, $this->feed->author);
65    }
66   
67    function test_feedRights()
68    {
69        $value = "Copyright &copy; 2000 O'Reilly &amp; Associates, Inc.";
70        $this->assertEquals($value, htmlentities(utf8_decode($this->feed->rights)));
71    }
72   
73    function test_feedDate()
74    {
75        $value = strtotime("2000-01-01T12:00+00:00");
76        $this->assertEquals($value, $this->feed->date);
77    }
78   
79    function test_feedUpdatedEquivalence()
80    {
81        $value = strtotime("2000-01-01T12:00+00:00");
82        $this->assertEquals($value, $this->feed->updated);
83    }
84   
85    function test_feedUpdatePeriod()
86    {
87        $value = 'hourly';
88        $this->assertEquals($value, $this->feed->updatePeriod);
89    }
90   
91    function test_feedUpdateFrequency()
92    {
93        $value = "2";
94        $this->assertEquals($value, $this->feed->updateFrequency);
95    }
96   
97    function test_feedUpdateBase()
98    {
99        $value = strtotime("2000-01-01T12:00+00:00");
100        $this->assertEquals($value, $this->feed->updateBase);
101    }
102   
103    function test_feedImage()
104    {
105        $value = array(
106            'title' => false,
107            'link' => false,
108            'url' => "http://meerkat.oreillynet.com/icons/meerkat-powered.jpg",
109            'description' => false,
110            'height' => false,
111            'width' => false);
112        $this->assertEquals($value, $this->feed->image);
113    }
114   
115    function test_entryTitle()
116    {
117        $value = "XML: A Disruptive Technology";
118        $this->assertEquals($value, $this->entry->title);
119    }
120   
121    function test_entryLink()
122    {
123        $value = "http://c.moreover.com/click/here.pl?r123";
124        $this->assertEquals($value, $this->entry->link);
125    }
126   
127    function test_entryDescription()
128    {
129        $value  = "XML is placing increasingly heavy loads on the existing technical infrastructure of the Internet.";
130        $description = trim($this->entry->description);
131        $description = preg_replace("/\t/", " ", $description);
132        $description = preg_replace("/(\s\s)+/", " ", $description);
133        $description = preg_replace("/(\s\s)+/", " ", $description);
134        $this->assertEquals($value, $description);
135    }
136   
137    function test_entryRights()
138    {
139        $value = "Copyright &copy; 2000 O'Reilly &amp; Associates, Inc.";
140        $this->assertEquals($value, htmlentities(utf8_decode($this->feed->rights)));
141    }
142   
143    function test_entryCreator()
144    {
145        $value = "Simon St.Laurent (mailto:simonstl@simonstl.com)";
146        $this->assertEquals($value, $this->entry->creator);
147    }
148   
149    function test_entryAuthorEquivalence()
150    {
151        $value = "Simon St.Laurent (mailto:simonstl@simonstl.com)";
152        $this->assertEquals($value, $this->entry->author);
153    }
154   
155    function test_entryPublisher()
156    {
157        $value = "The O'Reilly Network";
158        $this->assertEquals($value, $this->entry->publisher);
159    }
160   
161    function test_entryCategory()
162    {
163        $value = "XML";
164        $this->assertEquals($value, $this->entry->category);
165    }
166   
167    function test_entryIdEquivalence()
168    {
169        $value = "http://c.moreover.com/click/here.pl?r123";
170        $this->assertEquals($value, $this->entry->id);
171    }
172   
173    function test_feedTextInput()
174    {
175        $value = array(
176            'title' => null,
177             'description' => null,
178             'name' => null,
179             'link' => "http://meerkat.oreillynet.com");
180        $this->assertEquals($value, $this->feed->textinput);
181    }
182}
183
184$suite = new PHPUnit_TestSuite;
185$suite->addTestSuite("XML_Feed_Parser_RSS1_valueValidity_TestCase");
186$result = PHPUnit::run($suite, "123");
187echo $result->toString();
188
189?>
Note: See TracBrowser for help on using the repository browser.