aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests/api/controllers/links/PostLinkTest.php
diff options
context:
space:
mode:
authorArthurHoaro <arthur@hoa.ro>2020-10-13 12:07:13 +0200
committerArthurHoaro <arthur@hoa.ro>2020-10-13 12:07:13 +0200
commitd9f6275ebca035fec8331652c677981056793ccc (patch)
tree37a64baf4f0eba6b781040605965383d8aded2cc /tests/api/controllers/links/PostLinkTest.php
parent38672ba0d1c722e5d6d33a58255ceb55e9410e46 (diff)
parentd63ff87a009313141ae684ec447b902562ff6ee7 (diff)
downloadShaarli-stable.tar.gz
Shaarli-stable.tar.zst
Shaarli-stable.zip
Merge branch 'v0.11' into stablestable
Diffstat (limited to 'tests/api/controllers/links/PostLinkTest.php')
-rw-r--r--tests/api/controllers/links/PostLinkTest.php19
1 files changed, 10 insertions, 9 deletions
diff --git a/tests/api/controllers/links/PostLinkTest.php b/tests/api/controllers/links/PostLinkTest.php
index 5c2b5623..d683a984 100644
--- a/tests/api/controllers/links/PostLinkTest.php
+++ b/tests/api/controllers/links/PostLinkTest.php
@@ -4,6 +4,7 @@ namespace Shaarli\Api\Controllers;
4 4
5use PHPUnit\Framework\TestCase; 5use PHPUnit\Framework\TestCase;
6use Shaarli\Config\ConfigManager; 6use Shaarli\Config\ConfigManager;
7use Shaarli\History;
7use Slim\Container; 8use Slim\Container;
8use Slim\Http\Environment; 9use Slim\Http\Environment;
9use Slim\Http\Request; 10use Slim\Http\Request;
@@ -40,7 +41,7 @@ class PostLinkTest extends TestCase
40 protected $refDB = null; 41 protected $refDB = null;
41 42
42 /** 43 /**
43 * @var \History instance. 44 * @var HistoryController instance.
44 */ 45 */
45 protected $history; 46 protected $history;
46 47
@@ -70,12 +71,12 @@ class PostLinkTest extends TestCase
70 71
71 $refHistory = new \ReferenceHistory(); 72 $refHistory = new \ReferenceHistory();
72 $refHistory->write(self::$testHistory); 73 $refHistory->write(self::$testHistory);
73 $this->history = new \History(self::$testHistory); 74 $this->history = new History(self::$testHistory);
74 75
75 $this->container = new Container(); 76 $this->container = new Container();
76 $this->container['conf'] = $this->conf; 77 $this->container['conf'] = $this->conf;
77 $this->container['db'] = new \LinkDB(self::$testDatastore, true, false); 78 $this->container['db'] = new \Shaarli\Bookmark\LinkDB(self::$testDatastore, true, false);
78 $this->container['history'] = new \History(self::$testHistory); 79 $this->container['history'] = new History(self::$testHistory);
79 80
80 $this->controller = new Links($this->container); 81 $this->controller = new Links($this->container);
81 82
@@ -121,7 +122,7 @@ class PostLinkTest extends TestCase
121 $data = json_decode((string) $response->getBody(), true); 122 $data = json_decode((string) $response->getBody(), true);
122 $this->assertEquals(self::NB_FIELDS_LINK, count($data)); 123 $this->assertEquals(self::NB_FIELDS_LINK, count($data));
123 $this->assertEquals(43, $data['id']); 124 $this->assertEquals(43, $data['id']);
124 $this->assertRegExp('/[\w-_]{6}/', $data['shorturl']); 125 $this->assertRegExp('/[\w_-]{6}/', $data['shorturl']);
125 $this->assertEquals('http://domain.tld/?' . $data['shorturl'], $data['url']); 126 $this->assertEquals('http://domain.tld/?' . $data['shorturl'], $data['url']);
126 $this->assertEquals('?' . $data['shorturl'], $data['title']); 127 $this->assertEquals('?' . $data['shorturl'], $data['title']);
127 $this->assertEquals('', $data['description']); 128 $this->assertEquals('', $data['description']);
@@ -133,7 +134,7 @@ class PostLinkTest extends TestCase
133 $this->assertEquals('', $data['updated']); 134 $this->assertEquals('', $data['updated']);
134 135
135 $historyEntry = $this->history->getHistory()[0]; 136 $historyEntry = $this->history->getHistory()[0];
136 $this->assertEquals(\History::CREATED, $historyEntry['event']); 137 $this->assertEquals(History::CREATED, $historyEntry['event']);
137 $this->assertTrue( 138 $this->assertTrue(
138 (new \DateTime())->add(\DateInterval::createFromDateString('-5 seconds')) < $historyEntry['datetime'] 139 (new \DateTime())->add(\DateInterval::createFromDateString('-5 seconds')) < $historyEntry['datetime']
139 ); 140 );
@@ -166,7 +167,7 @@ class PostLinkTest extends TestCase
166 $data = json_decode((string) $response->getBody(), true); 167 $data = json_decode((string) $response->getBody(), true);
167 $this->assertEquals(self::NB_FIELDS_LINK, count($data)); 168 $this->assertEquals(self::NB_FIELDS_LINK, count($data));
168 $this->assertEquals(43, $data['id']); 169 $this->assertEquals(43, $data['id']);
169 $this->assertRegExp('/[\w-_]{6}/', $data['shorturl']); 170 $this->assertRegExp('/[\w_-]{6}/', $data['shorturl']);
170 $this->assertEquals('http://' . $link['url'], $data['url']); 171 $this->assertEquals('http://' . $link['url'], $data['url']);
171 $this->assertEquals($link['title'], $data['title']); 172 $this->assertEquals($link['title'], $data['title']);
172 $this->assertEquals($link['description'], $data['description']); 173 $this->assertEquals($link['description'], $data['description']);
@@ -210,11 +211,11 @@ class PostLinkTest extends TestCase
210 $this->assertEquals(['gnu', 'media', 'web', '.hidden', 'hashtag'], $data['tags']); 211 $this->assertEquals(['gnu', 'media', 'web', '.hidden', 'hashtag'], $data['tags']);
211 $this->assertEquals(false, $data['private']); 212 $this->assertEquals(false, $data['private']);
212 $this->assertEquals( 213 $this->assertEquals(
213 \DateTime::createFromFormat(\LinkDB::LINK_DATE_FORMAT, '20130614_184135'), 214 \DateTime::createFromFormat(\Shaarli\Bookmark\LinkDB::LINK_DATE_FORMAT, '20130614_184135'),
214 \DateTime::createFromFormat(\DateTime::ATOM, $data['created']) 215 \DateTime::createFromFormat(\DateTime::ATOM, $data['created'])
215 ); 216 );
216 $this->assertEquals( 217 $this->assertEquals(
217 \DateTime::createFromFormat(\LinkDB::LINK_DATE_FORMAT, '20130615_184230'), 218 \DateTime::createFromFormat(\Shaarli\Bookmark\LinkDB::LINK_DATE_FORMAT, '20130615_184230'),
218 \DateTime::createFromFormat(\DateTime::ATOM, $data['updated']) 219 \DateTime::createFromFormat(\DateTime::ATOM, $data['updated'])
219 ); 220 );
220 } 221 }