]> git.immae.eu Git - github/shaarli/Shaarli.git/blobdiff - tests/netscape/BookmarkImportTest.php
Add mutex on datastore I/O operations
[github/shaarli/Shaarli.git] / tests / netscape / BookmarkImportTest.php
index f678e26bd5ca8d3199242d33f6613bb36f7afecc..c526d5c8382699c27a57ffbc12622e153c42c4cf 100644 (file)
@@ -3,13 +3,14 @@
 namespace Shaarli\Netscape;
 
 use DateTime;
-use PHPUnit\Framework\TestCase;
+use malkusch\lock\mutex\NoMutex;
 use Psr\Http\Message\UploadedFileInterface;
 use Shaarli\Bookmark\Bookmark;
 use Shaarli\Bookmark\BookmarkFileService;
 use Shaarli\Bookmark\BookmarkFilter;
 use Shaarli\Config\ConfigManager;
 use Shaarli\History;
+use Shaarli\TestCase;
 use Slim\Http\UploadedFile;
 
 /**
@@ -75,7 +76,7 @@ class BookmarkImportTest extends TestCase
      */
     protected static $defaultTimeZone;
 
-    public static function setUpBeforeClass()
+    public static function setUpBeforeClass(): void
     {
         self::$defaultTimeZone = date_default_timezone_get();
         // Timezone without DST for test consistency
@@ -85,8 +86,9 @@ class BookmarkImportTest extends TestCase
     /**
      * Resets test data before each test
      */
-    protected function setUp()
+    protected function setUp(): void
     {
+        $mutex = new NoMutex();
         if (file_exists(self::$testDatastore)) {
             unlink(self::$testDatastore);
         }
@@ -97,19 +99,19 @@ class BookmarkImportTest extends TestCase
         $this->conf->set('resource.page_cache', $this->pagecache);
         $this->conf->set('resource.datastore', self::$testDatastore);
         $this->history = new History(self::$historyFilePath);
-        $this->bookmarkService = new BookmarkFileService($this->conf, $this->history, true);
+        $this->bookmarkService = new BookmarkFileService($this->conf, $this->history, $mutex, true);
         $this->netscapeBookmarkUtils = new NetscapeBookmarkUtils($this->bookmarkService, $this->conf, $this->history);
     }
 
     /**
      * Delete history file.
      */
-    public function tearDown()
+    protected function tearDown(): void
     {
         @unlink(self::$historyFilePath);
     }
 
-    public static function tearDownAfterClass()
+    public static function tearDownAfterClass(): void
     {
         date_default_timezone_set(self::$defaultTimeZone);
     }