2016-02-07 15:52:59 +00:00
|
|
|
<?php
|
|
|
|
|
2024-02-19 00:30:12 +00:00
|
|
|
namespace Tests\Wallabag\Controller;
|
2016-02-07 15:52:59 +00:00
|
|
|
|
2022-08-28 00:01:46 +00:00
|
|
|
use Doctrine\ORM\EntityManagerInterface;
|
2023-12-25 17:37:15 +00:00
|
|
|
use Symfony\Bundle\FrameworkBundle\KernelBrowser;
|
2024-02-24 19:24:51 +00:00
|
|
|
use Tests\Wallabag\WallabagTestCase;
|
2024-02-19 00:30:12 +00:00
|
|
|
use Wallabag\Entity\Annotation;
|
|
|
|
use Wallabag\Entity\Entry;
|
|
|
|
use Wallabag\Entity\User;
|
2016-02-07 15:52:59 +00:00
|
|
|
|
2024-02-24 19:24:51 +00:00
|
|
|
class AnnotationControllerTest extends WallabagTestCase
|
2016-02-07 15:52:59 +00:00
|
|
|
{
|
2023-12-25 17:37:15 +00:00
|
|
|
/**
|
|
|
|
* @var KernelBrowser
|
|
|
|
*/
|
|
|
|
private $client;
|
|
|
|
|
|
|
|
protected function setUp(): void
|
|
|
|
{
|
|
|
|
parent::setUp();
|
|
|
|
|
|
|
|
$this->logInAs('admin');
|
|
|
|
|
|
|
|
$this->client = $this->getTestClient();
|
|
|
|
}
|
|
|
|
|
2016-10-22 10:09:20 +00:00
|
|
|
/**
|
|
|
|
* This data provider allow to tests annotation from the :
|
|
|
|
* - API POV (when user use the api to manage annotations)
|
2016-10-28 08:55:39 +00:00
|
|
|
* - and User POV (when user use the web interface - using javascript - to manage annotations).
|
2016-10-22 10:09:20 +00:00
|
|
|
*/
|
|
|
|
public function dataForEachAnnotations()
|
|
|
|
{
|
|
|
|
return [
|
|
|
|
['/api/annotations'],
|
|
|
|
['annotations'],
|
|
|
|
];
|
|
|
|
}
|
|
|
|
|
2016-10-09 12:01:28 +00:00
|
|
|
/**
|
2016-10-22 10:09:20 +00:00
|
|
|
* @dataProvider dataForEachAnnotations
|
2016-10-09 12:01:28 +00:00
|
|
|
*/
|
2016-10-22 10:09:20 +00:00
|
|
|
public function testGetAnnotations($prefixUrl)
|
2016-02-07 15:52:59 +00:00
|
|
|
{
|
2022-08-28 00:01:46 +00:00
|
|
|
$em = $this->client->getContainer()->get(EntityManagerInterface::class);
|
2016-10-22 10:09:20 +00:00
|
|
|
|
|
|
|
$user = $em
|
2022-08-25 19:37:10 +00:00
|
|
|
->getRepository(User::class)
|
2016-10-22 10:09:20 +00:00
|
|
|
->findOneByUserName('admin');
|
|
|
|
$entry = $em
|
2022-08-25 19:37:10 +00:00
|
|
|
->getRepository(Entry::class)
|
2023-01-23 11:16:09 +00:00
|
|
|
->findByUrlAndUserId('http://0.0.0.0/entry1', $user->getId());
|
2016-10-22 10:09:20 +00:00
|
|
|
|
|
|
|
if ('annotations' === $prefixUrl) {
|
|
|
|
$this->logInAs('admin');
|
2016-02-07 15:52:59 +00:00
|
|
|
}
|
2016-03-11 16:56:41 +00:00
|
|
|
|
2017-07-01 07:52:38 +00:00
|
|
|
$this->client->request('GET', $prefixUrl . '/' . $entry->getId() . '.json');
|
|
|
|
$this->assertSame(200, $this->client->getResponse()->getStatusCode());
|
2016-02-07 15:52:59 +00:00
|
|
|
|
|
|
|
$content = json_decode($this->client->getResponse()->getContent(), true);
|
2016-10-22 10:09:20 +00:00
|
|
|
$this->assertGreaterThanOrEqual(1, $content['total']);
|
2023-01-23 11:16:09 +00:00
|
|
|
}
|
2016-10-22 10:09:20 +00:00
|
|
|
|
2023-01-23 11:16:09 +00:00
|
|
|
/**
|
|
|
|
* @dataProvider dataForEachAnnotations
|
|
|
|
*/
|
|
|
|
public function testGetAnnotationsFromAnOtherUser($prefixUrl)
|
|
|
|
{
|
|
|
|
$em = $this->client->getContainer()->get('doctrine.orm.entity_manager');
|
|
|
|
|
|
|
|
$otherUser = $em
|
2023-04-24 12:36:32 +00:00
|
|
|
->getRepository(User::class)
|
2023-01-23 11:16:09 +00:00
|
|
|
->findOneByUserName('bob');
|
|
|
|
$entry = $em
|
2023-04-24 12:36:32 +00:00
|
|
|
->getRepository(Entry::class)
|
2023-01-23 11:16:09 +00:00
|
|
|
->findByUrlAndUserId('http://0.0.0.0/entry3', $otherUser->getId());
|
|
|
|
|
|
|
|
if ('annotations' === $prefixUrl) {
|
|
|
|
$this->logInAs('admin');
|
|
|
|
}
|
|
|
|
|
|
|
|
$this->client->request('GET', $prefixUrl . '/' . $entry->getId() . '.json');
|
|
|
|
$this->assertSame(200, $this->client->getResponse()->getStatusCode());
|
|
|
|
|
|
|
|
$content = json_decode($this->client->getResponse()->getContent(), true);
|
|
|
|
$this->assertGreaterThanOrEqual(0, $content['total']);
|
2016-02-07 15:52:59 +00:00
|
|
|
}
|
|
|
|
|
2016-10-09 12:01:28 +00:00
|
|
|
/**
|
2016-10-22 10:09:20 +00:00
|
|
|
* @dataProvider dataForEachAnnotations
|
2016-10-09 12:01:28 +00:00
|
|
|
*/
|
2016-10-22 10:09:20 +00:00
|
|
|
public function testSetAnnotation($prefixUrl)
|
2016-02-07 15:52:59 +00:00
|
|
|
{
|
2022-08-28 00:01:46 +00:00
|
|
|
$em = $this->client->getContainer()->get(EntityManagerInterface::class);
|
2016-10-22 10:09:20 +00:00
|
|
|
|
2023-01-23 11:16:09 +00:00
|
|
|
$user = $em
|
2023-04-24 12:36:32 +00:00
|
|
|
->getRepository(User::class)
|
2023-01-23 11:16:09 +00:00
|
|
|
->findOneByUserName('admin');
|
|
|
|
|
2016-10-22 10:09:20 +00:00
|
|
|
if ('annotations' === $prefixUrl) {
|
|
|
|
$this->logInAs('admin');
|
|
|
|
}
|
2016-02-07 15:52:59 +00:00
|
|
|
|
2016-10-09 12:01:28 +00:00
|
|
|
/** @var Entry $entry */
|
2016-10-22 10:09:20 +00:00
|
|
|
$entry = $em
|
2022-08-25 19:37:10 +00:00
|
|
|
->getRepository(Entry::class)
|
2016-03-11 16:56:41 +00:00
|
|
|
->findOneByUsernameAndNotArchived('admin');
|
2016-02-07 15:52:59 +00:00
|
|
|
|
2016-04-12 09:36:01 +00:00
|
|
|
$headers = ['CONTENT_TYPE' => 'application/json'];
|
|
|
|
$content = json_encode([
|
2016-02-26 12:59:08 +00:00
|
|
|
'text' => 'my annotation',
|
2016-02-07 15:52:59 +00:00
|
|
|
'quote' => 'my quote',
|
2017-05-07 15:21:30 +00:00
|
|
|
'ranges' => [
|
2017-06-07 21:23:34 +00:00
|
|
|
['start' => '', 'startOffset' => 24, 'end' => '', 'endOffset' => 31],
|
2017-05-07 15:21:30 +00:00
|
|
|
],
|
2016-04-12 09:36:01 +00:00
|
|
|
]);
|
2017-07-01 07:52:38 +00:00
|
|
|
$this->client->request('POST', $prefixUrl . '/' . $entry->getId() . '.json', [], [], $headers, $content);
|
2016-02-07 15:52:59 +00:00
|
|
|
|
2017-07-01 07:52:38 +00:00
|
|
|
$this->assertSame(200, $this->client->getResponse()->getStatusCode());
|
2016-02-07 15:52:59 +00:00
|
|
|
|
2016-03-11 16:56:41 +00:00
|
|
|
$content = json_decode($this->client->getResponse()->getContent(), true);
|
|
|
|
|
2017-07-01 07:52:38 +00:00
|
|
|
$this->assertSame('Big boss', $content['user']);
|
|
|
|
$this->assertSame('v1.0', $content['annotator_schema_version']);
|
|
|
|
$this->assertSame('my annotation', $content['text']);
|
|
|
|
$this->assertSame('my quote', $content['quote']);
|
2016-03-11 16:56:41 +00:00
|
|
|
|
2016-10-09 12:01:28 +00:00
|
|
|
/** @var Annotation $annotation */
|
2018-11-26 21:22:49 +00:00
|
|
|
$annotation = $em
|
2022-08-25 19:37:10 +00:00
|
|
|
->getRepository(Annotation::class)
|
2023-01-23 11:16:09 +00:00
|
|
|
->findLastAnnotationByUserId($entry->getId(), $user->getId());
|
2016-02-07 15:52:59 +00:00
|
|
|
|
2017-07-01 07:52:38 +00:00
|
|
|
$this->assertSame('my annotation', $annotation->getText());
|
2016-02-07 15:52:59 +00:00
|
|
|
}
|
|
|
|
|
2019-11-27 13:04:11 +00:00
|
|
|
public function testAllowEmptyQuote()
|
2019-10-27 17:51:32 +00:00
|
|
|
{
|
2022-08-28 00:01:46 +00:00
|
|
|
$em = $this->client->getContainer()->get(EntityManagerInterface::class);
|
2019-10-27 17:51:32 +00:00
|
|
|
|
|
|
|
/** @var Entry $entry */
|
|
|
|
$entry = $em
|
2022-08-25 19:37:10 +00:00
|
|
|
->getRepository(Entry::class)
|
2019-10-27 17:51:32 +00:00
|
|
|
->findOneByUsernameAndNotArchived('admin');
|
|
|
|
|
|
|
|
$headers = ['CONTENT_TYPE' => 'application/json'];
|
|
|
|
$content = json_encode([
|
|
|
|
'text' => 'my annotation',
|
|
|
|
'quote' => null,
|
|
|
|
'ranges' => [
|
|
|
|
['start' => '', 'startOffset' => 24, 'end' => '', 'endOffset' => 31],
|
|
|
|
],
|
|
|
|
]);
|
|
|
|
$this->client->request('POST', '/api/annotations/' . $entry->getId() . '.json', [], [], $headers, $content);
|
|
|
|
|
2019-11-27 13:04:11 +00:00
|
|
|
$this->assertSame(200, $this->client->getResponse()->getStatusCode());
|
2019-10-27 17:51:32 +00:00
|
|
|
|
|
|
|
$content = json_decode($this->client->getResponse()->getContent(), true);
|
|
|
|
|
2019-11-27 13:04:11 +00:00
|
|
|
$this->assertSame('Big boss', $content['user']);
|
|
|
|
$this->assertSame('v1.0', $content['annotator_schema_version']);
|
|
|
|
$this->assertSame('my annotation', $content['text']);
|
|
|
|
$this->assertSame('', $content['quote']);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testAllowOmmittedQuote()
|
|
|
|
{
|
2022-08-28 00:01:46 +00:00
|
|
|
$em = $this->client->getContainer()->get(EntityManagerInterface::class);
|
2019-11-27 13:04:11 +00:00
|
|
|
|
|
|
|
/** @var Entry $entry */
|
|
|
|
$entry = $em
|
2022-08-25 19:37:10 +00:00
|
|
|
->getRepository(Entry::class)
|
2019-11-27 13:04:11 +00:00
|
|
|
->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']);
|
2019-10-27 17:51:32 +00:00
|
|
|
}
|
|
|
|
|
2017-05-07 15:21:30 +00:00
|
|
|
/**
|
|
|
|
* @dataProvider dataForEachAnnotations
|
|
|
|
*/
|
|
|
|
public function testSetAnnotationWithQuoteTooLong($prefixUrl)
|
|
|
|
{
|
2022-08-28 00:01:46 +00:00
|
|
|
$em = $this->client->getContainer()->get(EntityManagerInterface::class);
|
2017-05-07 15:21:30 +00:00
|
|
|
|
|
|
|
if ('annotations' === $prefixUrl) {
|
|
|
|
$this->logInAs('admin');
|
|
|
|
}
|
|
|
|
|
|
|
|
/** @var Entry $entry */
|
|
|
|
$entry = $em
|
2022-08-25 19:37:10 +00:00
|
|
|
->getRepository(Entry::class)
|
2017-05-07 15:21:30 +00:00
|
|
|
->findOneByUsernameAndNotArchived('admin');
|
|
|
|
|
|
|
|
$longQuote = str_repeat('a', 10001);
|
|
|
|
$headers = ['CONTENT_TYPE' => 'application/json'];
|
|
|
|
$content = json_encode([
|
|
|
|
'text' => 'my annotation',
|
|
|
|
'quote' => $longQuote,
|
|
|
|
'ranges' => [
|
2017-06-07 21:23:34 +00:00
|
|
|
['start' => '', 'startOffset' => 24, 'end' => '', 'endOffset' => 31],
|
2017-05-07 15:21:30 +00:00
|
|
|
],
|
|
|
|
]);
|
2017-07-01 07:52:38 +00:00
|
|
|
$this->client->request('POST', $prefixUrl . '/' . $entry->getId() . '.json', [], [], $headers, $content);
|
2017-05-07 15:21:30 +00:00
|
|
|
|
2017-07-01 07:52:38 +00:00
|
|
|
$this->assertSame(400, $this->client->getResponse()->getStatusCode());
|
2017-05-07 15:21:30 +00:00
|
|
|
}
|
|
|
|
|
2016-10-09 12:01:28 +00:00
|
|
|
/**
|
2016-10-22 10:09:20 +00:00
|
|
|
* @dataProvider dataForEachAnnotations
|
2016-10-09 12:01:28 +00:00
|
|
|
*/
|
2016-10-22 10:09:20 +00:00
|
|
|
public function testEditAnnotation($prefixUrl)
|
2016-02-07 15:52:59 +00:00
|
|
|
{
|
2022-08-28 00:01:46 +00:00
|
|
|
$em = $this->client->getContainer()->get(EntityManagerInterface::class);
|
2016-10-22 10:09:20 +00:00
|
|
|
|
|
|
|
$user = $em
|
2022-08-25 19:37:10 +00:00
|
|
|
->getRepository(User::class)
|
2016-10-22 10:09:20 +00:00
|
|
|
->findOneByUserName('admin');
|
|
|
|
$entry = $em
|
2022-08-25 19:37:10 +00:00
|
|
|
->getRepository(Entry::class)
|
2016-10-22 10:09:20 +00:00
|
|
|
->findOneByUsernameAndNotArchived('admin');
|
2016-02-07 15:52:59 +00:00
|
|
|
|
2016-10-22 10:09:20 +00:00
|
|
|
$annotation = new Annotation($user);
|
|
|
|
$annotation->setEntry($entry);
|
|
|
|
$annotation->setText('This is my annotation /o/');
|
|
|
|
$annotation->setQuote('my quote');
|
|
|
|
|
|
|
|
$em->persist($annotation);
|
|
|
|
$em->flush();
|
2016-02-07 15:52:59 +00:00
|
|
|
|
2016-04-12 09:36:01 +00:00
|
|
|
$headers = ['CONTENT_TYPE' => 'application/json'];
|
|
|
|
$content = json_encode([
|
2016-02-26 12:59:08 +00:00
|
|
|
'text' => 'a modified annotation',
|
2016-04-12 09:36:01 +00:00
|
|
|
]);
|
2017-07-01 07:52:38 +00:00
|
|
|
$this->client->request('PUT', $prefixUrl . '/' . $annotation->getId() . '.json', [], [], $headers, $content);
|
|
|
|
$this->assertSame(200, $this->client->getResponse()->getStatusCode());
|
2016-02-07 15:52:59 +00:00
|
|
|
|
|
|
|
$content = json_decode($this->client->getResponse()->getContent(), true);
|
|
|
|
|
2017-07-01 07:52:38 +00:00
|
|
|
$this->assertSame('Big boss', $content['user']);
|
|
|
|
$this->assertSame('v1.0', $content['annotator_schema_version']);
|
|
|
|
$this->assertSame('a modified annotation', $content['text']);
|
|
|
|
$this->assertSame('my quote', $content['quote']);
|
2016-02-07 15:52:59 +00:00
|
|
|
|
2016-10-09 12:01:28 +00:00
|
|
|
/** @var Annotation $annotationUpdated */
|
2016-10-22 10:09:20 +00:00
|
|
|
$annotationUpdated = $em
|
2022-08-25 19:37:10 +00:00
|
|
|
->getRepository(Annotation::class)
|
2016-03-11 16:56:41 +00:00
|
|
|
->findOneById($annotation->getId());
|
2017-07-01 07:52:38 +00:00
|
|
|
$this->assertSame('a modified annotation', $annotationUpdated->getText());
|
2016-10-22 10:09:20 +00:00
|
|
|
|
|
|
|
$em->remove($annotationUpdated);
|
|
|
|
$em->flush();
|
2016-02-07 15:52:59 +00:00
|
|
|
}
|
2016-03-11 16:56:41 +00:00
|
|
|
|
2016-10-09 12:01:28 +00:00
|
|
|
/**
|
2023-01-23 11:16:09 +00:00
|
|
|
* @dataProvider dataForEachAnnotations
|
|
|
|
*/
|
|
|
|
public function testEditAnnotationFromAnOtherUser($prefixUrl)
|
|
|
|
{
|
|
|
|
$em = $this->client->getContainer()->get('doctrine.orm.entity_manager');
|
|
|
|
|
|
|
|
$otherUser = $em
|
2023-04-24 12:36:32 +00:00
|
|
|
->getRepository(User::class)
|
2023-01-23 11:16:09 +00:00
|
|
|
->findOneByUserName('bob');
|
|
|
|
$entry = $em
|
2023-04-24 12:36:32 +00:00
|
|
|
->getRepository(Entry::class)
|
2023-01-23 11:16:09 +00:00
|
|
|
->findByUrlAndUserId('http://0.0.0.0/entry3', $otherUser->getId());
|
|
|
|
$annotation = $em
|
2023-04-24 12:36:32 +00:00
|
|
|
->getRepository(Annotation::class)
|
2023-01-23 11:16:09 +00:00
|
|
|
->findLastAnnotationByUserId($entry->getId(), $otherUser->getId());
|
|
|
|
|
|
|
|
$headers = ['CONTENT_TYPE' => 'application/json'];
|
|
|
|
$content = json_encode([
|
|
|
|
'text' => 'a modified annotation',
|
|
|
|
]);
|
|
|
|
$this->client->request('PUT', $prefixUrl . '/' . $annotation->getId() . '.json', [], [], $headers, $content);
|
|
|
|
$this->assertSame(404, $this->client->getResponse()->getStatusCode());
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2016-10-22 10:09:20 +00:00
|
|
|
* @dataProvider dataForEachAnnotations
|
2016-10-09 12:01:28 +00:00
|
|
|
*/
|
2016-10-22 10:09:20 +00:00
|
|
|
public function testDeleteAnnotation($prefixUrl)
|
2016-03-11 16:56:41 +00:00
|
|
|
{
|
2022-08-28 00:01:46 +00:00
|
|
|
$em = $this->client->getContainer()->get(EntityManagerInterface::class);
|
2016-10-22 10:09:20 +00:00
|
|
|
|
|
|
|
$user = $em
|
2022-08-25 19:37:10 +00:00
|
|
|
->getRepository(User::class)
|
2016-10-22 10:09:20 +00:00
|
|
|
->findOneByUserName('admin');
|
|
|
|
$entry = $em
|
2022-08-25 19:37:10 +00:00
|
|
|
->getRepository(Entry::class)
|
2016-10-22 10:09:20 +00:00
|
|
|
->findOneByUsernameAndNotArchived('admin');
|
2016-03-11 16:56:41 +00:00
|
|
|
|
2016-10-22 10:09:20 +00:00
|
|
|
$annotation = new Annotation($user);
|
|
|
|
$annotation->setEntry($entry);
|
|
|
|
$annotation->setText('This is my annotation /o/');
|
|
|
|
$annotation->setQuote('my quote');
|
|
|
|
|
|
|
|
$em->persist($annotation);
|
|
|
|
$em->flush();
|
|
|
|
|
|
|
|
if ('annotations' === $prefixUrl) {
|
|
|
|
$this->logInAs('admin');
|
|
|
|
}
|
2016-03-11 16:56:41 +00:00
|
|
|
|
2016-04-12 09:36:01 +00:00
|
|
|
$headers = ['CONTENT_TYPE' => 'application/json'];
|
|
|
|
$content = json_encode([
|
2016-03-11 16:56:41 +00:00
|
|
|
'text' => 'a modified annotation',
|
2016-04-12 09:36:01 +00:00
|
|
|
]);
|
2017-07-01 07:52:38 +00:00
|
|
|
$this->client->request('DELETE', $prefixUrl . '/' . $annotation->getId() . '.json', [], [], $headers, $content);
|
|
|
|
$this->assertSame(200, $this->client->getResponse()->getStatusCode());
|
2016-03-11 16:56:41 +00:00
|
|
|
|
|
|
|
$content = json_decode($this->client->getResponse()->getContent(), true);
|
|
|
|
|
2017-07-01 07:52:38 +00:00
|
|
|
$this->assertSame('This is my annotation /o/', $content['text']);
|
2016-03-11 16:56:41 +00:00
|
|
|
|
2016-10-22 10:09:20 +00:00
|
|
|
$annotationDeleted = $em
|
2022-08-25 19:37:10 +00:00
|
|
|
->getRepository(Annotation::class)
|
2016-03-11 16:56:41 +00:00
|
|
|
->findOneById($annotation->getId());
|
|
|
|
|
|
|
|
$this->assertNull($annotationDeleted);
|
|
|
|
}
|
2023-01-23 11:16:09 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @dataProvider dataForEachAnnotations
|
|
|
|
*/
|
|
|
|
public function testDeleteAnnotationFromAnOtherUser($prefixUrl)
|
|
|
|
{
|
|
|
|
$em = $this->client->getContainer()->get('doctrine.orm.entity_manager');
|
|
|
|
|
|
|
|
$otherUser = $em
|
2023-04-24 12:36:32 +00:00
|
|
|
->getRepository(User::class)
|
2023-01-23 11:16:09 +00:00
|
|
|
->findOneByUserName('bob');
|
|
|
|
$entry = $em
|
2023-04-24 12:36:32 +00:00
|
|
|
->getRepository(Entry::class)
|
2023-01-23 11:16:09 +00:00
|
|
|
->findByUrlAndUserId('http://0.0.0.0/entry3', $otherUser->getId());
|
|
|
|
$annotation = $em
|
2023-04-24 12:36:32 +00:00
|
|
|
->getRepository(Annotation::class)
|
2023-01-23 11:16:09 +00:00
|
|
|
->findLastAnnotationByUserId($entry->getId(), $otherUser->getId());
|
|
|
|
|
|
|
|
$user = $em
|
2023-04-24 12:36:32 +00:00
|
|
|
->getRepository(User::class)
|
2023-01-23 11:16:09 +00:00
|
|
|
->findOneByUserName('admin');
|
|
|
|
$entry = $em
|
2023-04-24 12:36:32 +00:00
|
|
|
->getRepository(Entry::class)
|
2023-01-23 11:16:09 +00:00
|
|
|
->findOneByUsernameAndNotArchived('admin');
|
|
|
|
|
|
|
|
if ('annotations' === $prefixUrl) {
|
|
|
|
$this->logInAs('admin');
|
|
|
|
}
|
|
|
|
|
|
|
|
$headers = ['CONTENT_TYPE' => 'application/json'];
|
|
|
|
$content = json_encode([
|
|
|
|
'text' => 'a modified annotation',
|
|
|
|
]);
|
|
|
|
$this->client->request('DELETE', $prefixUrl . '/' . $annotation->getId() . '.json', [], [], $headers, $content);
|
|
|
|
$this->assertSame(404, $this->client->getResponse()->getStatusCode());
|
|
|
|
}
|
2016-02-07 15:52:59 +00:00
|
|
|
}
|