]> git.immae.eu Git - github/shaarli/Shaarli.git/blobdiff - tests/api/controllers/DeleteLinkTest.php
Make max download size and timeout configurable
[github/shaarli/Shaarli.git] / tests / api / controllers / DeleteLinkTest.php
index 6894e8a2cf08129ec41c3d5e865aefeb8f322e0c..7d79713779cc70bf1c18c3ae3803196be6af3990 100644 (file)
@@ -16,6 +16,11 @@ class DeleteLinkTest extends \PHPUnit_Framework_TestCase
      */
     protected static $testDatastore = 'sandbox/datastore.php';
 
+    /**
+     * @var string datastore to test write operations
+     */
+    protected static $testHistory = 'sandbox/history.php';
+
     /**
      * @var ConfigManager instance
      */
@@ -31,6 +36,11 @@ class DeleteLinkTest extends \PHPUnit_Framework_TestCase
      */
     protected $linkDB;
 
+    /**
+     * @var \History instance.
+     */
+    protected $history;
+
     /**
      * @var Container instance.
      */
@@ -50,9 +60,13 @@ class DeleteLinkTest extends \PHPUnit_Framework_TestCase
         $this->refDB = new \ReferenceLinkDB();
         $this->refDB->write(self::$testDatastore);
         $this->linkDB = new \LinkDB(self::$testDatastore, true, false);
+        $refHistory = new \ReferenceHistory();
+        $refHistory->write(self::$testHistory);
+        $this->history = new \History(self::$testHistory);
         $this->container = new Container();
         $this->container['conf'] = $this->conf;
         $this->container['db'] = $this->linkDB;
+        $this->container['history'] = $this->history;
 
         $this->controller = new Links($this->container);
     }
@@ -63,6 +77,7 @@ class DeleteLinkTest extends \PHPUnit_Framework_TestCase
     public function tearDown()
     {
         @unlink(self::$testDatastore);
+        @unlink(self::$testHistory);
     }
 
     /**
@@ -83,6 +98,13 @@ class DeleteLinkTest extends \PHPUnit_Framework_TestCase
 
         $this->linkDB = new \LinkDB(self::$testDatastore, true, false);
         $this->assertFalse(isset($this->linkDB[$id]));
+
+        $historyEntry = $this->history->getHistory()[0];
+        $this->assertEquals(\History::DELETED, $historyEntry['event']);
+        $this->assertTrue(
+            (new \DateTime())->add(\DateInterval::createFromDateString('-5 seconds')) < $historyEntry['datetime']
+        );
+        $this->assertEquals($id, $historyEntry['id']);
     }
 
     /**