[ Index ]
 

Code source de LifeType 1.2.4

Accédez au Source d'autres logiciels libres

Classes | Fonctions | Variables | Constantes | Tables

title

Body

[fermer]

/class/test/tests/dao/ -> trackbackclient_test.class.php (source)

   1  <?php
   2  
   3      lt_include( PLOG_CLASS_PATH."class/test/helpers/lifetypetestcase.class.php" );
   4      lt_include( PLOG_CLASS_PATH."class/dao/trackbackclient.class.php" );
   5  
   6      /**
   7       * \ingroup Test
   8       *
   9       * Test cases for the TrackbackClient class
  10       */
  11      class TrackbackClient_Test extends LifeTypeTestCase
  12      {
  13  		function setUp()
  14          {
  15              // definition of our test pages
  16              
  17              $this->page = '
  18  <html><body>            
  19  !-- <rdf:RDF xmlns="http://web.resource.org/cc/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
  20  <Work rdf:about="">
  21      <license rdf:resource="http://creativecommons.org/licenses/by-nc-sa/2.5/" />
  22      <dc:type rdf:resource="http://purl.org/dc/dcmitype/Text" />
  23  </Work>
  24  <License rdf:about="http://creativecommons.org/licenses/by-nc-sa/2.5/"><permits rdf:resource="http://web.resource.org/cc/Reproduction"/>
  25      <permits rdf:resource="http://web.resource.org/cc/Distribution"/><requires rdf:resource="http://web.resource.org/cc/Notice"/>
  26      <requires rdf:resource="http://web.resource.org/cc/Attribution"/><prohibits rdf:resource="http://web.resource.org/cc/CommercialUse"/>
  27      <permits rdf:resource="http://web.resource.org/cc/DerivativeWorks"/><requires rdf:resource="http://web.resource.org/cc/ShareAlike"/></License>
  28  </rdf:RDF> -->
  29  <p>blah blah blah</p>
  30  <!-- <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
  31        xmlns:dc="http://purl.org/dc/elements/1.1/"
  32        xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/">
  33      <rdf:Description rdf:about="http://www.lifetype.net/blog/lifetype%2Ddevelopment%2Djournal/2007/02/14/critical%2Dsecurity%2Dissue%2Dlifetype%2D1.1.6%2Dand%2Dlifetype%2D1.2%2Dbeta2%2Dreleased"          dc:identifier="http://www.lifetype.net/blog/lifetype%2Ddevelopment%2Djournal/2007/02/14/critical%2Dsecurity%2Dissue%2Dlifetype%2D1.1.6%2Dand%2Dlifetype%2D1.2%2Dbeta2%2Dreleased"
  34      dc:title="Critical security issue: Lifetype 1.1.6 and Lifetype 1.2\-beta2 released"
  35      trackback:ping="http://www.lifetype.net/trackback.php?id=193"/></rdf:RDF> -->
  36  </body></html>
  37  ';
  38  
  39              // this one has three different trackback links
  40              $this->page2 = '
  41  <html><body>            
  42  !-- <rdf:RDF xmlns="http://web.resource.org/cc/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
  43  <Work rdf:about="">
  44      <license rdf:resource="http://creativecommons.org/licenses/by-nc-sa/2.5/" />
  45      <dc:type rdf:resource="http://purl.org/dc/dcmitype/Text" />
  46  </Work>
  47  <License rdf:about="http://creativecommons.org/licenses/by-nc-sa/2.5/"><permits rdf:resource="http://web.resource.org/cc/Reproduction"/>
  48      <permits rdf:resource="http://web.resource.org/cc/Distribution"/><requires rdf:resource="http://web.resource.org/cc/Notice"/>
  49      <requires rdf:resource="http://web.resource.org/cc/Attribution"/><prohibits rdf:resource="http://web.resource.org/cc/CommercialUse"/>
  50      <permits rdf:resource="http://web.resource.org/cc/DerivativeWorks"/><requires rdf:resource="http://web.resource.org/cc/ShareAlike"/></License>
  51  </rdf:RDF> -->
  52  <p>blah blah blah</p>
  53  <!-- <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
  54        xmlns:dc="http://purl.org/dc/elements/1.1/"
  55        xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/">
  56      <rdf:Description rdf:about="http://www.lifetype.net/blog/lifetype%2Ddevelopment%2Djournal/2007/02/14/critical%2Dsecurity%2Dissue%2Dlifetype%2D1.1.6%2Dand%2Dlifetype%2D1.2%2Dbeta2%2Dreleased"          dc:identifier="http://www.lifetype.net/blog/lifetype%2Ddevelopment%2Djournal/2007/02/14/critical%2Dsecurity%2Dissue%2Dlifetype%2D1.1.6%2Dand%2Dlifetype%2D1.2%2Dbeta2%2Dreleased"
  57      dc:title="Critical security issue: Lifetype 1.1.6 and Lifetype 1.2\-beta2 released"
  58      trackback:ping="http://www.lifetype.net/trackback.php?id=194"/></rdf:RDF> -->
  59      <!-- <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
  60            xmlns:dc="http://purl.org/dc/elements/1.1/"
  61            xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/">
  62          <rdf:Description rdf:about="http://www.lifetype.net/blog/lifetype%2Ddevelopment%2Djournal/2007/02/14/critical%2Dsecurity%2Dissue%2Dlifetype%2D1.1.6%2Dand%2Dlifetype%2D1.2%2Dbeta2%2Dreleased"          dc:identifier="http://www.lifetype.net/blog/lifetype%2Ddevelopment%2Djournal/2007/02/14/critical%2Dsecurity%2Dissue%2Dlifetype%2D1.1.6%2Dand%2Dlifetype%2D1.2%2Dbeta2%2Dreleased"
  63          dc:title="Critical security issue: Lifetype 1.1.6 and Lifetype 1.2\-beta2 released"
  64          trackback:ping="http://www.lifetype.net/trackback.php?id=193"/></rdf:RDF> -->
  65          <!-- <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
  66                xmlns:dc="http://purl.org/dc/elements/1.1/"
  67                xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/">
  68              <rdf:Description rdf:about="http://www.lifetype.net/blog/lifetype%2Ddevelopment%2Djournal/2007/02/14/critical%2Dsecurity%2Dissue%2Dlifetype%2D1.1.6%2Dand%2Dlifetype%2D1.2%2Dbeta2%2Dreleased"          dc:identifier="http://www.lifetype.net/blog/lifetype%2Ddevelopment%2Djournal/2007/02/14/critical%2Dsecurity%2Dissue%2Dlifetype%2D1.1.6%2Dand%2Dlifetype%2D1.2%2Dbeta2%2Dreleased"
  69              dc:title="Critical security issue: Lifetype 1.1.6 and Lifetype 1.2\-beta2 released"
  70              trackback:ping="http://www.lifetype.net/trackback.php?id=195"/></rdf:RDF> -->            
  71  </body></html>
  72  ';
  73  
  74              // this one has no valid trackback tags
  75              $this->page3 = '
  76  <html><body>            
  77  !-- <rdf:RDF xmlns="http://web.resource.org/cc/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
  78  <Work rdf:about="">
  79      <license rdf:resource="http://creativecommons.org/licenses/by-nc-sa/2.5/" />
  80      <dc:type rdf:resource="http://purl.org/dc/dcmitype/Text" />
  81  </Work>
  82  <License rdf:about="http://creativecommons.org/licenses/by-nc-sa/2.5/"><permits rdf:resource="http://web.resource.org/cc/Reproduction"/>
  83      <permits rdf:resource="http://web.resource.org/cc/Distribution"/><requires rdf:resource="http://web.resource.org/cc/Notice"/>
  84      <requires rdf:resource="http://web.resource.org/cc/Attribution"/><prohibits rdf:resource="http://web.resource.org/cc/CommercialUse"/>
  85      <permits rdf:resource="http://web.resource.org/cc/DerivativeWorks"/><requires rdf:resource="http://web.resource.org/cc/ShareAlike"/></License>
  86  </rdf:RDF> -->
  87  <p>blah blah blah</p>
  88  </body></html>
  89  ';
  90  
  91          }
  92          
  93  		function testGetTrackbackLinks()
  94          {    
  95              // get the trackback links from the given page
  96              $links = TrackbackClient::getTrackbackLinks( $this->page );
  97              
  98              // there should only be one link
  99              $this->assertEquals( 1, count( $links ), "There was more than one trackback link detected in the test page!" );
 100              
 101              // and that it is equal to the value that we're expecting
 102              $this->assertEquals( "http://www.lifetype.net/trackback.php?id=193", $links[0], "The returned trackback link was not the expected one!" );
 103          }
 104          
 105  		function testGetMultipleTrackbackLinks()
 106          {
 107              // get the trackback links from the given page
 108              $links = TrackbackClient::getTrackbackLinks( $this->page2 );
 109              
 110              // there should only be one link
 111              $this->assertEquals( 3, count( $links ), "There was not 3 trackback links detected in the test page!" );
 112              
 113              // and that it is equal to the value that we're expecting
 114              $this->assertEquals( "http://www.lifetype.net/trackback.php?id=194", $links[0], "The returned trackback link was not the expected one!" );
 115              $this->assertEquals( "http://www.lifetype.net/trackback.php?id=193", $links[1], "The returned trackback link was not the expected one!" );            
 116              $this->assertEquals( "http://www.lifetype.net/trackback.php?id=195", $links[2], "The returned trackback link was not the expected one!" );                        
 117          }
 118          
 119  		function testNoTrackbackLinks()
 120          {
 121              // get the trackback links from the given page
 122              $links = TrackbackClient::getTrackbackLinks( $this->page3 );
 123              
 124              // there should only be one link
 125              $this->assertEquals( 0, count( $links ), "There shouldn't be any trackback links detected in this page!" );            
 126          }
 127          
 128  		function testTrackbackLinksWithDashes()
 129          {
 130              // get the trackback links from the given page
 131              $links = TrackbackClient::getTrackbackLinks( $this->page, "http://www.lifetype.net/blog/lifetype-development-journal/2007/02/14/critical-security-issue-lifetype-1.1.6-and-lifetype-1.2-beta2-released" );
 132              
 133              // there should only be one link
 134              $this->assertEquals( 1, count( $links ), "There was more than one trackback link detected in the test page!" );
 135              
 136              // and that it is equal to the value that we're expecting
 137              $this->assertEquals( "http://www.lifetype.net/trackback.php?id=193", $links[0], "The returned trackback link was not the expected one!" );            
 138          }
 139      }
 140  ?>


Généré le : Mon Nov 26 21:04:15 2007 par Balluche grâce à PHPXref 0.7
  Clicky Web Analytics