diff options
Diffstat (limited to 'tests/api/controllers/links/PutLinkTest.php')
-rw-r--r-- | tests/api/controllers/links/PutLinkTest.php | 26 |
1 files changed, 15 insertions, 11 deletions
diff --git a/tests/api/controllers/links/PutLinkTest.php b/tests/api/controllers/links/PutLinkTest.php index 8a562571..cd815b66 100644 --- a/tests/api/controllers/links/PutLinkTest.php +++ b/tests/api/controllers/links/PutLinkTest.php | |||
@@ -3,14 +3,14 @@ | |||
3 | 3 | ||
4 | namespace Shaarli\Api\Controllers; | 4 | namespace Shaarli\Api\Controllers; |
5 | 5 | ||
6 | |||
7 | use Shaarli\Config\ConfigManager; | 6 | use Shaarli\Config\ConfigManager; |
7 | use Shaarli\History; | ||
8 | use Slim\Container; | 8 | use Slim\Container; |
9 | use Slim\Http\Environment; | 9 | use Slim\Http\Environment; |
10 | use Slim\Http\Request; | 10 | use Slim\Http\Request; |
11 | use Slim\Http\Response; | 11 | use Slim\Http\Response; |
12 | 12 | ||
13 | class PutLinkTest extends \PHPUnit_Framework_TestCase | 13 | class PutLinkTest extends \PHPUnit\Framework\TestCase |
14 | { | 14 | { |
15 | /** | 15 | /** |
16 | * @var string datastore to test write operations | 16 | * @var string datastore to test write operations |
@@ -33,7 +33,7 @@ class PutLinkTest extends \PHPUnit_Framework_TestCase | |||
33 | protected $refDB = null; | 33 | protected $refDB = null; |
34 | 34 | ||
35 | /** | 35 | /** |
36 | * @var \History instance. | 36 | * @var HistoryController instance. |
37 | */ | 37 | */ |
38 | protected $history; | 38 | protected $history; |
39 | 39 | ||
@@ -63,12 +63,12 @@ class PutLinkTest extends \PHPUnit_Framework_TestCase | |||
63 | 63 | ||
64 | $refHistory = new \ReferenceHistory(); | 64 | $refHistory = new \ReferenceHistory(); |
65 | $refHistory->write(self::$testHistory); | 65 | $refHistory->write(self::$testHistory); |
66 | $this->history = new \History(self::$testHistory); | 66 | $this->history = new History(self::$testHistory); |
67 | 67 | ||
68 | $this->container = new Container(); | 68 | $this->container = new Container(); |
69 | $this->container['conf'] = $this->conf; | 69 | $this->container['conf'] = $this->conf; |
70 | $this->container['db'] = new \LinkDB(self::$testDatastore, true, false); | 70 | $this->container['db'] = new \Shaarli\Bookmark\LinkDB(self::$testDatastore, true, false); |
71 | $this->container['history'] = new \History(self::$testHistory); | 71 | $this->container['history'] = new History(self::$testHistory); |
72 | 72 | ||
73 | $this->controller = new Links($this->container); | 73 | $this->controller = new Links($this->container); |
74 | 74 | ||
@@ -115,10 +115,12 @@ class PutLinkTest extends \PHPUnit_Framework_TestCase | |||
115 | \DateTime::createFromFormat('Ymd_His', '20150310_114651'), | 115 | \DateTime::createFromFormat('Ymd_His', '20150310_114651'), |
116 | \DateTime::createFromFormat(\DateTime::ATOM, $data['created']) | 116 | \DateTime::createFromFormat(\DateTime::ATOM, $data['created']) |
117 | ); | 117 | ); |
118 | $this->assertTrue(new \DateTime('5 seconds ago') < \DateTime::createFromFormat(\DateTime::ATOM, $data['updated'])); | 118 | $this->assertTrue( |
119 | new \DateTime('5 seconds ago') < \DateTime::createFromFormat(\DateTime::ATOM, $data['updated']) | ||
120 | ); | ||
119 | 121 | ||
120 | $historyEntry = $this->history->getHistory()[0]; | 122 | $historyEntry = $this->history->getHistory()[0]; |
121 | $this->assertEquals(\History::UPDATED, $historyEntry['event']); | 123 | $this->assertEquals(History::UPDATED, $historyEntry['event']); |
122 | $this->assertTrue( | 124 | $this->assertTrue( |
123 | (new \DateTime())->add(\DateInterval::createFromDateString('-5 seconds')) < $historyEntry['datetime'] | 125 | (new \DateTime())->add(\DateInterval::createFromDateString('-5 seconds')) < $historyEntry['datetime'] |
124 | ); | 126 | ); |
@@ -160,7 +162,9 @@ class PutLinkTest extends \PHPUnit_Framework_TestCase | |||
160 | \DateTime::createFromFormat('Ymd_His', '20150310_114651'), | 162 | \DateTime::createFromFormat('Ymd_His', '20150310_114651'), |
161 | \DateTime::createFromFormat(\DateTime::ATOM, $data['created']) | 163 | \DateTime::createFromFormat(\DateTime::ATOM, $data['created']) |
162 | ); | 164 | ); |
163 | $this->assertTrue(new \DateTime('5 seconds ago') < \DateTime::createFromFormat(\DateTime::ATOM, $data['updated'])); | 165 | $this->assertTrue( |
166 | new \DateTime('5 seconds ago') < \DateTime::createFromFormat(\DateTime::ATOM, $data['updated']) | ||
167 | ); | ||
164 | } | 168 | } |
165 | 169 | ||
166 | /** | 170 | /** |
@@ -195,11 +199,11 @@ class PutLinkTest extends \PHPUnit_Framework_TestCase | |||
195 | $this->assertEquals(['gnu', 'media', 'web', '.hidden', 'hashtag'], $data['tags']); | 199 | $this->assertEquals(['gnu', 'media', 'web', '.hidden', 'hashtag'], $data['tags']); |
196 | $this->assertEquals(false, $data['private']); | 200 | $this->assertEquals(false, $data['private']); |
197 | $this->assertEquals( | 201 | $this->assertEquals( |
198 | \DateTime::createFromFormat(\LinkDB::LINK_DATE_FORMAT, '20130614_184135'), | 202 | \DateTime::createFromFormat(\Shaarli\Bookmark\LinkDB::LINK_DATE_FORMAT, '20130614_184135'), |
199 | \DateTime::createFromFormat(\DateTime::ATOM, $data['created']) | 203 | \DateTime::createFromFormat(\DateTime::ATOM, $data['created']) |
200 | ); | 204 | ); |
201 | $this->assertEquals( | 205 | $this->assertEquals( |
202 | \DateTime::createFromFormat(\LinkDB::LINK_DATE_FORMAT, '20130615_184230'), | 206 | \DateTime::createFromFormat(\Shaarli\Bookmark\LinkDB::LINK_DATE_FORMAT, '20130615_184230'), |
203 | \DateTime::createFromFormat(\DateTime::ATOM, $data['updated']) | 207 | \DateTime::createFromFormat(\DateTime::ATOM, $data['updated']) |
204 | ); | 208 | ); |
205 | } | 209 | } |