Blame view

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