diff options
author | ArthurHoaro <arthur@hoa.ro> | 2017-05-07 17:40:17 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-05-07 17:40:17 +0200 |
commit | b4189928f84758e1589715dfe04e2d966a4f3b88 (patch) | |
tree | f17b8fa91fe8244fed7a913d64ce3220551916ff /tests/api/controllers/DeleteLinkTest.php | |
parent | a4af59f47103a3f9c903eeddb1e30ab9cb7344f0 (diff) | |
parent | b86aeccf6a99a9617c66cded7252a33b1df560cd (diff) | |
download | Shaarli-b4189928f84758e1589715dfe04e2d966a4f3b88.tar.gz Shaarli-b4189928f84758e1589715dfe04e2d966a4f3b88.tar.zst Shaarli-b4189928f84758e1589715dfe04e2d966a4f3b88.zip |
Merge pull request #858 from ArthurHoaro/api/history-entries
Add history entries for API endpoint
Diffstat (limited to 'tests/api/controllers/DeleteLinkTest.php')
-rw-r--r-- | tests/api/controllers/DeleteLinkTest.php | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/tests/api/controllers/DeleteLinkTest.php b/tests/api/controllers/DeleteLinkTest.php index 6894e8a2..7d797137 100644 --- a/tests/api/controllers/DeleteLinkTest.php +++ b/tests/api/controllers/DeleteLinkTest.php | |||
@@ -17,6 +17,11 @@ class DeleteLinkTest extends \PHPUnit_Framework_TestCase | |||
17 | protected static $testDatastore = 'sandbox/datastore.php'; | 17 | protected static $testDatastore = 'sandbox/datastore.php'; |
18 | 18 | ||
19 | /** | 19 | /** |
20 | * @var string datastore to test write operations | ||
21 | */ | ||
22 | protected static $testHistory = 'sandbox/history.php'; | ||
23 | |||
24 | /** | ||
20 | * @var ConfigManager instance | 25 | * @var ConfigManager instance |
21 | */ | 26 | */ |
22 | protected $conf; | 27 | protected $conf; |
@@ -32,6 +37,11 @@ class DeleteLinkTest extends \PHPUnit_Framework_TestCase | |||
32 | protected $linkDB; | 37 | protected $linkDB; |
33 | 38 | ||
34 | /** | 39 | /** |
40 | * @var \History instance. | ||
41 | */ | ||
42 | protected $history; | ||
43 | |||
44 | /** | ||
35 | * @var Container instance. | 45 | * @var Container instance. |
36 | */ | 46 | */ |
37 | protected $container; | 47 | protected $container; |
@@ -50,9 +60,13 @@ class DeleteLinkTest extends \PHPUnit_Framework_TestCase | |||
50 | $this->refDB = new \ReferenceLinkDB(); | 60 | $this->refDB = new \ReferenceLinkDB(); |
51 | $this->refDB->write(self::$testDatastore); | 61 | $this->refDB->write(self::$testDatastore); |
52 | $this->linkDB = new \LinkDB(self::$testDatastore, true, false); | 62 | $this->linkDB = new \LinkDB(self::$testDatastore, true, false); |
63 | $refHistory = new \ReferenceHistory(); | ||
64 | $refHistory->write(self::$testHistory); | ||
65 | $this->history = new \History(self::$testHistory); | ||
53 | $this->container = new Container(); | 66 | $this->container = new Container(); |
54 | $this->container['conf'] = $this->conf; | 67 | $this->container['conf'] = $this->conf; |
55 | $this->container['db'] = $this->linkDB; | 68 | $this->container['db'] = $this->linkDB; |
69 | $this->container['history'] = $this->history; | ||
56 | 70 | ||
57 | $this->controller = new Links($this->container); | 71 | $this->controller = new Links($this->container); |
58 | } | 72 | } |
@@ -63,6 +77,7 @@ class DeleteLinkTest extends \PHPUnit_Framework_TestCase | |||
63 | public function tearDown() | 77 | public function tearDown() |
64 | { | 78 | { |
65 | @unlink(self::$testDatastore); | 79 | @unlink(self::$testDatastore); |
80 | @unlink(self::$testHistory); | ||
66 | } | 81 | } |
67 | 82 | ||
68 | /** | 83 | /** |
@@ -83,6 +98,13 @@ class DeleteLinkTest extends \PHPUnit_Framework_TestCase | |||
83 | 98 | ||
84 | $this->linkDB = new \LinkDB(self::$testDatastore, true, false); | 99 | $this->linkDB = new \LinkDB(self::$testDatastore, true, false); |
85 | $this->assertFalse(isset($this->linkDB[$id])); | 100 | $this->assertFalse(isset($this->linkDB[$id])); |
101 | |||
102 | $historyEntry = $this->history->getHistory()[0]; | ||
103 | $this->assertEquals(\History::DELETED, $historyEntry['event']); | ||
104 | $this->assertTrue( | ||
105 | (new \DateTime())->add(\DateInterval::createFromDateString('-5 seconds')) < $historyEntry['datetime'] | ||
106 | ); | ||
107 | $this->assertEquals($id, $historyEntry['id']); | ||
86 | } | 108 | } |
87 | 109 | ||
88 | /** | 110 | /** |