2008-02-13 17:34:18 +00:00
|
|
|
|
<?php
|
2009-10-25 15:31:31 +00:00
|
|
|
|
/**
|
|
|
|
|
* SemanticScuttle - your social bookmark manager.
|
|
|
|
|
*
|
|
|
|
|
* PHP version 5.
|
|
|
|
|
*
|
|
|
|
|
* @category Bookmarking
|
|
|
|
|
* @package SemanticScuttle
|
2009-10-26 06:39:59 +00:00
|
|
|
|
* @author Benjamin Huynh-Kim-Bang <mensonge@users.sourceforge.net>
|
2009-10-25 15:31:31 +00:00
|
|
|
|
* @author Christian Weiske <cweiske@cweiske.de>
|
2009-10-26 06:39:59 +00:00
|
|
|
|
* @author Eric Dane <ericdane@users.sourceforge.net>
|
2009-10-25 15:31:31 +00:00
|
|
|
|
* @license GPL http://www.gnu.org/licenses/gpl.html
|
|
|
|
|
* @link http://sourceforge.net/projects/semanticscuttle
|
|
|
|
|
*/
|
2008-02-13 17:34:18 +00:00
|
|
|
|
|
2009-10-25 15:31:31 +00:00
|
|
|
|
require_once 'prepare.php';
|
2008-02-13 17:34:18 +00:00
|
|
|
|
|
2009-10-25 15:31:31 +00:00
|
|
|
|
if (!defined('PHPUnit_MAIN_METHOD')) {
|
|
|
|
|
define('PHPUnit_MAIN_METHOD', 'CommonDescriptionTest::main');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Unit tests for the SemanticScuttle common description service.
|
|
|
|
|
*
|
|
|
|
|
* @category Bookmarking
|
|
|
|
|
* @package SemanticScuttle
|
2009-10-26 06:39:59 +00:00
|
|
|
|
* @author Benjamin Huynh-Kim-Bang <mensonge@users.sourceforge.net>
|
|
|
|
|
* @author Christian Weiske <cweiske@cweiske.de>
|
|
|
|
|
* @author Eric Dane <ericdane@users.sourceforge.net>
|
2009-10-25 15:31:31 +00:00
|
|
|
|
* @license GPL http://www.gnu.org/licenses/gpl.html
|
|
|
|
|
* @link http://sourceforge.net/projects/semanticscuttle
|
|
|
|
|
*/
|
|
|
|
|
class CommonDescriptionTest extends TestBase
|
2008-02-13 17:34:18 +00:00
|
|
|
|
{
|
|
|
|
|
protected $us;
|
|
|
|
|
protected $bs;
|
2008-04-21 08:44:44 +00:00
|
|
|
|
protected $b2ts;
|
2008-02-13 17:34:18 +00:00
|
|
|
|
protected $tts;
|
|
|
|
|
protected $tsts;
|
|
|
|
|
protected $cds;
|
2009-10-25 15:31:31 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 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__)
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
2009-10-25 19:35:48 +00:00
|
|
|
|
|
2008-02-13 17:34:18 +00:00
|
|
|
|
protected function setUp()
|
|
|
|
|
{
|
2009-10-25 15:31:31 +00:00
|
|
|
|
$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');
|
2009-10-25 19:35:48 +00:00
|
|
|
|
$this->tts->deleteAll();
|
2009-10-25 15:31:31 +00:00
|
|
|
|
$this->tsts =SemanticScuttle_Service_Factory::get('TagStat');
|
|
|
|
|
$this->tsts->deleteAll();
|
|
|
|
|
$this->cds =SemanticScuttle_Service_Factory::get('CommonDescription');
|
|
|
|
|
$this->cds->deleteAll();
|
2008-02-13 17:34:18 +00:00
|
|
|
|
}
|
2009-10-25 19:35:48 +00:00
|
|
|
|
|
2008-02-13 17:34:18 +00:00
|
|
|
|
public function testModifyDescription()
|
|
|
|
|
{
|
2009-10-25 19:35:48 +00:00
|
|
|
|
$cds = $this->cds;
|
|
|
|
|
|
|
|
|
|
$uId1 = 1;
|
|
|
|
|
$uId2 = 2;
|
|
|
|
|
$title1 = "title1";
|
|
|
|
|
$title2 = "title2";
|
|
|
|
|
$desc1 = "&é\"'(-è_çà)=´~#'#{{[\\\\[||`\^\^@^@}¹²¡×¿ ?./§µ%";
|
|
|
|
|
$desc2 = "æâ€êþÿûîîôôöŀï'üð’‘ßä«≤»©» ↓¿×÷¡¹²³";
|
|
|
|
|
$time1 = time();
|
|
|
|
|
$time2 = time()+200;
|
|
|
|
|
|
|
|
|
|
$tagDesc1 = array('cdId'=>1, 'tag'=>'taghouse', 'cdDescription'=>$desc1, 'uId'=>$uId1,'cdDatetime'=>$time1);
|
|
|
|
|
$tagDesc2 = array('cdId'=>2, 'tag'=>'taghouse', 'cdDescription'=>$desc2, 'uId'=>$uId2,'cdDatetime'=>$time2);
|
|
|
|
|
|
|
|
|
|
$cds->addTagDescription('taghouse', $desc1, $uId1, $time1);
|
|
|
|
|
$cds->addTagDescription('taghouse', $desc2, $uId2, $time2);
|
|
|
|
|
|
|
|
|
|
$desc = $cds->getLastTagDescription('taghouse');
|
|
|
|
|
$this->assertContains('taghouse', $desc);
|
|
|
|
|
$this->assertContains($desc2, $desc);
|
|
|
|
|
$this->assertContains(gmdate('Y-m-d H:i:s', $time2), $desc);
|
|
|
|
|
|
|
|
|
|
$desc = $cds->getAllTagsDescription('taghouse');
|
|
|
|
|
$this->assertContains($desc1, $desc[1]);
|
|
|
|
|
$this->assertContains(gmdate('Y-m-d H:i:s', $time1), $desc[1]);
|
|
|
|
|
$this->assertContains($desc2, $desc[0]);
|
|
|
|
|
$this->assertContains(gmdate('Y-m-d H:i:s', $time2), $desc[0]);
|
|
|
|
|
|
|
|
|
|
$desc = $cds->getDescriptionById(1);
|
|
|
|
|
$this->assertContains($desc1, $desc);
|
|
|
|
|
|
|
|
|
|
$bkDesc1 = array('cdId'=>3, 'bHash'=>'10', 'cdTitle'=>$title1, 'cdDescription'=>$desc1, 'uId'=>$uId1,'cdDatetime'=>$time1);
|
|
|
|
|
$bkDesc2 = array('cdId'=>4, 'bHash'=>'10', 'cdTitle'=>$title2, 'cdDescription'=>$desc2, 'uId'=>$uId2,'cdDatetime'=>$time2);
|
|
|
|
|
|
|
|
|
|
$cds->addBookmarkDescription(10, $title1, $desc1, $uId1, $time1);
|
|
|
|
|
$cds->addBookmarkDescription(10, $title2, $desc2, $uId2, $time2);
|
|
|
|
|
|
|
|
|
|
$desc = $cds->getLastBookmarkDescription(10);
|
|
|
|
|
$this->assertContains($title2, $desc);
|
|
|
|
|
$this->assertContains($desc2, $desc);
|
|
|
|
|
$this->assertContains(gmdate('Y-m-d H:i:s', $time2), $desc);
|
|
|
|
|
|
|
|
|
|
$desc = $cds->getAllBookmarksDescription(10);
|
|
|
|
|
$this->assertContains($title1, $desc[1]);
|
|
|
|
|
$this->assertContains($desc1, $desc[1]);
|
|
|
|
|
$this->assertContains(gmdate('Y-m-d H:i:s', $time1), $desc[1]);
|
|
|
|
|
$this->assertContains($title2, $desc[0]);
|
|
|
|
|
$this->assertContains($desc2, $desc[0]);
|
|
|
|
|
$this->assertContains(gmdate('Y-m-d H:i:s', $time2), $desc[0]);
|
|
|
|
|
|
|
|
|
|
$desc = $cds->getDescriptionById(3);
|
|
|
|
|
$this->assertContains($desc1, $desc);
|
2008-02-13 17:34:18 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
2009-10-25 15:31:31 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (PHPUnit_MAIN_METHOD == 'CommonDescriptionTest::main') {
|
|
|
|
|
CommonDescriptionTest::main();
|
|
|
|
|
}
|
2008-02-13 17:34:18 +00:00
|
|
|
|
?>
|