diff options
author | cweiske <cweiske@b3834d28-1941-0410-a4f8-b48e95affb8f> | 2009-10-25 15:31:31 +0000 |
---|---|---|
committer | cweiske <cweiske@b3834d28-1941-0410-a4f8-b48e95affb8f> | 2009-10-25 15:31:31 +0000 |
commit | 05defe72d8739c0642c506175c0ad4de2293fb99 (patch) | |
tree | d160853768776e399c95d3cf83ca3fbf24481325 /tests | |
parent | 9a0aefc28bba04f674d901c6ffd6a9e63628feef (diff) | |
download | semanticscuttle-05defe72d8739c0642c506175c0ad4de2293fb99.tar.gz semanticscuttle-05defe72d8739c0642c506175c0ad4de2293fb99.tar.bz2 |
introduce testbase class and make all tests runnable standalone
git-svn-id: https://semanticscuttle.svn.sourceforge.net/svnroot/semanticscuttle/trunk@410 b3834d28-1941-0410-a4f8-b48e95affb8f
Diffstat (limited to 'tests')
-rw-r--r-- | tests/AllTests.php | 6 | ||||
-rw-r--r-- | tests/BookmarkTest.php (renamed from tests/BookmarksTest.php) | 66 | ||||
-rw-r--r-- | tests/CommonDescriptionTest.php | 79 | ||||
-rw-r--r-- | tests/SearchHistoryTest.php (renamed from tests/SearchTest.php) | 59 | ||||
-rw-r--r-- | tests/Tag2TagTest.php | 57 | ||||
-rw-r--r-- | tests/TagTest.php (renamed from tests/TagsTest.php) | 58 | ||||
-rw-r--r-- | tests/TagsCacheTest.php | 51 | ||||
-rw-r--r-- | tests/TestBase.php | 49 | ||||
-rw-r--r-- | tests/VoteTest.php | 27 | ||||
-rw-r--r-- | tests/prepare.php | 3 |
10 files changed, 358 insertions, 97 deletions
diff --git a/tests/AllTests.php b/tests/AllTests.php index b1e13b4..4507a5a 100644 --- a/tests/AllTests.php +++ b/tests/AllTests.php @@ -32,12 +32,12 @@ class AllTests extends PHPUnit_Framework_TestSuite { $suite = new AllTests(); $tdir = dirname(__FILE__); - $suite->addTestFile($tdir . '/BookmarksTest.php'); + $suite->addTestFile($tdir . '/BookmarkTest.php'); $suite->addTestFile($tdir . '/Tag2TagTest.php'); $suite->addTestFile($tdir . '/TagsCacheTest.php'); $suite->addTestFile($tdir . '/CommonDescriptionTest.php'); - $suite->addTestFile($tdir . '/SearchTest.php'); - $suite->addTestFile($tdir . '/TagsTest.php'); + $suite->addTestFile($tdir . '/SearchHistoryTest.php'); + $suite->addTestFile($tdir . '/TagTest.php'); $suite->addTestFile($tdir . '/VoteTest.php'); return $suite; } diff --git a/tests/BookmarksTest.php b/tests/BookmarkTest.php index 7520058..f42880a 100644 --- a/tests/BookmarksTest.php +++ b/tests/BookmarkTest.php @@ -1,25 +1,57 @@ <?php -require_once 'PHPUnit/Framework.php'; - -/* - To launch this test, type the following line into a shell - into the tests/ directory : - phpunit BookmarksTest tests/boomarksTest.php +/** + * SemanticScuttle - your social bookmark manager. + * + * PHP version 5. + * + * @category Bookmarking + * @package SemanticScuttle + * @author Christian Weiske <cweiske@cweiske.de> + * @license GPL http://www.gnu.org/licenses/gpl.html + * @link http://sourceforge.net/projects/semanticscuttle */ -class BookmarksTest extends PHPUnit_Framework_TestCase +require_once 'prepare.php'; + +if (!defined('PHPUnit_MAIN_METHOD')) { + define('PHPUnit_MAIN_METHOD', 'BookmarkTest::main'); +} + +/** + * Unit tests for the SemanticScuttle bookmark service. + * + * @category Bookmarking + * @package SemanticScuttle + * @author Christian Weiske <cweiske@cweiske.de> + * @license GPL http://www.gnu.org/licenses/gpl.html + * @link http://sourceforge.net/projects/semanticscuttle + */ +class BookmarkTest extends TestBase { protected $us; protected $bs; protected $ts; protected $tts; + + + /** + * Used to run this test class standalone + * + * @return void + */ + public static function main() + { + require_once 'PHPUnit/TextUI/TestRunner.php'; + PHPUnit_TextUI_TestRunner::run( + new PHPUnit_Framework_TestSuite(__CLASS__) + ); + } + + + protected function setUp() { - global $dbhost, $dbuser, $dbpass, $dbname, $dbport, $dbpersist, $dbtype, - $tableprefix, $TEMPLATES_DIR, $filetypes, $debugMode; - require_once dirname(__FILE__) . '/../src/SemanticScuttle/header.php'; - $this->us =SemanticScuttle_Service_Factory::get('User'); $this->bs =SemanticScuttle_Service_Factory::get('Bookmark'); $this->bs->deleteAll(); @@ -72,5 +104,17 @@ class BookmarksTest extends PHPUnit_Framework_TestCase $this->assertEquals(1, $bookmarks['total']); }*/ + + + public function testDeleteBookmark() + { + //FIXME + } + +} + + +if (PHPUnit_MAIN_METHOD == 'BookmarkTest::main') { + BookmarkTest::main(); } ?> diff --git a/tests/CommonDescriptionTest.php b/tests/CommonDescriptionTest.php index 3f6917e..93fcc53 100644 --- a/tests/CommonDescriptionTest.php +++ b/tests/CommonDescriptionTest.php @@ -1,13 +1,32 @@ <?php -require_once 'PHPUnit/Framework.php'; +/** + * SemanticScuttle - your social bookmark manager. + * + * PHP version 5. + * + * @category Bookmarking + * @package SemanticScuttle + * @author Christian Weiske <cweiske@cweiske.de> + * @license GPL http://www.gnu.org/licenses/gpl.html + * @link http://sourceforge.net/projects/semanticscuttle + */ -/* -To launch this test, type the following line into a shell -at the root of the scuttlePlus directory : - phpunit CommonDescriptionTest tests/commonDescriptionTest.php -*/ +require_once 'prepare.php'; -class CommonDescriptionTest extends PHPUnit_Framework_TestCase +if (!defined('PHPUnit_MAIN_METHOD')) { + define('PHPUnit_MAIN_METHOD', 'CommonDescriptionTest::main'); +} + +/** + * Unit tests for the SemanticScuttle common description service. + * + * @category Bookmarking + * @package SemanticScuttle + * @author Christian Weiske <cweiske@cweiske.de> + * @license GPL http://www.gnu.org/licenses/gpl.html + * @link http://sourceforge.net/projects/semanticscuttle + */ +class CommonDescriptionTest extends TestBase { protected $us; protected $bs; @@ -15,23 +34,36 @@ class CommonDescriptionTest extends PHPUnit_Framework_TestCase protected $tts; protected $tsts; protected $cds; + + + + /** + * Used to run this test class standalone + * + * @return void + */ + public static function main() + { + require_once 'PHPUnit/TextUI/TestRunner.php'; + PHPUnit_TextUI_TestRunner::run( + new PHPUnit_Framework_TestSuite(__CLASS__) + ); + } + protected function setUp() { - global $dbhost, $dbuser, $dbpass, $dbname, $dbport, $dbpersist, $dbtype, $tableprefix; - require_once dirname(__FILE__) . '/../src/SemanticScuttle/header.php'; - - $this->us =SemanticScuttle_Service_Factory::get('User'); - $this->bs =SemanticScuttle_Service_Factory::get('Bookmark'); - $this->bs->deleteAll(); - $this->b2ts =SemanticScuttle_Service_Factory::get('Bookmark2Tag'); - $this->b2ts->deleteAll(); - $this->tts =SemanticScuttle_Service_Factory::get('Tag2Tag'); - $this->tts->deleteAll(); - $this->tsts =SemanticScuttle_Service_Factory::get('TagStat'); - $this->tsts->deleteAll(); - $this->cds =SemanticScuttle_Service_Factory::get('CommonDescription'); - $this->cds->deleteAll(); + $this->us =SemanticScuttle_Service_Factory::get('User'); + $this->bs =SemanticScuttle_Service_Factory::get('Bookmark'); + $this->bs->deleteAll(); + $this->b2ts =SemanticScuttle_Service_Factory::get('Bookmark2Tag'); + $this->b2ts->deleteAll(); + $this->tts =SemanticScuttle_Service_Factory::get('Tag2Tag'); + $this->tts->deleteAll(); + $this->tsts =SemanticScuttle_Service_Factory::get('TagStat'); + $this->tsts->deleteAll(); + $this->cds =SemanticScuttle_Service_Factory::get('CommonDescription'); + $this->cds->deleteAll(); } public function testModifyDescription() @@ -93,4 +125,9 @@ class CommonDescriptionTest extends PHPUnit_Framework_TestCase } } + + +if (PHPUnit_MAIN_METHOD == 'CommonDescriptionTest::main') { + CommonDescriptionTest::main(); +} ?> diff --git a/tests/SearchTest.php b/tests/SearchHistoryTest.php index 3aa49de..2421a20 100644 --- a/tests/SearchTest.php +++ b/tests/SearchHistoryTest.php @@ -1,25 +1,58 @@ <?php -require_once 'PHPUnit/Framework.php'; +/** + * SemanticScuttle - your social bookmark manager. + * + * PHP version 5. + * + * @category Bookmarking + * @package SemanticScuttle + * @author Christian Weiske <cweiske@cweiske.de> + * @license GPL http://www.gnu.org/licenses/gpl.html + * @link http://sourceforge.net/projects/semanticscuttle + */ -/* -To launch this test, type the following line into a shell -at the root of the scuttlePlus directory : - phpunit SearchTest tests/searchTest.php -*/ +require_once 'prepare.php'; -class SearchTest extends PHPUnit_Framework_TestCase +if (!defined('PHPUnit_MAIN_METHOD')) { + define('PHPUnit_MAIN_METHOD', 'SearchHistoryTest::main'); +} + +/** + * Unit tests for the SemanticScuttle search history service. + * + * @category Bookmarking + * @package SemanticScuttle + * @author Christian Weiske <cweiske@cweiske.de> + * @license GPL http://www.gnu.org/licenses/gpl.html + * @link http://sourceforge.net/projects/semanticscuttle + */ +class SearchHistoryTest extends TestBase { protected $us; protected $bs; protected $b2ts; protected $tts; protected $shs; + + + + /** + * Used to run this test class standalone + * + * @return void + */ + public static function main() + { + require_once 'PHPUnit/TextUI/TestRunner.php'; + PHPUnit_TextUI_TestRunner::run( + new PHPUnit_Framework_TestSuite(__CLASS__) + ); + } + + protected function setUp() { - global $dbhost, $dbuser, $dbpass, $dbname, $dbport, $dbpersist, $dbtype, $tableprefix; - require_once dirname(__FILE__) . '/../src/SemanticScuttle/header.php'; - $this->us =SemanticScuttle_Service_Factory::get('User'); $this->bs =SemanticScuttle_Service_Factory::get('Bookmark'); $this->bs->deleteAll(); @@ -77,4 +110,10 @@ class SearchTest extends PHPUnit_Framework_TestCase $this->assertSame(2, count($searches)); } } + + +if (PHPUnit_MAIN_METHOD == 'SearchHistoryTest::main') { + SearchHistoryTest::main(); +} + ?> diff --git a/tests/Tag2TagTest.php b/tests/Tag2TagTest.php index 8b23040..8a19823 100644 --- a/tests/Tag2TagTest.php +++ b/tests/Tag2TagTest.php @@ -1,24 +1,57 @@ <?php -require_once 'PHPUnit/Framework.php'; - -/* - To launch this test, type the following line into a shell - at the root of the scuttlePlus directory : - phpunit Tag2TagTest tests/tag2TagTest.php +/** + * SemanticScuttle - your social bookmark manager. + * + * PHP version 5. + * + * @category Bookmarking + * @package SemanticScuttle + * @author Christian Weiske <cweiske@cweiske.de> + * @license GPL http://www.gnu.org/licenses/gpl.html + * @link http://sourceforge.net/projects/semanticscuttle */ -class Tag2TagTest extends PHPUnit_Framework_TestCase +require_once 'prepare.php'; + +if (!defined('PHPUnit_MAIN_METHOD')) { + define('PHPUnit_MAIN_METHOD', 'Tag2TagTest::main'); +} + +/** + * Unit tests for the SemanticScuttle tag2tag service. + * + * @category Bookmarking + * @package SemanticScuttle + * @author Christian Weiske <cweiske@cweiske.de> + * @license GPL http://www.gnu.org/licenses/gpl.html + * @link http://sourceforge.net/projects/semanticscuttle + */ +class Tag2TagTest extends TestBase { protected $us; protected $bs; protected $b2ts; protected $tts; + + + /** + * Used to run this test class standalone + * + * @return void + */ + public static function main() + { + require_once 'PHPUnit/TextUI/TestRunner.php'; + PHPUnit_TextUI_TestRunner::run( + new PHPUnit_Framework_TestSuite(__CLASS__) + ); + } + + + protected function setUp() { - global $dbhost, $dbuser, $dbpass, $dbname, $dbport, $dbpersist, $dbtype, $tableprefix; - require_once dirname(__FILE__) . '/../src/SemanticScuttle/header.php'; - $this->us =SemanticScuttle_Service_Factory::get('User'); $this->bs =SemanticScuttle_Service_Factory::get('Bookmark'); $this->bs->deleteAll(); @@ -482,4 +515,8 @@ class Tag2TagTest extends PHPUnit_Framework_TestCase }*/ } + +if (PHPUnit_MAIN_METHOD == 'Tag2TagTest::main') { + Tag2TagTest::main(); +} ?> diff --git a/tests/TagsTest.php b/tests/TagTest.php index f07e04f..2cc6d44 100644 --- a/tests/TagsTest.php +++ b/tests/TagTest.php @@ -1,21 +1,54 @@ <?php -require_once 'PHPUnit/Framework.php'; - -/* - To launch this test, type the following line into a shell - at the root of the scuttlePlus directory : - phpunit TagsTest tests/tagsTest.php +/** + * SemanticScuttle - your social bookmark manager. + * + * PHP version 5. + * + * @category Bookmarking + * @package SemanticScuttle + * @author Christian Weiske <cweiske@cweiske.de> + * @license GPL http://www.gnu.org/licenses/gpl.html + * @link http://sourceforge.net/projects/semanticscuttle */ -class TagsTest extends PHPUnit_Framework_TestCase +require_once 'prepare.php'; + +if (!defined('PHPUnit_MAIN_METHOD')) { + define('PHPUnit_MAIN_METHOD', 'TagTest::main'); +} + +/** + * Unit tests for the SemanticScuttle tag service. + * + * @category Bookmarking + * @package SemanticScuttle + * @author Christian Weiske <cweiske@cweiske.de> + * @license GPL http://www.gnu.org/licenses/gpl.html + * @link http://sourceforge.net/projects/semanticscuttle + */ +class TagTest extends TestBase { protected $ts; + + + /** + * Used to run this test class standalone + * + * @return void + */ + public static function main() + { + require_once 'PHPUnit/TextUI/TestRunner.php'; + PHPUnit_TextUI_TestRunner::run( + new PHPUnit_Framework_TestSuite(__CLASS__) + ); + } + + + protected function setUp() { - global $dbhost, $dbuser, $dbpass, $dbname, $dbport, $dbpersist, $dbtype, $tableprefix; - require_once dirname(__FILE__) . '/../src/SemanticScuttle/header.php'; - $this->ts =SemanticScuttle_Service_Factory::get('Tag'); $this->ts->deleteAll(); $this->us =SemanticScuttle_Service_Factory::get('User'); @@ -73,4 +106,9 @@ class TagsTest extends PHPUnit_Framework_TestCase } } + + +if (PHPUnit_MAIN_METHOD == 'TagTest::main') { + TagTest::main(); +} ?> diff --git a/tests/TagsCacheTest.php b/tests/TagsCacheTest.php index 8e15f2d..9230f1c 100644 --- a/tests/TagsCacheTest.php +++ b/tests/TagsCacheTest.php @@ -1,12 +1,31 @@ <?php -require_once 'PHPUnit/Framework.php'; - -/* - To launch this test, type the following line into a shell - at the root of the scuttlePlus directory : - phpunit TagsCacheTest tests/tagsCacheTest.php +/** + * SemanticScuttle - your social bookmark manager. + * + * PHP version 5. + * + * @category Bookmarking + * @package SemanticScuttle + * @author Christian Weiske <cweiske@cweiske.de> + * @license GPL http://www.gnu.org/licenses/gpl.html + * @link http://sourceforge.net/projects/semanticscuttle */ +require_once 'prepare.php'; + +if (!defined('PHPUnit_MAIN_METHOD')) { + define('PHPUnit_MAIN_METHOD', 'TagsCacheTest::main'); +} + +/** + * Unit tests for the SemanticScuttle tags cache service. + * + * @category Bookmarking + * @package SemanticScuttle + * @author Christian Weiske <cweiske@cweiske.de> + * @license GPL http://www.gnu.org/licenses/gpl.html + * @link http://sourceforge.net/projects/semanticscuttle + */ class TagsCacheTest extends PHPUnit_Framework_TestCase { protected $us; @@ -14,6 +33,21 @@ class TagsCacheTest extends PHPUnit_Framework_TestCase protected $b2ts; protected $tts; + + + /** + * Used to run this test class standalone + * + * @return void + */ + public static function main() + { + require_once 'PHPUnit/TextUI/TestRunner.php'; + PHPUnit_TextUI_TestRunner::run( + new PHPUnit_Framework_TestSuite(__CLASS__) + ); + } + protected function setUp() { global $dbhost, $dbuser, $dbpass, $dbname, $dbport, $dbpersist, $dbtype, $tableprefix, $TEMPLATES_DIR, $debugMode; @@ -173,4 +207,9 @@ class TagsCacheTest extends PHPUnit_Framework_TestCase $this->assertEquals(array(), $tcs->getSynonyms('d', 1)); } } + +if (PHPUnit_MAIN_METHOD == 'TagsCacheTest::main') { + TagsCacheTest::main(); +} + ?> diff --git a/tests/TestBase.php b/tests/TestBase.php new file mode 100644 index 0000000..dc5643f --- /dev/null +++ b/tests/TestBase.php @@ -0,0 +1,49 @@ +<?php +/** + * SemanticScuttle - your social bookmark manager. + * + * PHP version 5. + * + * @category Bookmarking + * @package SemanticScuttle + * @author Christian Weiske <cweiske@cweiske.de> + * @license GPL http://www.gnu.org/licenses/gpl.html + * @link http://sourceforge.net/projects/semanticscuttle + */ + +require_once 'PHPUnit/Framework.php'; + +/** + * Base unittest class that provides several helper methods. + * + * @category Bookmarking + * @package SemanticScuttle + * @author Christian Weiske <cweiske@cweiske.de> + * @license GPL http://www.gnu.org/licenses/gpl.html + * @link http://sourceforge.net/projects/semanticscuttle + */ +class TestBase extends PHPUnit_Framework_TestCase +{ + /** + * Create a new bookmark. + * + * @return integer ID of bookmark + */ + protected function addBookmark() + { + $bs = SemanticScuttle_Service_Factory::get('Bookmark'); + $rand = rand(); + $bid = $bs->addBookmark( + 'http://example.org/' . $rand, + 'unittest bookmark #' . $rand, + 'description', + null, + 0, + array('unittest') + ); + return $bid; + } + +} + +?>
\ No newline at end of file diff --git a/tests/VoteTest.php b/tests/VoteTest.php index 0196071..90611d1 100644 --- a/tests/VoteTest.php +++ b/tests/VoteTest.php @@ -12,7 +12,6 @@ */ require_once 'prepare.php'; -require_once 'PHPUnit/Framework.php'; if (!defined('PHPUnit_MAIN_METHOD')) { define('PHPUnit_MAIN_METHOD', 'VoteTest::main'); @@ -27,7 +26,7 @@ if (!defined('PHPUnit_MAIN_METHOD')) { * @license GPL http://www.gnu.org/licenses/gpl.html * @link http://sourceforge.net/projects/semanticscuttle */ -class VoteTest extends PHPUnit_Framework_TestCase +class VoteTest extends TestBase { /** * Vote service instance to test. @@ -63,28 +62,6 @@ class VoteTest extends PHPUnit_Framework_TestCase /** - * Create a new bookmark. - * - * @return integer ID of bookmark - */ - protected function addBookmark() - { - $bs = SemanticScuttle_Service_Factory::get('Bookmark'); - $rand = rand(); - $bid = $bs->addBookmark( - 'http://example.org/' . $rand, - 'unittest bookmark #' . $rand, - 'description', - null, - 0, - array('unittest') - ); - return $bid; - } - - - - /** * Test getVoting() when no votes have been cast. * * @return void @@ -345,7 +322,7 @@ class VoteTest extends PHPUnit_Framework_TestCase $this->assertEquals(-1, $this->vs->getVote($bid, $uid)); } -}//class VoteTest extends PHPUnit_Framework_TestCase +}//class VoteTest extends TestBase if (PHPUnit_MAIN_METHOD == 'VoteTest::main') { diff --git a/tests/prepare.php b/tests/prepare.php index 73d804d..095cf36 100644 --- a/tests/prepare.php +++ b/tests/prepare.php @@ -5,5 +5,6 @@ $_SERVER['HTTP_HOST'] = 'http://localhost/'; define('UNIT_TEST_MODE', true); -require_once dirname(__FILE__) . '/../src/SemanticScuttle/header.php' +require_once dirname(__FILE__) . '/../src/SemanticScuttle/header.php'; +require_once dirname(__FILE__) . '/TestBase.php'; ?>
\ No newline at end of file |