return;
}
+ $this->container->updater->setBasePath($this->container->basePath);
$newUpdates = $this->container->updater->update();
if (!empty($newUpdates)) {
$this->container->updater->writeUpdates(
&& 1 === preg_match('/^\?([a-zA-Z0-9-_@]{6})($|&|#)/', $bookmark->getUrl(), $match)
) {
$updated = true;
- $bookmark = $bookmark->setUrl($this->basePath . '/shaare/' . $match[1]);
+ $bookmark = $bookmark->setUrl('/shaare/' . $match[1]);
$this->bookmarkService->set($bookmark, false);
}
$this->assertEquals($id, $data['id']);
// Check link elements
- $this->assertEquals('http://domain.tld/?WDWyig', $data['url']);
+ $this->assertEquals('http://domain.tld/shaare/WDWyig', $data['url']);
$this->assertEquals('WDWyig', $data['shorturl']);
$this->assertEquals('Link title: @website', $data['title']);
$this->assertEquals(
// Check first element fields
$first = $data[2];
- $this->assertEquals('http://domain.tld/?WDWyig', $first['url']);
+ $this->assertEquals('http://domain.tld/shaare/WDWyig', $first['url']);
$this->assertEquals('WDWyig', $first['shorturl']);
$this->assertEquals('Link title: @website', $first['title']);
$this->assertEquals(
$bookmark = $this->privateLinkDB->get(42);
$this->assertEquals(42, $bookmark->getId());
- $this->assertEquals('?WDWyig', $bookmark->getUrl());
+ $this->assertEquals('/shaare/WDWyig', $bookmark->getUrl());
$this->assertEquals('1eYJ1Q', $bookmark->getShortUrl());
$this->assertEquals('Note: I have a big ID but an old date', $bookmark->getTitle());
$this->assertEquals('Used to test bookmarks reordering.', $bookmark->getDescription());
$bookmark = $this->privateLinkDB->get(42);
$this->assertEquals(42, $bookmark->getId());
- $this->assertEquals('?WDWyig', $bookmark->getUrl());
+ $this->assertEquals('/shaare/WDWyig', $bookmark->getUrl());
$this->assertEquals('1eYJ1Q', $bookmark->getShortUrl());
$this->assertEquals('Note: I have a big ID but an old date', $bookmark->getTitle());
$this->assertEquals('Used to test bookmarks reordering.', $bookmark->getDescription());
$link = $data['links'][array_keys($data['links'])[2]];
$this->assertEquals(41, $link['id']);
$this->assertEquals(DateTime::createFromFormat(Bookmark::LINK_DATE_FORMAT, '20150310_114651'), $link['created']);
- $this->assertEquals('http://host.tld/?WDWyig', $link['guid']);
- $this->assertEquals('http://host.tld/?WDWyig', $link['url']);
+ $this->assertEquals('http://host.tld/shaare/WDWyig', $link['guid']);
+ $this->assertEquals('http://host.tld/shaare/WDWyig', $link['url']);
$this->assertRegExp('/Tue, 10 Mar 2015 11:46:51 \+\d{4}/', $link['pub_iso_date']);
$pub = DateTime::createFromFormat(DateTime::RSS, $link['pub_iso_date']);
$up = DateTime::createFromFormat(DateTime::ATOM, $link['up_iso_date']);
$this->assertEquals($pub, $up);
$this->assertContains('Stallman has a beard', $link['description']);
$this->assertContains('Permalink', $link['description']);
- $this->assertContains('http://host.tld/?WDWyig', $link['description']);
+ $this->assertContains('http://host.tld/shaare/WDWyig', $link['description']);
$this->assertEquals(1, count($link['taglist']));
$this->assertEquals('sTuff', $link['taglist'][0]);
$link = $data['links'][array_keys($data['links'])[2]];
$this->assertEquals(41, $link['id']);
$this->assertEquals(DateTime::createFromFormat(Bookmark::LINK_DATE_FORMAT, '20150310_114651'), $link['created']);
- $this->assertEquals('http://host.tld/?WDWyig', $link['guid']);
- $this->assertEquals('http://host.tld/?WDWyig', $link['url']);
+ $this->assertEquals('http://host.tld/shaare/WDWyig', $link['guid']);
+ $this->assertEquals('http://host.tld/shaare/WDWyig', $link['url']);
$this->assertContains('Direct link', $link['description']);
- $this->assertContains('http://host.tld/?WDWyig', $link['description']);
+ $this->assertContains('http://host.tld/shaare/WDWyig', $link['description']);
// Second link is a direct link
$link = $data['links'][array_keys($data['links'])[3]];
$this->assertEquals(8, $link['id']);
$this->assertEquals(DateTime::createFromFormat(Bookmark::LINK_DATE_FORMAT, '20150310_114633'), $link['created']);
- $this->assertEquals('http://host.tld/?RttfEw', $link['guid']);
+ $this->assertEquals('http://host.tld/shaare/RttfEw', $link['guid']);
$this->assertEquals('https://static.fsf.org/nosvn/faif-2.0.pdf', $link['url']);
$this->assertContains('Direct link', $link['description']);
$this->assertContains('https://static.fsf.org/nosvn/faif-2.0.pdf', $link['description']);
// Test first link (note link)
$link = $data['links'][array_keys($data['links'])[2]];
- $this->assertEquals('http://host.tld:8080/~user/shaarli/?WDWyig', $link['guid']);
- $this->assertEquals('http://host.tld:8080/~user/shaarli/?WDWyig', $link['url']);
+ $this->assertEquals('http://host.tld:8080/~user/shaarli/shaare/WDWyig', $link['guid']);
+ $this->assertEquals('http://host.tld:8080/~user/shaarli/shaare/WDWyig', $link['url']);
$this->assertContains('http://host.tld:8080/~user/shaarli/./add-tag/hashtag', $link['description']);
}
}
''
);
$this->assertEquals(
- '?WDWyig',
+ '/shaare/WDWyig',
$links[2]['url']
);
}
$indexUrl
);
$this->assertEquals(
- $indexUrl . '?WDWyig',
+ $indexUrl . 'shaare/WDWyig',
$links[2]['url']
);
}
namespace Shaarli\Updater;
use Exception;
+use PHPUnit\Framework\TestCase;
use Shaarli\Bookmark\BookmarkFileService;
use Shaarli\Bookmark\BookmarkServiceInterface;
use Shaarli\Config\ConfigManager;
* Class UpdaterTest.
* Runs unit tests against the updater class.
*/
-class UpdaterTest extends \PHPUnit\Framework\TestCase
+class UpdaterTest extends TestCase
{
/**
* @var string Path to test datastore.
public function testUpdateMethodRelativeHomeLinkDoNotRename(): void
{
- $this->updater->setBasePath('/subfolder');
$this->conf->set('general.header_link', '~/my-blog');
$this->updater->updateMethodRelativeHomeLink();
public function testUpdateMethodMigrateExistingNotesUrl(): void
{
- $this->updater->setBasePath('/subfolder');
-
$this->updater->updateMethodMigrateExistingNotesUrl();
static::assertSame($this->refDB->getLinks()[0]->getUrl(), $this->bookmarkService->get(0)->getUrl());
static::assertSame($this->refDB->getLinks()[7]->getUrl(), $this->bookmarkService->get(7)->getUrl());
static::assertSame($this->refDB->getLinks()[8]->getUrl(), $this->bookmarkService->get(8)->getUrl());
static::assertSame($this->refDB->getLinks()[9]->getUrl(), $this->bookmarkService->get(9)->getUrl());
- static::assertSame('/subfolder/shaare/WDWyig', $this->bookmarkService->get(42)->getUrl());
- static::assertSame('/subfolder/shaare/WDWyig', $this->bookmarkService->get(41)->getUrl());
- static::assertSame('/subfolder/shaare/0gCTjQ', $this->bookmarkService->get(10)->getUrl());
- static::assertSame('/subfolder/shaare/PCRizQ', $this->bookmarkService->get(11)->getUrl());
+ static::assertSame('/shaare/WDWyig', $this->bookmarkService->get(42)->getUrl());
+ static::assertSame('/shaare/WDWyig', $this->bookmarkService->get(41)->getUrl());
+ static::assertSame('/shaare/0gCTjQ', $this->bookmarkService->get(10)->getUrl());
+ static::assertSame('/shaare/PCRizQ', $this->bookmarkService->get(11)->getUrl());
}
}
$this->addLink(
11,
'Pined older',
- '?PCRizQ',
+ '/shaare/PCRizQ',
'This is an older pinned link',
0,
DateTime::createFromFormat(Bookmark::LINK_DATE_FORMAT, '20100309_101010'),
$this->addLink(
10,
'Pined',
- '?0gCTjQ',
+ '/shaare/0gCTjQ',
'This is a pinned link',
0,
DateTime::createFromFormat(Bookmark::LINK_DATE_FORMAT, '20121207_152312'),
$this->addLink(
41,
'Link title: @website',
- '?WDWyig',
+ '/shaare/WDWyig',
'Stallman has a beard and is part of the Free Software Foundation (or not). Seriously, read this. #hashtag',
0,
DateTime::createFromFormat(Bookmark::LINK_DATE_FORMAT, '20150310_114651'),
$this->addLink(
42,
'Note: I have a big ID but an old date',
- '?WDWyig',
+ '/shaare/WDWyig',
'Used to test bookmarks reordering.',
0,
DateTime::createFromFormat(Bookmark::LINK_DATE_FORMAT, '20100310_101010'),