mirror of
https://github.com/wallabag/wallabag.git
synced 2025-08-06 17:41:01 +00:00
Fix tests
This commit is contained in:
parent
86c1751186
commit
6a0d49ab7a
1 changed files with 34 additions and 7 deletions
|
@ -107,7 +107,7 @@ class AnnotationControllerTest extends WallabagAnnotationTestCase
|
||||||
$this->assertSame('my annotation', $annotation->getText());
|
$this->assertSame('my annotation', $annotation->getText());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testCouldNotSetAnnotationWithoutQuote()
|
public function testAllowEmptyQuote()
|
||||||
{
|
{
|
||||||
$em = $this->client->getContainer()->get('doctrine.orm.entity_manager');
|
$em = $this->client->getContainer()->get('doctrine.orm.entity_manager');
|
||||||
|
|
||||||
|
@ -126,15 +126,42 @@ class AnnotationControllerTest extends WallabagAnnotationTestCase
|
||||||
]);
|
]);
|
||||||
$this->client->request('POST', '/api/annotations/' . $entry->getId() . '.json', [], [], $headers, $content);
|
$this->client->request('POST', '/api/annotations/' . $entry->getId() . '.json', [], [], $headers, $content);
|
||||||
|
|
||||||
$this->assertSame(400, $this->client->getResponse()->getStatusCode());
|
$this->assertSame(200, $this->client->getResponse()->getStatusCode());
|
||||||
|
|
||||||
$content = json_decode($this->client->getResponse()->getContent(), true);
|
$content = json_decode($this->client->getResponse()->getContent(), true);
|
||||||
|
|
||||||
$this->assertCount(
|
$this->assertSame('Big boss', $content['user']);
|
||||||
1,
|
$this->assertSame('v1.0', $content['annotator_schema_version']);
|
||||||
$content['errors']['children']['quote']['errors'],
|
$this->assertSame('my annotation', $content['text']);
|
||||||
'The quote field should contains an error'
|
$this->assertSame('', $content['quote']);
|
||||||
);
|
}
|
||||||
|
|
||||||
|
public function testAllowOmmittedQuote()
|
||||||
|
{
|
||||||
|
$em = $this->client->getContainer()->get('doctrine.orm.entity_manager');
|
||||||
|
|
||||||
|
/** @var Entry $entry */
|
||||||
|
$entry = $em
|
||||||
|
->getRepository('WallabagCoreBundle:Entry')
|
||||||
|
->findOneByUsernameAndNotArchived('admin');
|
||||||
|
|
||||||
|
$headers = ['CONTENT_TYPE' => 'application/json'];
|
||||||
|
$content = json_encode([
|
||||||
|
'text' => 'my new annotation',
|
||||||
|
'ranges' => [
|
||||||
|
['start' => '', 'startOffset' => 25, 'end' => '', 'endOffset' => 32],
|
||||||
|
],
|
||||||
|
]);
|
||||||
|
$this->client->request('POST', '/api/annotations/' . $entry->getId() . '.json', [], [], $headers, $content);
|
||||||
|
|
||||||
|
$this->assertSame(200, $this->client->getResponse()->getStatusCode());
|
||||||
|
|
||||||
|
$content = json_decode($this->client->getResponse()->getContent(), true);
|
||||||
|
|
||||||
|
$this->assertSame('Big boss', $content['user']);
|
||||||
|
$this->assertSame('v1.0', $content['annotator_schema_version']);
|
||||||
|
$this->assertSame('my new annotation', $content['text']);
|
||||||
|
$this->assertSame('', $content['quote']);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue