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

Source for file Services_Trackback_SpamCheck_SURBL_Test.php

Documentation is available at Services_Trackback_SpamCheck_SURBL_Test.php

  1. <?php
  2.  
  3. // Includepath for local CVS development
  4. // set_include_path('/cvs/pear/Services_Trackback'.PATH_SEPARATOR.get_include_path());
  5.  
  6.     // {{{ require_once
  7.  
  8. // Services_Trackback classes
  9. require_once 'Services/Trackback.php';
  10. require_once 'Services/Trackback/SpamCheck.php';
  11. require_once 'Services/Trackback/SpamCheck/SURBL.php';
  12.  
  13. // Unittest suite
  14. require_once 'PHPUnit.php';
  15.  
  16. // Testdata
  17. require_once dirname(__FILE__).'/trackback_data.php';
  18.  
  19.     // }}}
  20.  
  21. class Webservices_Trackback_SpamCheck_SURBL_TestCase extends PHPUnit_TestCase
  22. {
  23.  
  24.     var $trackbacks = array();
  25.  
  26.     var $spamCheck;
  27.     
  28.     // {{{ Webservices_Trackback_SpamCheck_TestCase()
  29.     
  30.     // constructor of the test suite
  31.     function Webservices_Trackback_SpamCheck_SURBL_TestCase($name{
  32.        $this->PHPUnit_TestCase($name);
  33.     }
  34.  
  35.     // }}}
  36.     // {{{ setup()
  37.     
  38.     function setUp({
  39.         global $trackbackData;
  40.         foreach ($trackbackData as $id => $set{
  41.             $this->trackbacks[$idServices_Trackback::create($set);
  42.         }
  43.         $this->spamCheck Services_Trackback_SpamCheck::create('SURBL');
  44.     }
  45.  
  46.     // }}}
  47.     // {{{ tearDown()
  48.     
  49.     function tearDown({
  50.     }
  51.  
  52.     // }}}
  53.     // {{{ Test create()
  54.  
  55.     function test_create({
  56.         $realCheck = new Services_Trackback_SpamCheck_SURBL();
  57.         $this->assertTrue($this->spamCheck == $realCheck);
  58.     }
  59.  
  60.     // }}}
  61.     // {{{ Test check()
  62.     function test_check_failure_nospam({
  63.         $this->assertTrue(!$this->spamCheck->check($this->trackbacks['nospam']));
  64.     }
  65.     function test_check_failure_undetected({
  66.         $this->assertTrue(!$this->spamCheck->check($this->trackbacks['undetected']));
  67.     }
  68.     function test_check_success_all({
  69.         $this->assertTrue($this->spamCheck->check($this->trackbacks['all']));
  70.     }
  71.     function test_check_failure_host({
  72.         $this->assertTrue(!$this->spamCheck->check($this->trackbacks['host']));
  73.     }
  74.     function test_check_failure_title({
  75.         $this->assertTrue(!$this->spamCheck->check($this->trackbacks['title']));
  76.     }
  77.     function test_check_success_excerpt({
  78.         $this->assertTrue($this->spamCheck->check($this->trackbacks['excerpt']));
  79.     }
  80.     function test_check_success_url({
  81.         $this->assertTrue($this->spamCheck->check($this->trackbacks['url']));
  82.     }
  83.     function test_check_failure_blog_name({
  84.         $this->assertTrue(!$this->spamCheck->check($this->trackbacks['blog_name']));
  85.     }
  86.     // }}}
  87.     // {{{ Test getResults()
  88.  
  89.     function test_getResults({
  90.         $this->spamCheck->check($this->trackbacks['all']);
  91.         $results $this->spamCheck->getResults();
  92.         $this->assertTrue($results[0]);
  93.     }
  94.  
  95.     // }}}
  96.     // {{{ Test reset()
  97.  
  98.     function test_reset({
  99.         $this->spamCheck->check($this->trackbacks['all']);
  100.         $this->spamCheck->_results = array();
  101.         $this->spamCheck->_urls = array();
  102.         $fakeCheck Services_Trackback_SpamCheck::create('SURBL');
  103.         $this->assertTrue($this->spamCheck == $fakeCheck);
  104.     }
  105.  
  106.     // }}}
  107.  
  108. }
  109. $suite  = new PHPUnit_TestSuite("Webservices_Trackback_SpamCheck_SURBL_TestCase");
  110. $result = PHPUnit::run($suite);
  111.  
  112. echo $result->toString();
  113.  
  114. ?>

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