mirror of
https://github.com/wallabag/wallabag.git
synced 2024-11-26 11:01:04 +00:00
Improve EntryRestControllerTest for origin_url
Ensure that origin_url is initially null Ensure patching entry with origin_url='' Ensure patching entry with origin_url=null Signed-off-by: Kevin Decherf <kevin@kdecherf.com>
This commit is contained in:
parent
97444566db
commit
65152fcb89
1 changed files with 55 additions and 0 deletions
|
@ -440,6 +440,7 @@ class EntryRestControllerTest extends WallabagApiTestCase
|
|||
$this->assertSame('New title for my article', $content['title']);
|
||||
$this->assertSame(1, $content['user_id']);
|
||||
$this->assertCount(2, $content['tags']);
|
||||
$this->assertNull($content['origin_url']);
|
||||
$this->assertSame('my content', $content['content']);
|
||||
$this->assertSame('de', $content['language']);
|
||||
$this->assertSame('2016-09-08T11:55:58+0200', $content['published_at']);
|
||||
|
@ -680,6 +681,60 @@ class EntryRestControllerTest extends WallabagApiTestCase
|
|||
$this->assertSame($previousLanguage, $content['language'], 'Ensure language has not moved');
|
||||
}
|
||||
|
||||
public function testPatchEntryRemoveOriginUrl()
|
||||
{
|
||||
$entry = $this->client->getContainer()
|
||||
->get('doctrine.orm.entity_manager')
|
||||
->getRepository('WallabagCoreBundle:Entry')
|
||||
->findOneByUser(1);
|
||||
|
||||
if (!$entry) {
|
||||
$this->markTestSkipped('No content found in db.');
|
||||
}
|
||||
|
||||
$previousContent = $entry->getContent();
|
||||
$previousLanguage = $entry->getLanguage();
|
||||
$previousTitle = $entry->getTitle();
|
||||
|
||||
$this->client->request('PATCH', '/api/entries/' . $entry->getId() . '.json', [
|
||||
'origin_url' => '',
|
||||
]);
|
||||
|
||||
$this->assertSame(200, $this->client->getResponse()->getStatusCode());
|
||||
|
||||
$content = json_decode($this->client->getResponse()->getContent(), true);
|
||||
|
||||
$this->assertSame($entry->getId(), $content['id']);
|
||||
$this->assertSame($entry->getUrl(), $content['url']);
|
||||
$this->assertEmpty($content['origin_url']);
|
||||
$this->assertEmpty($content['published_by'], 'Authors were not saved because of an array instead of a string');
|
||||
$this->assertSame($previousContent, $content['content'], 'Ensure content has not moved');
|
||||
$this->assertSame($previousLanguage, $content['language'], 'Ensure language has not moved');
|
||||
$this->assertSame($previousTitle, $content['title'], 'Ensure title has not moved');
|
||||
}
|
||||
|
||||
public function testPatchEntryNullOriginUrl()
|
||||
{
|
||||
$entry = $this->client->getContainer()
|
||||
->get('doctrine.orm.entity_manager')
|
||||
->getRepository('WallabagCoreBundle:Entry')
|
||||
->findOneByUser(1);
|
||||
|
||||
if (!$entry) {
|
||||
$this->markTestSkipped('No content found in db.');
|
||||
}
|
||||
|
||||
$this->client->request('PATCH', '/api/entries/' . $entry->getId() . '.json', [
|
||||
'origin_url' => null,
|
||||
]);
|
||||
|
||||
$this->assertSame(200, $this->client->getResponse()->getStatusCode());
|
||||
|
||||
$content = json_decode($this->client->getResponse()->getContent(), true);
|
||||
|
||||
$this->assertNull($content['origin_url']);
|
||||
}
|
||||
|
||||
public function testGetTagsEntry()
|
||||
{
|
||||
$entry = $this->client->getContainer()
|
||||
|
|
Loading…
Reference in a new issue