aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests/updater
diff options
context:
space:
mode:
authorArthurHoaro <arthur@hoa.ro>2020-11-12 13:02:36 +0100
committerArthurHoaro <arthur@hoa.ro>2020-11-12 13:02:36 +0100
commit1409f1c89a7ca01456ae2dcd6357d296e2b99f5a (patch)
treeffa30a9358e82d27be75d8fc5e57f3c8820dc6d3 /tests/updater
parent054e03f37fa29da8066f1a637919f13c7e7dc5d2 (diff)
parenta6935feb22df8d9634189ee87d257da9f03eedbd (diff)
downloadShaarli-v0.12.tar.gz
Shaarli-v0.12.tar.zst
Shaarli-v0.12.zip
Merge branch 'master' into v0.12v0.12.1v0.12
Diffstat (limited to 'tests/updater')
-rw-r--r--tests/updater/UpdaterTest.php20
1 files changed, 11 insertions, 9 deletions
diff --git a/tests/updater/UpdaterTest.php b/tests/updater/UpdaterTest.php
index a6280b8c..cadd8265 100644
--- a/tests/updater/UpdaterTest.php
+++ b/tests/updater/UpdaterTest.php
@@ -2,6 +2,7 @@
2namespace Shaarli\Updater; 2namespace Shaarli\Updater;
3 3
4use Exception; 4use Exception;
5use malkusch\lock\mutex\NoMutex;
5use Shaarli\Bookmark\BookmarkFileService; 6use Shaarli\Bookmark\BookmarkFileService;
6use Shaarli\Bookmark\BookmarkServiceInterface; 7use Shaarli\Bookmark\BookmarkServiceInterface;
7use Shaarli\Config\ConfigManager; 8use Shaarli\Config\ConfigManager;
@@ -44,12 +45,13 @@ class UpdaterTest extends TestCase
44 */ 45 */
45 protected function setUp(): void 46 protected function setUp(): void
46 { 47 {
48 $mutex = new NoMutex();
47 $this->refDB = new \ReferenceLinkDB(); 49 $this->refDB = new \ReferenceLinkDB();
48 $this->refDB->write(self::$testDatastore); 50 $this->refDB->write(self::$testDatastore);
49 51
50 copy('tests/utils/config/configJson.json.php', self::$configFile .'.json.php'); 52 copy('tests/utils/config/configJson.json.php', self::$configFile .'.json.php');
51 $this->conf = new ConfigManager(self::$configFile); 53 $this->conf = new ConfigManager(self::$configFile);
52 $this->bookmarkService = new BookmarkFileService($this->conf, $this->createMock(History::class), true); 54 $this->bookmarkService = new BookmarkFileService($this->conf, $this->createMock(History::class), $mutex, true);
53 $this->updater = new Updater([], $this->bookmarkService, $this->conf, true); 55 $this->updater = new Updater([], $this->bookmarkService, $this->conf, true);
54 } 56 }
55 57
@@ -58,10 +60,10 @@ class UpdaterTest extends TestCase
58 */ 60 */
59 public function testReadEmptyUpdatesFile() 61 public function testReadEmptyUpdatesFile()
60 { 62 {
61 $this->assertEquals(array(), UpdaterUtils::read_updates_file('')); 63 $this->assertEquals(array(), UpdaterUtils::readUpdatesFile(''));
62 $updatesFile = $this->conf->get('resource.data_dir') . '/updates.txt'; 64 $updatesFile = $this->conf->get('resource.data_dir') . '/updates.txt';
63 touch($updatesFile); 65 touch($updatesFile);
64 $this->assertEquals(array(), UpdaterUtils::read_updates_file($updatesFile)); 66 $this->assertEquals(array(), UpdaterUtils::readUpdatesFile($updatesFile));
65 unlink($updatesFile); 67 unlink($updatesFile);
66 } 68 }
67 69
@@ -73,14 +75,14 @@ class UpdaterTest extends TestCase
73 $updatesFile = $this->conf->get('resource.data_dir') . '/updates.txt'; 75 $updatesFile = $this->conf->get('resource.data_dir') . '/updates.txt';
74 $updatesMethods = array('m1', 'm2', 'm3'); 76 $updatesMethods = array('m1', 'm2', 'm3');
75 77
76 UpdaterUtils::write_updates_file($updatesFile, $updatesMethods); 78 UpdaterUtils::writeUpdatesFile($updatesFile, $updatesMethods);
77 $readMethods = UpdaterUtils::read_updates_file($updatesFile); 79 $readMethods = UpdaterUtils::readUpdatesFile($updatesFile);
78 $this->assertEquals($readMethods, $updatesMethods); 80 $this->assertEquals($readMethods, $updatesMethods);
79 81
80 // Update 82 // Update
81 $updatesMethods[] = 'm4'; 83 $updatesMethods[] = 'm4';
82 UpdaterUtils::write_updates_file($updatesFile, $updatesMethods); 84 UpdaterUtils::writeUpdatesFile($updatesFile, $updatesMethods);
83 $readMethods = UpdaterUtils::read_updates_file($updatesFile); 85 $readMethods = UpdaterUtils::readUpdatesFile($updatesFile);
84 $this->assertEquals($readMethods, $updatesMethods); 86 $this->assertEquals($readMethods, $updatesMethods);
85 unlink($updatesFile); 87 unlink($updatesFile);
86 } 88 }
@@ -93,7 +95,7 @@ class UpdaterTest extends TestCase
93 $this->expectException(\Exception::class); 95 $this->expectException(\Exception::class);
94 $this->expectExceptionMessageRegExp('/Updates file path is not set(.*)/'); 96 $this->expectExceptionMessageRegExp('/Updates file path is not set(.*)/');
95 97
96 UpdaterUtils::write_updates_file('', array('test')); 98 UpdaterUtils::writeUpdatesFile('', array('test'));
97 } 99 }
98 100
99 /** 101 /**
@@ -108,7 +110,7 @@ class UpdaterTest extends TestCase
108 touch($updatesFile); 110 touch($updatesFile);
109 chmod($updatesFile, 0444); 111 chmod($updatesFile, 0444);
110 try { 112 try {
111 @UpdaterUtils::write_updates_file($updatesFile, array('test')); 113 @UpdaterUtils::writeUpdatesFile($updatesFile, array('test'));
112 } catch (Exception $e) { 114 } catch (Exception $e) {
113 unlink($updatesFile); 115 unlink($updatesFile);
114 throw $e; 116 throw $e;