X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=tests%2Fbookmark%2FLinkDBTest.php;fp=tests%2FLinkDBTest.php;h=2990a6b56a0360756b3b8ee157fc7125e4372a21;hb=d9f6275ebca035fec8331652c677981056793ccc;hp=c763c0cbd5f34ce7797658b7bcae2e72829f3290;hpb=38672ba0d1c722e5d6d33a58255ceb55e9410e46;p=github%2Fshaarli%2FShaarli.git diff --git a/tests/LinkDBTest.php b/tests/bookmark/LinkDBTest.php similarity index 90% rename from tests/LinkDBTest.php rename to tests/bookmark/LinkDBTest.php index c763c0cb..2990a6b5 100644 --- a/tests/LinkDBTest.php +++ b/tests/bookmark/LinkDBTest.php @@ -3,9 +3,14 @@ * Link datastore tests */ -require_once 'application/Cache.php'; -require_once 'application/FileUtils.php'; -require_once 'application/LinkDB.php'; +namespace Shaarli\Bookmark; + +use DateTime; +use ReferenceLinkDB; +use ReflectionClass; +use Shaarli; + +require_once 'application/feed/Cache.php'; require_once 'application/Utils.php'; require_once 'tests/utils/ReferenceLinkDB.php'; @@ -13,7 +18,7 @@ require_once 'tests/utils/ReferenceLinkDB.php'; /** * Unitary tests for LinkDB */ -class LinkDBTest extends PHPUnit_Framework_TestCase +class LinkDBTest extends \PHPUnit\Framework\TestCase { // datastore to test write operations protected static $testDatastore = 'sandbox/datastore.php'; @@ -73,7 +78,7 @@ class LinkDBTest extends PHPUnit_Framework_TestCase */ protected static function getMethod($name) { - $class = new ReflectionClass('LinkDB'); + $class = new ReflectionClass('Shaarli\Bookmark\LinkDB'); $method = $class->getMethod($name); $method->setAccessible(true); return $method; @@ -100,7 +105,7 @@ class LinkDBTest extends PHPUnit_Framework_TestCase /** * Attempt to instantiate a LinkDB whereas the datastore is not writable * - * @expectedException IOException + * @expectedException Shaarli\Exceptions\IOException * @expectedExceptionMessageRegExp /Error accessing "null"/ */ public function testConstructDatastoreNotWriteable() @@ -187,12 +192,12 @@ class LinkDBTest extends PHPUnit_Framework_TestCase $link = array( 'id' => 42, - 'title'=>'an additional link', - 'url'=>'http://dum.my', - 'description'=>'One more', - 'private'=>0, - 'created'=> DateTime::createFromFormat(LinkDB::LINK_DATE_FORMAT, '20150518_190000'), - 'tags'=>'unit test' + 'title' => 'an additional link', + 'url' => 'http://dum.my', + 'description' => 'One more', + 'private' => 0, + 'created' => DateTime::createFromFormat(LinkDB::LINK_DATE_FORMAT, '20150518_190000'), + 'tags' => 'unit test' ); $testDB[$link['id']] = $link; $testDB->save('tests'); @@ -356,36 +361,6 @@ class LinkDBTest extends PHPUnit_Framework_TestCase ); } - /** - * Test real_url without redirector. - */ - public function testLinkRealUrlWithoutRedirector() - { - $db = new LinkDB(self::$testDatastore, false, false); - foreach ($db as $link) { - $this->assertEquals($link['url'], $link['real_url']); - } - } - - /** - * Test real_url with redirector. - */ - public function testLinkRealUrlWithRedirector() - { - $redirector = 'http://redirector.to?'; - $db = new LinkDB(self::$testDatastore, false, false, $redirector); - foreach ($db as $link) { - $this->assertStringStartsWith($redirector, $link['real_url']); - $this->assertNotFalse(strpos($link['real_url'], urlencode('://'))); - } - - $db = new LinkDB(self::$testDatastore, false, false, $redirector, false); - foreach ($db as $link) { - $this->assertStringStartsWith($redirector, $link['real_url']); - $this->assertFalse(strpos($link['real_url'], urlencode('://'))); - } - } - /** * Test filter with string. */ @@ -451,7 +426,7 @@ class LinkDBTest extends PHPUnit_Framework_TestCase /** * Test filterHash() with an invalid smallhash. * - * @expectedException LinkNotFoundException + * @expectedException \Shaarli\Bookmark\Exception\LinkNotFoundException */ public function testFilterHashInValid1() { @@ -462,7 +437,7 @@ class LinkDBTest extends PHPUnit_Framework_TestCase /** * Test filterHash() with an empty smallhash. * - * @expectedException LinkNotFoundException + * @expectedException \Shaarli\Bookmark\Exception\LinkNotFoundException */ public function testFilterHashInValid() { @@ -511,7 +486,7 @@ class LinkDBTest extends PHPUnit_Framework_TestCase public function testRenameTagCaseSensitive() { self::$refDB->write(self::$testDatastore); - $linkDB = new LinkDB(self::$testDatastore, true, false, ''); + $linkDB = new LinkDB(self::$testDatastore, true, false); $res = $linkDB->renameTag('sTuff', 'Taz'); $this->assertEquals(1, count($res));