Services_Technorati
[ class tree: Services_Technorati ] [ index: Services_Technorati ] [ all elements ]

Source for file Services_Technorati_Test.php

Documentation is available at Services_Technorati_Test.php

  1. <?php
  2.  
  3. require_once 'Services/Technorati.php';
  4. require_once 'PHPUnit.php';
  5.  
  6. class Services_Technorati_TestCase extends PHPUnit_TestCase
  7. {
  8.     // contains the object handle of our Technorati class.
  9.     public $tapi;
  10.     
  11.     // contains our API key
  12.     public static $key;
  13.     
  14.     // /* constructor for test suite */
  15.     // function __construct($name) {
  16.     //     $this->PHPUnit_TestCase($name);
  17.     // }
  18.     
  19.     function setUp({
  20.         $this->tapi =Services_Technorati::factory(self::$keynull1.0);
  21.     }
  22.     
  23.     function tearDown({
  24.         unset($this->tapi);
  25.     }
  26.     
  27.     /*
  28.      * Test that the factory brings the same result as going directly to the
  29.      * constructor. This will only work while we're going with the one API
  30.      * version
  31.      */
  32.     function testFactory({
  33.         $testTapi = new Services_Technorati(self::$keynull1.0);
  34.         $this->assertTrue($this->tapi == $testTapi);
  35.     }
  36.     
  37.     /* Test that the keyinfo query returns the two numeric values we need */
  38.     function testKeyInfo({
  39.         $result $this->tapi->keyInfo();
  40.         $this->assertTrue(is_numeric((int)$result->document->result->apiqueries));
  41.         $this->assertTrue(is_numeric((int)$result->document->result->maxqueries));
  42.     }
  43.     
  44.     /* Test that the result of a cosmos query is either a relevant PEAR error or an
  45.      * array populated with at least the query metadata. The only parameter
  46.      * passed is a URL.
  47.      */
  48.     function testCosmos({
  49.         $result $this->tapi->cosmos('http://www.example.com');
  50.         $this->assertTrue(is_object($result));
  51.         $this->assertEquals('http://www.example.com'(string)$result->document->result->url);
  52.     }
  53.     
  54.     /* Test that the result of a search query is either a relevant PEAR error or an
  55.      * array populated with at least the query metadata. The only parameter
  56.      * passed is a single search term.
  57.      */    
  58.     function testSearch({
  59.         $result $this->tapi->search('example');
  60.         $this->assertTrue(is_object($result));
  61.         $this->assertEquals('example'(string)$result->document->result->query);
  62.     }
  63.     
  64.     /* Test that the result of a getInfo query is either a relevant PEAR error or an
  65.      * array populated with at least the query metadata. The only parameter
  66.      * passed is a single username.
  67.      */        
  68.     function testGetInfo({
  69.         $result $this->tapi->getInfo('jystewart');
  70.         $this->assertTrue($result instanceof SimpleXMLElement);
  71.         $this->assertEquals('jystewart'(string)$result->document->result->username);
  72.     }
  73.     
  74.     /* Test that the result of an outbound query is either a relevant PEAR error or an
  75.      * array populated with at least the query metadata. The only parameter
  76.      * passed is a single URL.
  77.          
  78.     function testOutbound() {
  79.         $result = $this->tapi->outbound('http://www.example.com');
  80.         $this->assertTrue(($result instanceof SimpleXMLElement && 
  81.             (string)$result->document->result->url == 'http://www.example.com') or
  82.             PEAR::isError($result));
  83.     }
  84.     
  85.     /* Test that the result of a blogInfo query is either a relevant PEAR error or an
  86.      * array populated with at least the query metadata. The only parameter
  87.      * passed is a single URL.
  88.      */    
  89.     function testBlogInfo({
  90.         $result $this->tapi->blogInfo('http://www.example.com');
  91.         $this->assertTrue($result instanceof SimpleXMLElement);
  92.         $this->assertEquals('http://www.example.com'(string)$result->document->result->url);
  93.     }
  94.     
  95.     /* Test that the result of a tag query is either a relevant PEAR error or an
  96.      * array populated with at least the query metadata. The only parameter
  97.      * passed is a single search term.
  98.      */
  99.     function testTag({
  100.         $result $this->tapi->tag('example');
  101.         $this->assertTrue($result instanceof SimpleXMLElement);
  102.         $this->assertEquals('example'(string)$result->document->result->query);
  103.     }
  104.     
  105.     /* Test that the result of a TopTags query is either a relevant PEAR error or an
  106.      * array populated with at least a numeric value for the limit on number of results.
  107.      */        
  108.     function testTopTags({
  109.         $result $this->tapi->topTags();
  110.         $this->assertTrue($result instanceof SimpleXMLElement);
  111.         $this->assertTrue(is_numeric((int)$result->document->result->limit));
  112.     }
  113. }
  114.  
  115. $suite = new PHPUnit_TestSuite('Services_Technorati_TestCase');
  116. $result = PHPUnit::run($suite'123');
  117. echo $result->toString();
  118.  
  119. ?>

Documentation generated on Mon, 11 Mar 2019 14:58:13 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.