Sophie

Sophie

distrib > Mandriva > 2010.0 > i586 > media > contrib-release > by-pkgid > 47200008af2de8c8cd71da51b0eadb13 > files > 4

php-pear-Services_Trackback-0.6.1-6mdv2010.0.noarch.rpm

<?php

// Includepath for local CVS development
// set_include_path('/cvs/pear/Services_Trackback'.PATH_SEPARATOR.get_include_path());

    // {{{ require_once

// Services_Trackback classes
require_once 'Services/Trackback.php';
require_once 'Services/Trackback/SpamCheck.php';
require_once 'Services/Trackback/SpamCheck/DNSBL.php';

// Unittest suite
require_once 'PHPUnit.php';

// Testdata
require_once dirname(__FILE__).'/trackback_data.php';

    // }}}

class Webservices_Trackback_SpamCheck_DNSBL_TestCase extends PHPUnit_TestCase
{

    var $trackbacks = array();

    var $spamCheck;
    
    // {{{ Webservices_Trackback_SpamCheck_DNSBL_TestCase()
    
    // constructor of the test suite
    function Webservices_Trackback_SpamCheck_DNSBL_TestCase($name) {
       $this->PHPUnit_TestCase($name);
    }

    // }}}
    // {{{ setup()
    
    function setUp() {
        global $trackbackData;
        foreach ($trackbackData as $id => $set) {
            $this->trackbacks[$id] = Services_Trackback::create($set);
        }
        $this->spamCheck = Services_Trackback_SpamCheck::create('DNSBL');
    }

    // }}}
    // {{{ tearDown()
    
    function tearDown() {
    }

    // }}}
    // {{{ Test create()

    function test_create() {
        $realCheck = new Services_Trackback_SpamCheck_DNSBL();
        $this->assertTrue($this->spamCheck == $realCheck);
    }

    // }}}
    // {{{ Test check()
    function test_check_failure_nospam() {
        $this->assertTrue(!$this->spamCheck->check($this->trackbacks['nospam']));
    }
    function test_check_failure_undetected() {
        $this->assertTrue(!$this->spamCheck->check($this->trackbacks['undetected']));
    }
    function test_check_success_all() {
        $this->assertTrue($this->spamCheck->check($this->trackbacks['all']));
    }
    function test_check_success_host() {
        $this->assertTrue($this->spamCheck->check($this->trackbacks['host']));
    }
    function test_check_failure_title() {
        $this->assertTrue(!$this->spamCheck->check($this->trackbacks['title']));
    }
    function test_check_faulire_excerpt() {
        $this->assertTrue(!$this->spamCheck->check($this->trackbacks['excerpt']));
    }
    function test_check_failure_url() {
        $this->assertTrue(!$this->spamCheck->check($this->trackbacks['url']));
    }
    function test_check_failure_blog_name() {
        $this->assertTrue(!$this->spamCheck->check($this->trackbacks['blog_name']));
    }
    // }}}
    // {{{ Test getResults()

    function test_getResults() {
        $this->spamCheck->check($this->trackbacks['all']);
        $results = $this->spamCheck->getResults();
        $this->assertTrue($results[0]);
    }

    // }}}
    // {{{ Test reset()

    function test_reset() {
        $this->spamCheck->check($this->trackbacks['all']);
        $this->spamCheck->reset();
        $fakeCheck = Services_Trackback_SpamCheck::create('DNSBL');
        $fakeCheck->_dnsbl->blacklists = array('bl.spamcop.net');
        $this->assertTrue($this->spamCheck == $fakeCheck);
    }

    // }}}

}
$suite  = new PHPUnit_TestSuite("Webservices_Trackback_SpamCheck_DNSBL_TestCase");
$result = PHPUnit::run($suite);

echo $result->toString();

?>