X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=tests%2Fupdater%2FUpdaterTest.php;h=a8539d63fc0262e05c3b361ead40195bd21d95d1;hb=refs%2Fheads%2Fmaster;hp=5cfcd5db4f74c54bc0078129b86afbd4cb7ae26f;hpb=b1baca99f280570d0336b4d71ad1f9dca213a35b;p=github%2Fshaarli%2FShaarli.git diff --git a/tests/updater/UpdaterTest.php b/tests/updater/UpdaterTest.php index 5cfcd5db..a8539d63 100644 --- a/tests/updater/UpdaterTest.php +++ b/tests/updater/UpdaterTest.php @@ -2,11 +2,13 @@ namespace Shaarli\Updater; use Exception; -use PHPUnit\Framework\TestCase; +use malkusch\lock\mutex\NoMutex; use Shaarli\Bookmark\BookmarkFileService; use Shaarli\Bookmark\BookmarkServiceInterface; use Shaarli\Config\ConfigManager; use Shaarli\History; +use Shaarli\Plugin\PluginManager; +use Shaarli\TestCase; /** @@ -44,12 +46,19 @@ class UpdaterTest extends TestCase */ protected function setUp(): void { + $mutex = new NoMutex(); $this->refDB = new \ReferenceLinkDB(); $this->refDB->write(self::$testDatastore); copy('tests/utils/config/configJson.json.php', self::$configFile .'.json.php'); $this->conf = new ConfigManager(self::$configFile); - $this->bookmarkService = new BookmarkFileService($this->conf, $this->createMock(History::class), true); + $this->bookmarkService = new BookmarkFileService( + $this->conf, + $this->createMock(PluginManager::class), + $this->createMock(History::class), + $mutex, + true + ); $this->updater = new Updater([], $this->bookmarkService, $this->conf, true); } @@ -58,10 +67,10 @@ class UpdaterTest extends TestCase */ public function testReadEmptyUpdatesFile() { - $this->assertEquals(array(), UpdaterUtils::read_updates_file('')); + $this->assertEquals(array(), UpdaterUtils::readUpdatesFile('')); $updatesFile = $this->conf->get('resource.data_dir') . '/updates.txt'; touch($updatesFile); - $this->assertEquals(array(), UpdaterUtils::read_updates_file($updatesFile)); + $this->assertEquals(array(), UpdaterUtils::readUpdatesFile($updatesFile)); unlink($updatesFile); } @@ -73,44 +82,42 @@ class UpdaterTest extends TestCase $updatesFile = $this->conf->get('resource.data_dir') . '/updates.txt'; $updatesMethods = array('m1', 'm2', 'm3'); - UpdaterUtils::write_updates_file($updatesFile, $updatesMethods); - $readMethods = UpdaterUtils::read_updates_file($updatesFile); + UpdaterUtils::writeUpdatesFile($updatesFile, $updatesMethods); + $readMethods = UpdaterUtils::readUpdatesFile($updatesFile); $this->assertEquals($readMethods, $updatesMethods); // Update $updatesMethods[] = 'm4'; - UpdaterUtils::write_updates_file($updatesFile, $updatesMethods); - $readMethods = UpdaterUtils::read_updates_file($updatesFile); + UpdaterUtils::writeUpdatesFile($updatesFile, $updatesMethods); + $readMethods = UpdaterUtils::readUpdatesFile($updatesFile); $this->assertEquals($readMethods, $updatesMethods); unlink($updatesFile); } /** * Test errors in UpdaterUtils::write_updates_file(): empty updates file. - * - * @expectedException Exception */ public function testWriteEmptyUpdatesFile() { + $this->expectException(\Exception::class); $this->expectExceptionMessageRegExp('/Updates file path is not set(.*)/'); - UpdaterUtils::write_updates_file('', array('test')); + UpdaterUtils::writeUpdatesFile('', array('test')); } /** * Test errors in UpdaterUtils::write_updates_file(): not writable updates file. - * - * @expectedException Exception */ public function testWriteUpdatesFileNotWritable() { + $this->expectException(\Exception::class); $this->expectExceptionMessageRegExp('/Unable to write(.*)/'); $updatesFile = $this->conf->get('resource.data_dir') . '/updates.txt'; touch($updatesFile); chmod($updatesFile, 0444); try { - @UpdaterUtils::write_updates_file($updatesFile, array('test')); + @UpdaterUtils::writeUpdatesFile($updatesFile, array('test')); } catch (Exception $e) { unlink($updatesFile); throw $e;