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

Source for file Services_Trackback_SpamCheck_Test.php

Documentation is available at Services_Trackback_SpamCheck_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/Wordlist.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_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_TestCase($name{
  32.        $this->PHPUnit_TestCase($name);
  33.     }
  34.  
  35.     // }}}
  36.     // {{{ setup()
  37.     
  38.     function setUp({
  39.         global $trackbackData;
  40.         $this->_trackbacks['nospam'Services_Trackback::create($trackbackData['nospam']);
  41.         $this->_trackbacks['spam'=  Services_Trackback::create($trackbackData['all']);
  42.         $this->spamCheck = new Services_Trackback_SpamCheck_Wordlist();
  43.     }
  44.  
  45.     // }}}
  46.     // {{{ tearDown()
  47.     
  48.     function tearDown({
  49.     }
  50.  
  51.     // }}}
  52.     // {{{ Test create()
  53.  
  54.     function test_create({
  55.         $realCheck Services_Trackback_SpamCheck::create('Wordlist');
  56.         $this->assertTrue($this->spamCheck == $realCheck);
  57.     }
  58.  
  59.     // }}}
  60.     // {{{ Test check()
  61.  
  62.     function test_check_success({
  63.         $this->assertTrue($this->spamCheck->check($this->_trackbacks['spam']));
  64.     }
  65.     
  66.     function test_check_failure({
  67.         $this->assertTrue(!$this->spamCheck->check($this->_trackbacks['nospam']));
  68.     }
  69.  
  70.     // }}}
  71.     // {{{ Test getResults()
  72.  
  73.     function test_getResults({
  74.         $this->spamCheck->check($this->_trackbacks['spam']);
  75.         $results $this->spamCheck->getResults();
  76.         $this->assertTrue($results[6]);
  77.     }
  78.  
  79.     // }}}
  80.     // {{{ Test reset()
  81.  
  82.     function test_reset({
  83.         $this->spamCheck->check($this->_trackbacks['spam']);
  84.         $this->spamCheck->_results = array();
  85.         $fakeCheck Services_Trackback_SpamCheck::create('Wordlist');
  86.         $this->assertTrue($this->spamCheck == $fakeCheck);
  87.     }
  88.  
  89.     // }}}
  90.  
  91. }
  92. $suite  = new PHPUnit_TestSuite("Webservices_Trackback_SpamCheck_TestCase");
  93. $result = PHPUnit::run($suite);
  94.  
  95. echo $result->toString();
  96.  
  97. ?>

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