- $this->container['db'] = new \LinkDB(self::$testDatastore, true, false);
- $this->container['history'] = new \History(self::$testHistory);
+ $this->container['db'] = $this->bookmarkService;
+ $this->container['history'] = $this->history;
$this->controller = new Links($this->container);
$mock = $this->createMock(Router::class);
$mock->expects($this->any())
->method('relativePathFor')
$this->controller = new Links($this->container);
$mock = $this->createMock(Router::class);
$mock->expects($this->any())
->method('relativePathFor')
$response = $this->controller->postLink($request, new Response());
$this->assertEquals(201, $response->getStatusCode());
$response = $this->controller->postLink($request, new Response());
$this->assertEquals(201, $response->getStatusCode());
$data = json_decode((string) $response->getBody(), true);
$this->assertEquals(self::NB_FIELDS_LINK, count($data));
$this->assertEquals(43, $data['id']);
$data = json_decode((string) $response->getBody(), true);
$this->assertEquals(self::NB_FIELDS_LINK, count($data));
$this->assertEquals(43, $data['id']);
- $this->assertRegExp('/[\w-_]{6}/', $data['shorturl']);
- $this->assertEquals('http://domain.tld/?' . $data['shorturl'], $data['url']);
- $this->assertEquals('?' . $data['shorturl'], $data['title']);
+ $this->assertRegExp('/[\w_-]{6}/', $data['shorturl']);
+ $this->assertEquals('http://domain.tld/shaare/' . $data['shorturl'], $data['url']);
+ $this->assertEquals('/shaare/' . $data['shorturl'], $data['title']);
$this->assertEquals('', $data['description']);
$this->assertEquals([], $data['tags']);
$this->assertEquals('', $data['description']);
$this->assertEquals([], $data['tags']);
- $this->assertEquals(false, $data['private']);
- $this->assertTrue(new \DateTime('5 seconds ago') < \DateTime::createFromFormat(\DateTime::ATOM, $data['created']));
+ $this->assertEquals(true, $data['private']);
+ $this->assertTrue(
+ new \DateTime('5 seconds ago') < \DateTime::createFromFormat(\DateTime::ATOM, $data['created'])
+ );
$this->assertEquals('', $data['updated']);
$historyEntry = $this->history->getHistory()[0];
$this->assertEquals('', $data['updated']);
$historyEntry = $this->history->getHistory()[0];
$response = $this->controller->postLink($request, new Response());
$this->assertEquals(201, $response->getStatusCode());
$response = $this->controller->postLink($request, new Response());
$this->assertEquals(201, $response->getStatusCode());
$data = json_decode((string) $response->getBody(), true);
$this->assertEquals(self::NB_FIELDS_LINK, count($data));
$this->assertEquals(43, $data['id']);
$data = json_decode((string) $response->getBody(), true);
$this->assertEquals(self::NB_FIELDS_LINK, count($data));
$this->assertEquals(43, $data['id']);
$this->assertEquals('http://' . $link['url'], $data['url']);
$this->assertEquals($link['title'], $data['title']);
$this->assertEquals($link['description'], $data['description']);
$this->assertEquals($link['tags'], $data['tags']);
$this->assertEquals(true, $data['private']);
$this->assertEquals('http://' . $link['url'], $data['url']);
$this->assertEquals($link['title'], $data['title']);
$this->assertEquals($link['description'], $data['description']);
$this->assertEquals($link['tags'], $data['tags']);
$this->assertEquals(true, $data['private']);
$this->assertEquals(['gnu', 'media', 'web', '.hidden', 'hashtag'], $data['tags']);
$this->assertEquals(false, $data['private']);
$this->assertEquals(
$this->assertEquals(['gnu', 'media', 'web', '.hidden', 'hashtag'], $data['tags']);
$this->assertEquals(false, $data['private']);
$this->assertEquals(