* @license PHP License * @package WB * @subpackage unittest */ WBClass::load('WBException_Datasource' , 'WBUnitTest_SQLUte' , 'WBEvent_Handler_UnitTest'); /** * Unit Test * * Test table * * @version 0.1.1 * @package WB * @subpackage unittest */ class TestCaseDictionaryURL extends UnitTestCase { /** * table * @var WBDatasource_Table */ protected $table; /** * dictionary - system under test * @var WBDictionary_URL */ protected $dict; /** * constructor */ public function __construct() { WBUnitTest_SQLUte::source( __FILE__, 'construct'); $this->table = WBClass::create('WBDatasource_Table'); $this->dict = WBClass::create('WBDictionary_URL'); } /** * destructor */ public function __destruct() { // WBUnitTest_SQLUte::source(__FILE__, 'destruct'); } /** * check instance * */ public function testInstances() { $this->assertTrue(class_exists('WBDatasource_Table', false)); $this->assertTrue(is_object($this->table)); $this->assertIsA($this->table, 'WBDatasource_Table'); $this->assertTrue(class_exists('WBDictionary_URL', false)); $this->assertTrue(is_object($this->dict)); $this->assertIsA($this->dict, 'WBDictionary_URL'); } public function testAddWord() { $self = WBString::replaceSuperPlaceholders('http://[[SERVER]][[DOCROOT]]'); $urls = array( '/local/link/bar', '/more/local/stuff', 'gerd@php-tools.net', 'http://lena.sub.org/', 'http://wombat.exit0.net/img/px.gif', 'http://wombat.exit0.net/devel/todo', 'http://de.wikipedia.org/wiki/Wombat', 'http://www.bundesregierung.de/nn_1264/Content/DE/Artikel/20Jahre/2009-10-16-montagsdemo-in-leipzig.html', 'http://www.w3.org/standards/webdesign/', 'http://www.youtube.com/watch?v=XF2bSx0vtz4', 'http://my.nero.com/', 'http://truss.my.nero.com/', 'http://truss.my.nero.com/blog/7404282', $self, $self . '/site.php/some/page', $self . '/file.php/xx123/image/jpeg/testBild.jpg', $self . '/css.php', $self . '/js.php/WB/prototype.js', 'ftp://ftp.kernel.org/pub/linux/kernel/v2.6/' ); foreach ($urls as $url) { WBEvent_Handler_UnitTest::flushList('now'); // first call of addWord should actually add the word $this->dict->addWord($url); $list = WBEvent_Handler_UnitTest::getProclist('now'); $count = count($list); $this->assertEqual($count, 1, $url); // second call is supposed to do nothing $this->dict->addWord($url); $list = WBEvent_Handler_UnitTest::getProclist('now'); $count = count($list); $this->assertEqual($count, 1, $url); $id = $this->dict->getId(); $this->assertNotNull($id); $this->assertTrue($this->dict->lookupWord($url)); $this->assertEqual($this->dict->getWord(), $url, $url); // load a non-exising word in between $this->assertFalse($this->dict->lookupWord('http://example.com/an.url.that.never.has.been.added.html')); $this->assertNull($this->dict->getId()); $this->assertNull($this->dict->getWord()); // load recently added word $this->assertTrue($this->dict->lookupWord($url)); $this->assertEqual($this->dict->getId(), $id); $this->assertEqual($this->dict->getWord(), $url); // $this->dict->autoPopulate($id); } } } ?>