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
This commit is contained in:
parent
9a0aefc28b
commit
05defe72d8
10 changed files with 358 additions and 97 deletions
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
?>
|
|
@ -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;
|
||||
|
@ -16,11 +35,24 @@ class CommonDescriptionTest extends PHPUnit_Framework_TestCase
|
|||
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();
|
||||
|
@ -93,4 +125,9 @@ class CommonDescriptionTest extends PHPUnit_Framework_TestCase
|
|||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
if (PHPUnit_MAIN_METHOD == 'CommonDescriptionTest::main') {
|
||||
CommonDescriptionTest::main();
|
||||
}
|
||||
?>
|
||||
|
|
|
@ -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 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;
|
||||
|
@ -15,11 +34,25 @@ class SearchTest extends PHPUnit_Framework_TestCase
|
|||
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();
|
||||
}
|
||||
|
||||
?>
|
|
@ -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();
|
||||
}
|
||||
?>
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
?>
|
|
@ -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();
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
49
tests/TestBase.php
Normal file
49
tests/TestBase.php
Normal file
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
|
@ -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.
|
||||
|
@ -62,28 +61,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.
|
||||
*
|
||||
|
@ -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') {
|
||||
|
|
|
@ -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';
|
||||
?>
|
Loading…
Reference in a new issue