$this->assertSame(1, $content['page']);
$this->assertGreaterThanOrEqual(1, $content['pages']);
+ $this->assertContains('foo', array_column($content['_embedded']['items'][0]['tags'], 'label'), 'Entries tags should have "foo" tag');
+ $this->assertContains('bar', array_column($content['_embedded']['items'][0]['tags'], 'label'), 'Entries tags should have "bar" tag');
+
$this->assertArrayHasKey('_links', $content);
$this->assertArrayHasKey('self', $content['_links']);
$this->assertArrayHasKey('first', $content['_links']);
$this->assertSame('http://www.lemonde.fr/pixels/article/2015/03/28/plongee-dans-l-univers-d-ingress-le-jeu-de-google-aux-frontieres-du-reel_4601155_4408996.html', $content['url']);
$this->assertSame(0, $content['is_archived']);
$this->assertSame(0, $content['is_starred']);
+ $this->assertNull($content['starred_at']);
$this->assertSame('New title for my article', $content['title']);
$this->assertSame(1, $content['user_id']);
$this->assertCount(2, $content['tags']);
public function testPostSameEntry()
{
+ $em = $this->client->getContainer()->get('doctrine.orm.entity_manager');
+ $entry = new Entry($em->getReference(User::class, 1));
+ $entry->setUrl('http://www.lemonde.fr/pixels/article/2015/03/28/plongee-dans-l-univers-d-ingress-le-jeu-de-google-aux-frontieres-du-reel_4601155_4408996.html');
+ $entry->setArchived(true);
+ $entry->addTag((new Tag())->setLabel('google'));
+ $entry->addTag((new Tag())->setLabel('apple'));
+ $em->persist($entry);
+ $em->flush();
+ $em->clear();
+
$this->client->request('POST', '/api/entries.json', [
'url' => 'http://www.lemonde.fr/pixels/article/2015/03/28/plongee-dans-l-univers-d-ingress-le-jeu-de-google-aux-frontieres-du-reel_4601155_4408996.html',
'archive' => '1',
public function testPostArchivedAndStarredEntry()
{
+ $now = new \DateTime();
$this->client->request('POST', '/api/entries.json', [
'url' => 'http://www.lemonde.fr/idees/article/2016/02/08/preserver-la-liberte-d-expression-sur-les-reseaux-sociaux_4861503_3232.html',
'archive' => '1',
$this->assertSame('http://www.lemonde.fr/idees/article/2016/02/08/preserver-la-liberte-d-expression-sur-les-reseaux-sociaux_4861503_3232.html', $content['url']);
$this->assertSame(1, $content['is_archived']);
$this->assertSame(1, $content['is_starred']);
+ $this->assertGreaterThanOrEqual($now->getTimestamp(), (new \DateTime($content['starred_at']))->getTimestamp());
$this->assertSame(1, $content['user_id']);
}
public function testSaveIsStarredAfterPatch()
{
+ $now = new \DateTime();
$entry = $this->client->getContainer()
->get('doctrine.orm.entity_manager')
->getRepository('WallabagCoreBundle:Entry')
$content = json_decode($this->client->getResponse()->getContent(), true);
$this->assertSame(1, $content['is_starred']);
+ $this->assertGreaterThanOrEqual($now->getTimestamp(), (new \DateTime($content['starred_at']))->getTimestamp());
}
public function dataForEntriesExistWithUrl()
$this->assertSame(400, $this->client->getResponse()->getStatusCode());
$this->assertContains('API limit reached', $this->client->getResponse()->getContent());
}
+
+ public function testRePostEntryAndReUsePublishedAt()
+ {
+ $em = $this->client->getContainer()->get('doctrine.orm.entity_manager');
+ $entry = new Entry($em->getReference(User::class, 1));
+ $entry->setTitle('Antoine de Caunes : « Je veux avoir le droit de tâtonner »');
+ $entry->setContent('hihi');
+ $entry->setUrl('http://www.lemonde.fr/m-perso/article/2017/06/25/antoine-de-caunes-je-veux-avoir-le-droit-de-tatonner_5150728_4497916.html');
+ $entry->setPublishedAt(new \DateTime('2017-06-26T07:46:02+0200'));
+ $em->persist($entry);
+ $em->flush();
+ $em->clear();
+
+ $this->client->request('POST', '/api/entries.json', [
+ 'url' => 'http://www.lemonde.fr/m-perso/article/2017/06/25/antoine-de-caunes-je-veux-avoir-le-droit-de-tatonner_5150728_4497916.html',
+ ]);
+
+ $this->assertSame(200, $this->client->getResponse()->getStatusCode());
+
+ $content = json_decode($this->client->getResponse()->getContent(), true);
+
+ $this->assertGreaterThan(0, $content['id']);
+ $this->assertSame('http://www.lemonde.fr/m-perso/article/2017/06/25/antoine-de-caunes-je-veux-avoir-le-droit-de-tatonner_5150728_4497916.html', $content['url']);
+ }
}