Blame view

libs/XML_Feed_Parser-1.0.2/tests/atomEntryOnly.php 2.53 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
  <?php
  
  require_once 'XML_Feed_Parser_TestCase.php';
  
  class XML_Feed_Parser_AtomEntryOnly_TestCase extends XML_Feed_Parser_TestCase
  {
      function __construct($name)
      {
          $this->PHPUnit_TestCase($name);
          $sample_dir = XML_Feed_Parser_TestCase::getSampleDir();
          $this->feed = new XML_Feed_Parser(file_get_contents($sample_dir . DIRECTORY_SEPARATOR . 'atom10-entryonly.xml'));
          $this->entry = $this->feed->getEntryByOffset(0);
      }
  
      function test_Title()
      {
          $value = 'Atom draft-07 snapshot';
          $this->assertEquals($this->entry->title, $value);
      }
  
      function test_Id()
      {
          $value = 'tag:example.org,2003:3.2397';
          $this->assertEquals($this->entry->id, $value);
      }
  
      function test_Updated()
      {
          $value = strtotime('2005-07-10T12:29:29Z');
          $this->assertEquals($this->entry->updated, $value);
      }
  
      function test_Published()
      {
          $value = strtotime('2003-12-13T08:29:29-04:00');
          $this->assertEquals($this->entry->published, $value);
      }
      
      function test_AuthorURI()
      {
          $value = 'http://example.org/';
          $this->assertEquals($value, $this->entry->author(null, array('param' => 'uri')));
      }
  
      function test_Contributor()
      {
          $value = 'Sam Ruby';
          $this->assertEquals($this->entry->contributor, $value);
      }
  
      function test_Contributor2()
      {
          $value = 'Joe Gregorio';
          $this->assertEquals($this->entry->contributor(1), $value);
      }
  
      function test_Content()
      {
          $value = '<p><i>[Update: The Atom draft is finished.]</i></p>';
          $content = trim(preg_replace('/\t/', ' ', $this->entry->content));
          $content = preg_replace('/(\s\s)+/', ' ', $content);
          $this->assertEquals($value, $content);
      }
  
      function test_Link()
      {
          $value = 'http://example.org/2005/04/02/atom';
          $this->assertEquals($this->entry->link, $value);
      }
      
      function test_Enclosure()
      {
          $value = array (
             'url' => 'http://example.org/audio/ph34r_my_podcast.mp3',
             'type' => 'audio/mpeg',
             'length' => '1337');
          $this->assertEquals($this->entry->enclosure, $value);
      }
      
      
      function test_entryXPath()
      {
          $this->assertEquals('http://example.org/2005/04/02/atom', 
              $this->entry->link(0, 'href', array('rel'=>'alternate')));
      }
  }
  
  $suite = new PHPUnit_TestSuite;
  $suite->addTestSuite('XML_Feed_Parser_AtomEntryOnly_TestCase');
  $result = PHPUnit::run($suite, '123');
  echo $result->toString();
  
  ?>