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.
/**
* Executed before each test.
*/
- public function setUp()
+ protected function setUp(): void
{
$this->refDB = new \ReferenceLinkDB();
$this->refDB->write(self::$testDatastore);
* Test errors in UpdaterUtils::write_updates_file(): empty updates file.
*
* @expectedException Exception
- * @expectedExceptionMessageRegExp /Updates file path is not set(.*)/
*/
public function testWriteEmptyUpdatesFile()
{
+ $this->expectExceptionMessageRegExp('/Updates file path is not set(.*)/');
+
UpdaterUtils::write_updates_file('', array('test'));
}
* Test errors in UpdaterUtils::write_updates_file(): not writable updates file.
*
* @expectedException Exception
- * @expectedExceptionMessageRegExp /Unable to write(.*)/
*/
public function testWriteUpdatesFileNotWritable()
{
+ $this->expectExceptionMessageRegExp('/Unable to write(.*)/');
+
$updatesFile = $this->conf->get('resource.data_dir') . '/updates.txt';
touch($updatesFile);
chmod($updatesFile, 0444);
/**
* Test Update failed.
- *
- * @expectedException \Exception
*/
public function testUpdateFailed()
{
+ $this->expectException(\Exception::class);
+
$updates = array(
'updateMethodDummy1',
'updateMethodDummy2',
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());
}
}