From d8a5adc285fbd9237d7c3140f6d6a11b6eceaaee Mon Sep 17 00:00:00 2001 From: mensonge Date: Thu, 18 Dec 2008 10:59:43 +0000 Subject: Major refactoring: improve tests process. add a main file called allTests.php. git-svn-id: https://semanticscuttle.svn.sourceforge.net/svnroot/semanticscuttle/trunk@203 b3834d28-1941-0410-a4f8-b48e95affb8f --- tests/LAUNCH_TESTS | 4 +- tests/allTests.php | 39 ++ tests/bookmarksTest.php | 112 +++--- tests/dox.html | 1 + tests/tag2TagTest.php | 950 ++++++++++++++++++++++++------------------------ tests/tagsCacheTest.php | 172 +++++++++ tests/tagsTest.php | 132 +++---- 7 files changed, 812 insertions(+), 598 deletions(-) create mode 100644 tests/allTests.php create mode 100644 tests/dox.html create mode 100644 tests/tagsCacheTest.php diff --git a/tests/LAUNCH_TESTS b/tests/LAUNCH_TESTS index 531d239..5fcc559 100644 --- a/tests/LAUNCH_TESTS +++ b/tests/LAUNCH_TESTS @@ -2,6 +2,6 @@ You need PHPunit. Then -To launch the tests, put in a console situated in the root of the SEMANTICSCUTTLE project (where is the SEMANTICSCUTTLE config file): +To launch the tests, type in a console situated in the root of the SEMANTICSCUTTLE project (where is the SEMANTICSCUTTLE config file): -phpunit BookmarksTest ./tests/bookmarksTest.php ; phpunit CommonDescriptionTest tests/commonDescriptionTest.php ; phpunit Tag2TagTest tests/tag2TagTest.php ; phpunit SearchTest tests/searchTest.php ; phpunit TagsTest tests/tagsTest.php +phpunit --testdox-html tests/dox.html AllTests tests/allTests.php diff --git a/tests/allTests.php b/tests/allTests.php new file mode 100644 index 0000000..843911c --- /dev/null +++ b/tests/allTests.php @@ -0,0 +1,39 @@ +addTestFile('tests/bookmarksTest.php'); + $suite->addTestFile('tests/tag2TagTest.php'); + $suite->addTestFile('tests/tagsCacheTest.php'); + $suite->addTestFile('tests/commonDescriptionTest.php'); + $suite->addTestFile('tests/searchTest.php'); + $suite->addTestFile('tests/tagsTest.php'); + return $suite; + } + + protected function setUp() + { + global $dbhost, $dbuser, $dbpass, $dbname, $dbport, $dbpersist, $dbtype, $tableprefix, $TEMPLATES_DIR, $filetypes, $debugMode; + require_once('./header.inc.php'); + } + + protected function tearDown() + { + } +} +?> \ No newline at end of file diff --git a/tests/bookmarksTest.php b/tests/bookmarksTest.php index 9c8e533..e229d5e 100644 --- a/tests/bookmarksTest.php +++ b/tests/bookmarksTest.php @@ -2,74 +2,74 @@ require_once 'PHPUnit/Framework.php'; /* -To launch this test, type the following line into a shell -at the root of the scuttlePlus directory : - phpunit BookmarksTest tests/bookmarksTest.php -*/ + To launch this test, type the following line into a shell + into the tests/ directory : + phpunit BookmarksTest tests/boomarksTest.php + */ class BookmarksTest extends PHPUnit_Framework_TestCase { - protected $us; - protected $bs; - protected $ts; - protected $tts; - - protected function setUp() - { - global $dbhost, $dbuser, $dbpass, $dbname, $dbport, $dbpersist, $dbtype, $tableprefix; - require_once('./header.inc.php'); + protected $us; + protected $bs; + protected $ts; + protected $tts; - $this->us =& ServiceFactory::getServiceInstance('UserService'); - $this->bs =& ServiceFactory::getServiceInstance('BookmarkService'); - $this->bs->deleteAll(); - $this->b2ts=& ServiceFactory::getServiceInstance('Bookmark2TagService'); - $this->b2ts->deleteAll(); - $this->tts =& ServiceFactory::getServiceInstance('Tag2TagService'); - $this->tts->deleteAll(); - $this->tsts =& ServiceFactory::getServiceInstance('TagStatService'); - $this->tsts->deleteAll(); - } + protected function setUp() + { + global $dbhost, $dbuser, $dbpass, $dbname, $dbport, $dbpersist, $dbtype, $tableprefix, $TEMPLATES_DIR, $filetypes, $debugMode; + require_once('./header.inc.php'); - public function testHardCharactersInBookmarks() - { - $bs = $this->bs; - $title = "title&é\"'(-è_çà)="; - $desc = "description#{[|`\^@]}³<> ¹¡÷׿&é\"'(-è\\_çà)="; - $tag1 = "#{|`^@]³¹¡¿<&é\"'(-è\\_çà)"; - $tag2 = "&é\"'(-è.[?./§!_çà)"; + $this->us =& ServiceFactory::getServiceInstance('UserService'); + $this->bs =& ServiceFactory::getServiceInstance('BookmarkService'); + $this->bs->deleteAll(); + $this->b2ts=& ServiceFactory::getServiceInstance('Bookmark2TagService'); + $this->b2ts->deleteAll(); + $this->tts =& ServiceFactory::getServiceInstance('Tag2TagService'); + $this->tts->deleteAll(); + $this->tsts =& ServiceFactory::getServiceInstance('TagStatService'); + $this->tsts->deleteAll(); + } - $bs->addBookmark("http://site1.com", $title, $desc, "status", array($tag1, $tag2), null, false, false, 1); + public function testHardCharactersInBookmarks() + { + $bs = $this->bs; + $title = "title&é\"'(-è_çà)="; + $desc = "description#{[|`\^@]}³<> ¹¡÷׿&é\"'(-è\\_çà)="; + $tag1 = "#{|`^@]³¹¡¿<&é\"'(-è\\_çà)"; + $tag2 = "&é\"'(-è.[?./§!_çà)"; - $bookmarks =& $bs->getBookmarks(0, 1, NULL, NULL, NULL, getSortOrder(), NULL, 0, $dtend); + $bs->addBookmark("http://site1.com", $title, $desc, "status", array($tag1, $tag2), null, false, false, 1); - $b0 = $bookmarks['bookmarks'][0]; - $this->assertEquals($title, $b0['bTitle']); - $this->assertEquals($desc, $b0['bDescription']); - $this->assertEquals(str_replace(array('"', '\''), "_", $tag1), $b0['tags'][0]); - $this->assertEquals(str_replace(array('"', '\''), "_", $tag2), $b0['tags'][1]); - } - - public function testUnificationOfBookmarks() - { - $bs = $this->bs; + $bookmarks =& $bs->getBookmarks(0, 1, NULL, NULL, NULL, getSortOrder(), NULL, 0); - $bs->addBookmark("http://site1.com", "title", "description", "status", array('tag1'), null, false, false, 1); - $bs->addBookmark("http://site1.com", "title2", "description2", "status", array('tag2'), null, false, false, 2); + $b0 = $bookmarks['bookmarks'][0]; + $this->assertEquals($title, $b0['bTitle']); + $this->assertEquals($desc, $b0['bDescription']); + $this->assertEquals(str_replace(array('"', '\'', '/'), "_", $tag1), $b0['tags'][0]); + $this->assertEquals(str_replace(array('"', '\'', '/'), "_", $tag2), $b0['tags'][1]); + } - $bookmarks =& $bs->getBookmarks(0, 1, NULL, NULL, NULL, getSortOrder(), NULL, 0, $dtend); - $this->assertEquals(1, $bookmarks['total']); - } + public function testUnificationOfBookmarks() + { + $bs = $this->bs; - /*public function testSearchingBookmarksAccentsInsensible() - { - $bs = $this->bs; + $bs->addBookmark("http://site1.com", "title", "description", "status", array('tag1'), null, false, false, 1); + $bs->addBookmark("http://site1.com", "title2", "description2", "status", array('tag2'), null, false, false, 2); - $bs->addBookmark("http://site1.com", "title", "éèüaàê", "status", array('tag1'), null, false, false, 1); - $bookmarks =& $bs->getBookmarks(0, NULL, NULL, NULL, $terms = "eeaae"); //void - $this->assertEquals(0, $bookmarks['total']); - $bookmarks =& $bs->getBookmarks(0, NULL, NULL, NULL, $terms = "eeuaae"); - $this->assertEquals(1, $bookmarks['total']); - }*/ + $bookmarks =& $bs->getBookmarks(0, 1, NULL, NULL, NULL, getSortOrder(), NULL, 0); + $this->assertEquals(1, $bookmarks['total']); + } + + /*public function testSearchingBookmarksAccentsInsensible() + { + $bs = $this->bs; + + $bs->addBookmark("http://site1.com", "title", "éèüaàê", "status", array('tag1'), null, false, false, 1); + $bookmarks =& $bs->getBookmarks(0, NULL, NULL, NULL, $terms = "eeaae"); //void + $this->assertEquals(0, $bookmarks['total']); + $bookmarks =& $bs->getBookmarks(0, NULL, NULL, NULL, $terms = "eeuaae"); + $this->assertEquals(1, $bookmarks['total']); + }*/ } ?> diff --git a/tests/dox.html b/tests/dox.html new file mode 100644 index 0000000..98f6d00 --- /dev/null +++ b/tests/dox.html @@ -0,0 +1 @@ +

TagsCache