aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests/HistoryTest.php
diff options
context:
space:
mode:
authorArthurHoaro <arthur@hoa.ro>2017-05-07 17:40:17 +0200
committerGitHub <noreply@github.com>2017-05-07 17:40:17 +0200
commitb4189928f84758e1589715dfe04e2d966a4f3b88 (patch)
treef17b8fa91fe8244fed7a913d64ce3220551916ff /tests/HistoryTest.php
parenta4af59f47103a3f9c903eeddb1e30ab9cb7344f0 (diff)
parentb86aeccf6a99a9617c66cded7252a33b1df560cd (diff)
downloadShaarli-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/HistoryTest.php')
-rw-r--r--tests/HistoryTest.php24
1 files changed, 12 insertions, 12 deletions
diff --git a/tests/HistoryTest.php b/tests/HistoryTest.php
index 91525845..d3bef5a3 100644
--- a/tests/HistoryTest.php
+++ b/tests/HistoryTest.php
@@ -74,21 +74,21 @@ class HistoryTest extends PHPUnit_Framework_TestCase
74 $history->addLink(['id' => 0]); 74 $history->addLink(['id' => 0]);
75 $actual = $history->getHistory()[0]; 75 $actual = $history->getHistory()[0];
76 $this->assertEquals(History::CREATED, $actual['event']); 76 $this->assertEquals(History::CREATED, $actual['event']);
77 $this->assertTrue(new DateTime('-2 seconds') < DateTime::createFromFormat(DateTime::ATOM, $actual['datetime'])); 77 $this->assertTrue(new DateTime('-2 seconds') < $actual['datetime']);
78 $this->assertEquals(0, $actual['id']); 78 $this->assertEquals(0, $actual['id']);
79 79
80 $history = new History(self::$historyFilePath); 80 $history = new History(self::$historyFilePath);
81 $history->addLink(['id' => 1]); 81 $history->addLink(['id' => 1]);
82 $actual = $history->getHistory()[0]; 82 $actual = $history->getHistory()[0];
83 $this->assertEquals(History::CREATED, $actual['event']); 83 $this->assertEquals(History::CREATED, $actual['event']);
84 $this->assertTrue(new DateTime('-2 seconds') < DateTime::createFromFormat(DateTime::ATOM, $actual['datetime'])); 84 $this->assertTrue(new DateTime('-2 seconds') < $actual['datetime']);
85 $this->assertEquals(1, $actual['id']); 85 $this->assertEquals(1, $actual['id']);
86 86
87 $history = new History(self::$historyFilePath); 87 $history = new History(self::$historyFilePath);
88 $history->addLink(['id' => 'str']); 88 $history->addLink(['id' => 'str']);
89 $actual = $history->getHistory()[0]; 89 $actual = $history->getHistory()[0];
90 $this->assertEquals(History::CREATED, $actual['event']); 90 $this->assertEquals(History::CREATED, $actual['event']);
91 $this->assertTrue(new DateTime('-2 seconds') < DateTime::createFromFormat(DateTime::ATOM, $actual['datetime'])); 91 $this->assertTrue(new DateTime('-2 seconds') < $actual['datetime']);
92 $this->assertEquals('str', $actual['id']); 92 $this->assertEquals('str', $actual['id']);
93 } 93 }
94 94
@@ -101,7 +101,7 @@ class HistoryTest extends PHPUnit_Framework_TestCase
101 $history->updateLink(['id' => 1]); 101 $history->updateLink(['id' => 1]);
102 $actual = $history->getHistory()[0]; 102 $actual = $history->getHistory()[0];
103 $this->assertEquals(History::UPDATED, $actual['event']); 103 $this->assertEquals(History::UPDATED, $actual['event']);
104 $this->assertTrue(new DateTime('-2 seconds') < DateTime::createFromFormat(DateTime::ATOM, $actual['datetime'])); 104 $this->assertTrue(new DateTime('-2 seconds') < $actual['datetime']);
105 $this->assertEquals(1, $actual['id']); 105 $this->assertEquals(1, $actual['id']);
106 } 106 }
107 107
@@ -114,7 +114,7 @@ class HistoryTest extends PHPUnit_Framework_TestCase
114 $history->deleteLink(['id' => 1]); 114 $history->deleteLink(['id' => 1]);
115 $actual = $history->getHistory()[0]; 115 $actual = $history->getHistory()[0];
116 $this->assertEquals(History::DELETED, $actual['event']); 116 $this->assertEquals(History::DELETED, $actual['event']);
117 $this->assertTrue(new DateTime('-2 seconds') < DateTime::createFromFormat(DateTime::ATOM, $actual['datetime'])); 117 $this->assertTrue(new DateTime('-2 seconds') < $actual['datetime']);
118 $this->assertEquals(1, $actual['id']); 118 $this->assertEquals(1, $actual['id']);
119 } 119 }
120 120
@@ -127,7 +127,7 @@ class HistoryTest extends PHPUnit_Framework_TestCase
127 $history->updateSettings(); 127 $history->updateSettings();
128 $actual = $history->getHistory()[0]; 128 $actual = $history->getHistory()[0];
129 $this->assertEquals(History::SETTINGS, $actual['event']); 129 $this->assertEquals(History::SETTINGS, $actual['event']);
130 $this->assertTrue(new DateTime('-2 seconds') < DateTime::createFromFormat(DateTime::ATOM, $actual['datetime'])); 130 $this->assertTrue(new DateTime('-2 seconds') < $actual['datetime']);
131 $this->assertEmpty($actual['id']); 131 $this->assertEmpty($actual['id']);
132 } 132 }
133 133
@@ -140,13 +140,13 @@ class HistoryTest extends PHPUnit_Framework_TestCase
140 $history->updateLink(['id' => 1]); 140 $history->updateLink(['id' => 1]);
141 $actual = $history->getHistory()[0]; 141 $actual = $history->getHistory()[0];
142 $this->assertEquals(History::UPDATED, $actual['event']); 142 $this->assertEquals(History::UPDATED, $actual['event']);
143 $this->assertTrue(new DateTime('-2 seconds') < DateTime::createFromFormat(DateTime::ATOM, $actual['datetime'])); 143 $this->assertTrue(new DateTime('-2 seconds') < $actual['datetime']);
144 $this->assertEquals(1, $actual['id']); 144 $this->assertEquals(1, $actual['id']);
145 145
146 $history->addLink(['id' => 1]); 146 $history->addLink(['id' => 1]);
147 $actual = $history->getHistory()[0]; 147 $actual = $history->getHistory()[0];
148 $this->assertEquals(History::CREATED, $actual['event']); 148 $this->assertEquals(History::CREATED, $actual['event']);
149 $this->assertTrue(new DateTime('-2 seconds') < DateTime::createFromFormat(DateTime::ATOM, $actual['datetime'])); 149 $this->assertTrue(new DateTime('-2 seconds') < $actual['datetime']);
150 $this->assertEquals(1, $actual['id']); 150 $this->assertEquals(1, $actual['id']);
151 } 151 }
152 152
@@ -160,7 +160,7 @@ class HistoryTest extends PHPUnit_Framework_TestCase
160 $history = new History(self::$historyFilePath); 160 $history = new History(self::$historyFilePath);
161 $actual = $history->getHistory()[0]; 161 $actual = $history->getHistory()[0];
162 $this->assertEquals(History::UPDATED, $actual['event']); 162 $this->assertEquals(History::UPDATED, $actual['event']);
163 $this->assertTrue(new DateTime('-2 seconds') < DateTime::createFromFormat(DateTime::ATOM, $actual['datetime'])); 163 $this->assertTrue(new DateTime('-2 seconds') < $actual['datetime']);
164 $this->assertEquals(1, $actual['id']); 164 $this->assertEquals(1, $actual['id']);
165 } 165 }
166 166
@@ -176,12 +176,12 @@ class HistoryTest extends PHPUnit_Framework_TestCase
176 $history = new History(self::$historyFilePath); 176 $history = new History(self::$historyFilePath);
177 $actual = $history->getHistory()[0]; 177 $actual = $history->getHistory()[0];
178 $this->assertEquals(History::CREATED, $actual['event']); 178 $this->assertEquals(History::CREATED, $actual['event']);
179 $this->assertTrue(new DateTime('-2 seconds') < DateTime::createFromFormat(DateTime::ATOM, $actual['datetime'])); 179 $this->assertTrue(new DateTime('-2 seconds') < $actual['datetime']);
180 $this->assertEquals(1, $actual['id']); 180 $this->assertEquals(1, $actual['id']);
181 181
182 $actual = $history->getHistory()[1]; 182 $actual = $history->getHistory()[1];
183 $this->assertEquals(History::UPDATED, $actual['event']); 183 $this->assertEquals(History::UPDATED, $actual['event']);
184 $this->assertTrue(new DateTime('-2 seconds') < DateTime::createFromFormat(DateTime::ATOM, $actual['datetime'])); 184 $this->assertTrue(new DateTime('-2 seconds') < $actual['datetime']);
185 $this->assertEquals(1, $actual['id']); 185 $this->assertEquals(1, $actual['id']);
186 } 186 }
187 187
@@ -194,7 +194,7 @@ class HistoryTest extends PHPUnit_Framework_TestCase
194 $history->updateLink(['id' => 1]); 194 $history->updateLink(['id' => 1]);
195 $this->assertEquals(1, count($history->getHistory())); 195 $this->assertEquals(1, count($history->getHistory()));
196 $arr = $history->getHistory(); 196 $arr = $history->getHistory();
197 $arr[0]['datetime'] = (new DateTime('-1 hour'))->format(DateTime::ATOM); 197 $arr[0]['datetime'] = new DateTime('-1 hour');
198 FileUtils::writeFlatDB(self::$historyFilePath, $arr); 198 FileUtils::writeFlatDB(self::$historyFilePath, $arr);
199 199
200 $history = new History(self::$historyFilePath, 60); 200 $history = new History(self::$historyFilePath, 60);