Find this useful? Enter your email to receive occasional updates for securing PHP code.
Signing you up...
Thank you for signing up!
PHP Decode
<?php namespace Tests\Wallabag\Controller\Api; use Doctrine\ORM\EntityManagerInterface; u..
Decoded Output download
<?php
namespace Tests\Wallabag\Controller\Api; use Doctrine\ORM\EntityManagerInterface; use Symfony\Component\DependencyInjection\Container; use Wallabag\Entity\Entry; use Wallabag\Entity\Tag; use Wallabag\Entity\User; use Wallabag\Helper\ContentProxy; class EntryRestControllerTest extends WallabagApiTestCase { public function testGetOneEntry() { $entry = $this->client->getContainer()->get(EntityManagerInterface::class)->getRepository(Entry::class)->findOneBy(array("user" => $this->getUserId(), "isArchived" => false)); if (!$entry) { $this->markTestSkipped("No content found in db."); } $this->client->request("GET", "/api/entries/" . $entry->getId() . ".json"); $this->assertSame(200, $this->client->getResponse()->getStatusCode()); $content = json_decode($this->client->getResponse()->getContent(), true); $this->assertSame($entry->getTitle(), $content["title"]); $this->assertSame($entry->getUrl(), $content["url"]); $this->assertCount(\count($entry->getTags()), $content["tags"]); $this->assertSame($entry->getUserName(), $content["user_name"]); $this->assertSame($entry->getUserEmail(), $content["user_email"]); $this->assertSame($entry->getUserId(), $content["user_id"]); $this->assertSame("application/json", $this->client->getResponse()->headers->get("Content-Type")); } public function testGetOneEntryWithOriginUrl() { $entry = $this->client->getContainer()->get(EntityManagerInterface::class)->getRepository(Entry::class)->findOneBy(array("user" => $this->getUserId(), "url" => "http://0.0.0.0/entry2")); if (!$entry) { $this->markTestSkipped("No content found in db."); } $this->client->request("GET", "/api/entries/" . $entry->getId() . ".json"); $this->assertSame(200, $this->client->getResponse()->getStatusCode()); $content = json_decode($this->client->getResponse()->getContent(), true); $this->assertSame($entry->getOriginUrl(), $content["origin_url"]); } public function testExportEntry() { $entry = $this->client->getContainer()->get(EntityManagerInterface::class)->getRepository(Entry::class)->findOneBy(array("user" => $this->getUserId(), "isArchived" => false)); if (!$entry) { $this->markTestSkipped("No content found in db."); } $this->client->request("GET", "/api/entries/" . $entry->getId() . "/export.epub"); $this->assertSame(200, $this->client->getResponse()->getStatusCode()); $this->assertStringContainsString("application/epub", $this->client->getResponse()->getContent()); $this->assertSame("application/epub+zip", $this->client->getResponse()->headers->get("Content-Type")); $client = $this->createAuthorizedClient(); $client->request("GET", "/api/entries/" . $entry->getId() . "/export.pdf"); $this->assertSame(200, $client->getResponse()->getStatusCode()); $this->assertStringContainsString("PDF-", $client->getResponse()->getContent()); $this->assertSame("application/pdf", $client->getResponse()->headers->get("Content-Type")); $client = $this->createAuthorizedClient(); $client->request("GET", "/api/entries/" . $entry->getId() . "/export.txt"); $this->assertSame(200, $client->getResponse()->getStatusCode()); $this->assertStringContainsString("text/plain", $client->getResponse()->headers->get("Content-Type")); $client = $this->createAuthorizedClient(); $client->request("GET", "/api/entries/" . $entry->getId() . "/export.csv"); $this->assertSame(200, $client->getResponse()->getStatusCode()); $this->assertStringContainsString("application/csv", $client->getResponse()->headers->get("Content-Type")); } public function testGetOneEntryWrongUser() { $entry = $this->client->getContainer()->get(EntityManagerInterface::class)->getRepository(Entry::class)->findOneBy(array("user" => $this->getUserId("bob"), "isArchived" => false)); if (!$entry) { $this->markTestSkipped("No content found in db."); } $this->client->request("GET", "/api/entries/" . $entry->getId() . ".json"); $this->assertSame(403, $this->client->getResponse()->getStatusCode()); } public function testGetEntries() { $this->client->request("GET", "/api/entries"); $this->assertSame(200, $this->client->getResponse()->getStatusCode()); $content = json_decode($this->client->getResponse()->getContent(), true); $this->assertGreaterThanOrEqual(1, \count($content)); $this->assertNotEmpty($content["_embedded"]["items"]); $this->assertGreaterThanOrEqual(1, $content["total"]); $this->assertSame(1, $content["page"]); $this->assertGreaterThanOrEqual(1, $content["pages"]); $this->assertNotNull($content["_embedded"]["items"][0]["content"]); $this->assertSame("application/json", $this->client->getResponse()->headers->get("Content-Type")); } public function testGetEntriesDetailMetadata() { $this->client->request("GET", "/api/entries?detail=metadata"); $this->assertSame(200, $this->client->getResponse()->getStatusCode()); $content = json_decode($this->client->getResponse()->getContent(), true); $this->assertGreaterThanOrEqual(1, \count($content)); $this->assertNotEmpty($content["_embedded"]["items"]); $this->assertGreaterThanOrEqual(1, $content["total"]); $this->assertSame(1, $content["page"]); $this->assertGreaterThanOrEqual(1, $content["pages"]); $this->assertNull($content["_embedded"]["items"][0]["content"]); $this->assertSame("application/json", $this->client->getResponse()->headers->get("Content-Type")); } public function testGetEntriesByDomainName() { $this->client->request("GET", "/api/entries?domain_name=domain.io"); $this->assertSame(200, $this->client->getResponse()->getStatusCode()); $content = json_decode($this->client->getResponse()->getContent(), true); $this->assertGreaterThanOrEqual(1, \count($content)); $this->assertNotEmpty($content["_embedded"]["items"]); $this->assertGreaterThanOrEqual(1, $content["total"]); $this->assertSame(1, $content["page"]); $this->assertGreaterThanOrEqual(1, $content["pages"]); $this->assertSame("test title entry6", $content["_embedded"]["items"][0]["title"]); $this->assertSame("application/json", $this->client->getResponse()->headers->get("Content-Type")); } public function testGetEntriesWithFullOptions() { $this->client->request("GET", "/api/entries", array("archive" => 1, "starred" => 1, "sort" => "updated", "order" => "asc", "page" => 1, "perPage" => 2, "tags" => "foo", "since" => 1443274283, "public" => 0, "notParsed" => 0)); $this->assertSame(200, $this->client->getResponse()->getStatusCode()); $content = json_decode($this->client->getResponse()->getContent(), true); $this->assertGreaterThanOrEqual(1, \count($content)); $this->assertArrayHasKey("items", $content["_embedded"]); $this->assertGreaterThanOrEqual(0, $content["total"]); $this->assertSame(1, $content["page"]); $this->assertSame(2, $content["limit"]); $this->assertGreaterThanOrEqual(1, $content["pages"]); $this->assertArrayHasKey("_links", $content); $this->assertArrayHasKey("self", $content["_links"]); $this->assertArrayHasKey("first", $content["_links"]); $this->assertArrayHasKey("last", $content["_links"]); foreach (array("self", "first", "last") as $link) { $this->assertArrayHasKey("href", $content["_links"][$link]); $this->assertStringContainsString("archive=1", $content["_links"][$link]["href"]); $this->assertStringContainsString("starred=1", $content["_links"][$link]["href"]); $this->assertStringContainsString("sort=updated", $content["_links"][$link]["href"]); $this->assertStringContainsString("order=asc", $content["_links"][$link]["href"]); $this->assertStringContainsString("tags=foo", $content["_links"][$link]["href"]); $this->assertStringContainsString("since=1443274283", $content["_links"][$link]["href"]); $this->assertStringContainsString("public=0", $content["_links"][$link]["href"]); } $this->assertSame("application/json", $this->client->getResponse()->headers->get("Content-Type")); } public function testGetEntriesPublicOnly() { $entry = $this->client->getContainer()->get(EntityManagerInterface::class)->getRepository(Entry::class)->findOneByUser($this->getUserId()); if (!$entry) { $this->markTestSkipped("No content found in db."); } $entry->generateUid(); $em = $this->client->getContainer()->get(EntityManagerInterface::class); $em->persist($entry); $em->flush(); $this->client->request("GET", "/api/entries", array("public" => 1)); $this->assertSame(200, $this->client->getResponse()->getStatusCode()); $content = json_decode($this->client->getResponse()->getContent(), true); $this->assertGreaterThanOrEqual(1, \count($content)); $this->assertArrayHasKey("items", $content["_embedded"]); $this->assertGreaterThanOrEqual(1, $content["total"]); $this->assertSame(1, $content["page"]); $this->assertSame(30, $content["limit"]); $this->assertGreaterThanOrEqual(1, $content["pages"]); $this->assertArrayHasKey("_links", $content); $this->assertArrayHasKey("self", $content["_links"]); $this->assertArrayHasKey("first", $content["_links"]); $this->assertArrayHasKey("last", $content["_links"]); foreach (array("self", "first", "last") as $link) { $this->assertArrayHasKey("href", $content["_links"][$link]); $this->assertStringContainsString("public=1", $content["_links"][$link]["href"]); } $this->assertSame("application/json", $this->client->getResponse()->headers->get("Content-Type")); } public function testGetEntriesOnPageTwo() { $this->client->request("GET", "/api/entries", array("page" => 2, "perPage" => 2)); $this->assertSame(200, $this->client->getResponse()->getStatusCode()); $content = json_decode($this->client->getResponse()->getContent(), true); $this->assertGreaterThanOrEqual(0, $content["total"]); $this->assertSame(2, $content["page"]); $this->assertSame(2, $content["limit"]); } public function testGetStarredEntriesWithBadSort() { $this->client->request("GET", "/api/entries", array("starred" => 1, "sort" => "updated", "order" => "unknown")); $this->assertSame(400, $this->client->getResponse()->getStatusCode()); $this->assertSame("application/json", $this->client->getResponse()->headers->get("Content-Type")); } public function testGetStarredEntries() { $this->client->request("GET", "/api/entries", array("starred" => 1, "sort" => "updated")); $this->assertSame(200, $this->client->getResponse()->getStatusCode()); $content = json_decode($this->client->getResponse()->getContent(), true); $this->assertGreaterThanOrEqual(1, \count($content)); $this->assertNotEmpty($content["_embedded"]["items"]); $this->assertGreaterThanOrEqual(1, $content["total"]); $this->assertSame(1, $content["page"]); $this->assertGreaterThanOrEqual(1, $content["pages"]); $this->assertArrayHasKey("_links", $content); $this->assertArrayHasKey("self", $content["_links"]); $this->assertArrayHasKey("first", $content["_links"]); $this->assertArrayHasKey("last", $content["_links"]); foreach (array("self", "first", "last") as $link) { $this->assertArrayHasKey("href", $content["_links"][$link]); $this->assertStringContainsString("starred=1", $content["_links"][$link]["href"]); $this->assertStringContainsString("sort=updated", $content["_links"][$link]["href"]); } $this->assertSame("application/json", $this->client->getResponse()->headers->get("Content-Type")); } public function testGetArchiveEntries() { $this->client->request("GET", "/api/entries", array("archive" => 1)); $this->assertSame(200, $this->client->getResponse()->getStatusCode()); $content = json_decode($this->client->getResponse()->getContent(), true); $this->assertGreaterThanOrEqual(1, \count($content)); $this->assertNotEmpty($content["_embedded"]["items"]); $this->assertGreaterThanOrEqual(1, $content["total"]); $this->assertSame(1, $content["page"]); $this->assertGreaterThanOrEqual(1, $content["pages"]); $this->assertArrayHasKey("_links", $content); $this->assertArrayHasKey("self", $content["_links"]); $this->assertArrayHasKey("first", $content["_links"]); $this->assertArrayHasKey("last", $content["_links"]); foreach (array("self", "first", "last") as $link) { $this->assertArrayHasKey("href", $content["_links"][$link]); $this->assertStringContainsString("archive=1", $content["_links"][$link]["href"]); } $this->assertSame("application/json", $this->client->getResponse()->headers->get("Content-Type")); } public function testGetNotParsedEntries() { $this->client->request("GET", "/api/entries", array("notParsed" => 1)); $this->assertSame(200, $this->client->getResponse()->getStatusCode()); $content = json_decode($this->client->getResponse()->getContent(), true); $this->assertGreaterThanOrEqual(1, \count($content)); $this->assertNotEmpty($content["_embedded"]["items"]); $this->assertGreaterThanOrEqual(1, $content["total"]); $this->assertSame(1, $content["page"]); $this->assertGreaterThanOrEqual(1, $content["pages"]); $this->assertArrayHasKey("_links", $content); $this->assertArrayHasKey("self", $content["_links"]); $this->assertArrayHasKey("first", $content["_links"]); $this->assertArrayHasKey("last", $content["_links"]); foreach (array("self", "first", "last") as $link) { $this->assertArrayHasKey("href", $content["_links"][$link]); $this->assertStringContainsString("notParsed=1", $content["_links"][$link]["href"]); } $this->assertSame("application/json", $this->client->getResponse()->headers->get("Content-Type")); } public function testGetParsedEntries() { $this->client->request("GET", "/api/entries", array("notParsed" => 0)); $this->assertSame(200, $this->client->getResponse()->getStatusCode()); $content = json_decode($this->client->getResponse()->getContent(), true); $this->assertGreaterThanOrEqual(1, \count($content)); $this->assertNotEmpty($content["_embedded"]["items"]); $this->assertGreaterThanOrEqual(1, $content["total"]); $this->assertSame(1, $content["page"]); $this->assertGreaterThanOrEqual(1, $content["pages"]); $this->assertArrayHasKey("_links", $content); $this->assertArrayHasKey("self", $content["_links"]); $this->assertArrayHasKey("first", $content["_links"]); $this->assertArrayHasKey("last", $content["_links"]); foreach (array("self", "first", "last") as $link) { $this->assertArrayHasKey("href", $content["_links"][$link]); $this->assertStringContainsString("notParsed=0", $content["_links"][$link]["href"]); } $this->assertSame("application/json", $this->client->getResponse()->headers->get("Content-Type")); } public function testGetTaggedEntries() { $this->client->request("GET", "/api/entries", array("tags" => "foo,bar")); $this->assertSame(200, $this->client->getResponse()->getStatusCode()); $content = json_decode($this->client->getResponse()->getContent(), true); $this->assertGreaterThanOrEqual(1, \count($content)); $this->assertNotEmpty($content["_embedded"]["items"]); $this->assertGreaterThanOrEqual(1, $content["total"]); $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->assertArrayHasKey("last", $content["_links"]); foreach (array("self", "first", "last") as $link) { $this->assertArrayHasKey("href", $content["_links"][$link]); $this->assertStringContainsString("tags=foo,bar", $content["_links"][$link]["href"]); } $this->assertSame("application/json", $this->client->getResponse()->headers->get("Content-Type")); } public function testGetTaggedEntriesWithBadParams() { $this->client->request("GET", "/api/entries", array("tags" => array("foo", "bar"))); $this->assertSame(200, $this->client->getResponse()->getStatusCode()); } public function testGetDatedEntries() { $this->client->request("GET", "/api/entries", array("since" => 1443274283)); $this->assertSame(200, $this->client->getResponse()->getStatusCode()); $content = json_decode($this->client->getResponse()->getContent(), true); $this->assertGreaterThanOrEqual(1, \count($content)); $this->assertNotEmpty($content["_embedded"]["items"]); $this->assertGreaterThanOrEqual(1, $content["total"]); $this->assertSame(1, $content["page"]); $this->assertGreaterThanOrEqual(1, $content["pages"]); $this->assertArrayHasKey("_links", $content); $this->assertArrayHasKey("self", $content["_links"]); $this->assertArrayHasKey("first", $content["_links"]); $this->assertArrayHasKey("last", $content["_links"]); foreach (array("self", "first", "last") as $link) { $this->assertArrayHasKey("href", $content["_links"][$link]); $this->assertStringContainsString("since=1443274283", $content["_links"][$link]["href"]); } $this->assertSame("application/json", $this->client->getResponse()->headers->get("Content-Type")); } public function testGetDatedSupEntries() { $future = new \DateTime(date("Y-m-d H:i:s")); $this->client->request("GET", "/api/entries", array("since" => $future->getTimestamp() + 1000)); $this->assertSame(200, $this->client->getResponse()->getStatusCode()); $content = json_decode($this->client->getResponse()->getContent(), true); $this->assertGreaterThanOrEqual(1, \count($content)); $this->assertEmpty($content["_embedded"]["items"]); $this->assertSame(0, $content["total"]); $this->assertSame(1, $content["page"]); $this->assertSame(1, $content["pages"]); $this->assertArrayHasKey("_links", $content); $this->assertArrayHasKey("self", $content["_links"]); $this->assertArrayHasKey("first", $content["_links"]); $this->assertArrayHasKey("last", $content["_links"]); foreach (array("self", "first", "last") as $link) { $this->assertArrayHasKey("href", $content["_links"][$link]); $this->assertStringContainsString("since=" . ($future->getTimestamp() + 1000), $content["_links"][$link]["href"]); } $this->assertSame("application/json", $this->client->getResponse()->headers->get("Content-Type")); } public function testDeleteEntry() { $em = $this->client->getContainer()->get(EntityManagerInterface::class); $entry = new Entry($em->getReference(User::class, 1)); $entry->setUrl("http://0.0.0.0/test-delete-entry"); $entry->setTitle("Test delete entry"); $em->persist($entry); $em->flush(); $em->clear(); $e = array("title" => $entry->getTitle(), "url" => $entry->getUrl(), "id" => $entry->getId()); $this->client->request("DELETE", "/api/entries/" . $e["id"] . ".json"); $this->assertSame(200, $this->client->getResponse()->getStatusCode()); $content = json_decode($this->client->getResponse()->getContent(), true); $this->assertSame($e["title"], $content["title"]); $this->assertSame($e["url"], $content["url"]); $this->assertSame($e["id"], $content["id"]); $client = $this->createAuthorizedClient(); $client->request("DELETE", "/api/entries/" . $e["id"] . ".json"); $this->assertSame(404, $client->getResponse()->getStatusCode()); } public function testDeleteEntryExpectId() { $em = $this->client->getContainer()->get(EntityManagerInterface::class); $entry = new Entry($em->getReference(User::class, 1)); $entry->setUrl("http://0.0.0.0/test-delete-entry-id"); $em->persist($entry); $em->flush(); $em->clear(); $id = $entry->getId(); $this->client->request("DELETE", "/api/entries/" . $id . ".json?expect=id"); $this->assertSame(200, $this->client->getResponse()->getStatusCode()); $content = json_decode($this->client->getResponse()->getContent(), true); $this->assertSame($id, $content["id"]); $this->assertArrayNotHasKey("url", $content); $client = $this->createAuthorizedClient(); $client->request("DELETE", "/api/entries/" . $id . ".json"); $this->assertSame(404, $client->getResponse()->getStatusCode()); } public function testDeleteEntryExpectBadRequest() { $this->client->request("DELETE", "/api/entries/1.json?expect=badrequest"); $this->assertSame(400, $this->client->getResponse()->getStatusCode()); } public function testPostEntry() { $this->client->request("POST", "/api/entries.json", array("url" => "https://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", "tags" => "google", "title" => "New title for my article", "content" => "my content", "language" => "de", "published_at" => "2016-09-08T11:55:58+0200", "authors" => "bob,helen", "public" => 1)); $this->assertSame(200, $this->client->getResponse()->getStatusCode()); $content = json_decode($this->client->getResponse()->getContent(), true); $this->assertGreaterThan(0, $content["id"]); $this->assertSame("https://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->assertNull($content["archived_at"]); $this->assertSame("New title for my article", $content["title"]); $this->assertSame($this->getUserId(), $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"]); $this->assertCount(2, $content["published_by"]); $this->assertContains("bob", $content["published_by"]); $this->assertContains("helen", $content["published_by"]); $this->assertTrue($content["is_public"], "A public link has been generated for that entry"); } public function testPostSameEntry() { $em = $this->client->getContainer()->get(EntityManagerInterface::class); $entry = new Entry($em->getReference(User::class, $this->getUserId())); $entry->setUrl("https://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", array("url" => "https://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", "tags" => "google, apple")); $this->assertSame(200, $this->client->getResponse()->getStatusCode()); $content = json_decode($this->client->getResponse()->getContent(), true); $this->assertGreaterThan(0, $content["id"]); $this->assertSame("https://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(1, $content["is_archived"]); $this->assertSame(0, $content["is_starred"]); $this->assertCount(3, $content["tags"]); } public function testPostEntryWhenFetchContentFails() { $container = $this->client->getContainer(); $contentProxy = $this->getMockBuilder(ContentProxy::class)->disableOriginalConstructor()->setMethods(array("updateEntry"))->getMock(); $contentProxy->expects($this->any())->method("updateEntry")->willThrowException(new \Exception("Test Fetch content fails")); $container->set(ContentProxy::class, $contentProxy); try { $this->client->request("POST", "/api/entries.json", array("url" => "http://www.example.com/")); $this->assertSame(200, $this->client->getResponse()->getStatusCode()); $content = json_decode($this->client->getResponse()->getContent(), true); $this->assertGreaterThan(0, $content["id"]); $this->assertSame("http://www.example.com/", $content["url"]); $this->assertSame("www.example.com", $content["domain_name"]); $this->assertSame("www.example.com", $content["title"]); } finally { if (isset($content["id"])) { $em = $this->client->getContainer()->get(EntityManagerInterface::class); $entry = $em->getReference(Entry::class, $content["id"]); $em->remove($entry); $em->flush(); } } } public function testPostArchivedAndStarredEntry() { $now = new \DateTime(); $this->client->request("POST", "/api/entries.json", array("url" => "https://www.lemonde.fr/idees/article/2016/02/08/preserver-la-liberte-d-expression-sur-les-reseaux-sociaux_4861503_3232.html", "archive" => "1", "starred" => "1")); $this->assertSame(200, $this->client->getResponse()->getStatusCode()); $content = json_decode($this->client->getResponse()->getContent(), true); $this->assertGreaterThan(0, $content["id"]); $this->assertSame("https://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->assertGreaterThanOrEqual($now->getTimestamp(), (new \DateTime($content["archived_at"]))->getTimestamp()); $this->assertSame($this->getUserId(), $content["user_id"]); } public function testPostArchivedAndStarredEntryWithoutQuotes() { $this->client->request("POST", "/api/entries.json", array("url" => "https://www.lemonde.fr/idees/article/2016/02/08/preserver-la-liberte-d-expression-sur-les-reseaux-sociaux_4861503_3232.html", "archive" => 0, "starred" => 1)); $this->assertSame(200, $this->client->getResponse()->getStatusCode()); $content = json_decode($this->client->getResponse()->getContent(), true); $this->assertGreaterThan(0, $content["id"]); $this->assertSame("https://www.lemonde.fr/idees/article/2016/02/08/preserver-la-liberte-d-expression-sur-les-reseaux-sociaux_4861503_3232.html", $content["url"]); $this->assertSame(0, $content["is_archived"]); $this->assertSame(1, $content["is_starred"]); } public function testPostEntryWithOriginUrl() { $this->client->request("POST", "/api/entries.json", array("url" => "https://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", "tags" => "google", "title" => "New title for my article", "content" => "my content", "language" => "de", "published_at" => "2016-09-08T11:55:58+0200", "authors" => "bob,helen", "public" => 1, "origin_url" => "http://mysource.tld")); $this->assertSame(200, $this->client->getResponse()->getStatusCode()); $content = json_decode($this->client->getResponse()->getContent(), true); $this->assertGreaterThan(0, $content["id"]); $this->assertSame("https://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("http://mysource.tld", $content["origin_url"]); } public function testPatchEntry() { $entry = $this->client->getContainer()->get(EntityManagerInterface::class)->getRepository(Entry::class)->findOneByUser($this->getUserId()); if (!$entry) { $this->markTestSkipped("No content found in db."); } $this->client->request("PATCH", "/api/entries/" . $entry->getId() . ".json", array("title" => "New awesome title", "tags" => "new tag " . uniqid(), "starred" => "1", "archive" => "0", "language" => "de_AT", "preview_picture" => "http://preview.io/picture.jpg", "authors" => "bob,sponge", "content" => "awesome", "public" => 0, "published_at" => 1488833381)); $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->assertSame("New awesome title", $content["title"]); $this->assertGreaterThanOrEqual(1, \count($content["tags"]), "We force only one tag"); $this->assertSame($this->getUserId(), $content["user_id"]); $this->assertSame("de_AT", $content["language"]); $this->assertSame("http://preview.io/picture.jpg", $content["preview_picture"]); $this->assertContains("sponge", $content["published_by"]); $this->assertContains("bob", $content["published_by"]); $this->assertSame("awesome", $content["content"]); $this->assertFalse($content["is_public"], "Entry is no more shared"); $this->assertStringContainsString("2017-03-06", $content["published_at"]); } public function testPatchEntryWithoutQuotes() { $entry = $this->client->getContainer()->get(EntityManagerInterface::class)->getRepository(Entry::class)->findOneByUser($this->getUserId()); if (!$entry) { $this->markTestSkipped("No content found in db."); } $previousContent = $entry->getContent(); $previousLanguage = $entry->getLanguage(); $this->client->request("PATCH", "/api/entries/" . $entry->getId() . ".json", array("title" => "New awesome title", "tags" => "new tag " . uniqid(), "starred" => 1, "archive" => 0, "authors" => array("bob", "sponge"))); $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->assertGreaterThanOrEqual(1, \count($content["tags"]), "We force only one tag"); $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"); } public function testPatchEntryWithOriginUrl() { $entry = $this->client->getContainer()->get(EntityManagerInterface::class)->getRepository(Entry::class)->findOneByUser($this->getUserId()); if (!$entry) { $this->markTestSkipped("No content found in db."); } $previousContent = $entry->getContent(); $previousLanguage = $entry->getLanguage(); $this->client->request("PATCH", "/api/entries/" . $entry->getId() . ".json", array("title" => "Another awesome title just for profit", "origin_url" => "https://myawesomesource.example.com")); $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->assertSame("https://myawesomesource.example.com", $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"); } public function testPatchEntryRemoveOriginUrl() { $entry = $this->client->getContainer()->get(EntityManagerInterface::class)->getRepository(Entry::class)->findOneByUser($this->getUserId()); 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", array("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(EntityManagerInterface::class)->getRepository(Entry::class)->findOneByUser($this->getUserId()); if (!$entry) { $this->markTestSkipped("No content found in db."); } $this->client->request("PATCH", "/api/entries/" . $entry->getId() . ".json", array("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()->get(EntityManagerInterface::class)->getRepository(Entry::class)->findOneWithTags($this->user->getId()); $entry = $entry[0]; if (!$entry) { $this->markTestSkipped("No content found in db."); } $tags = array(); foreach ($entry->getTags() as $tag) { $tags[] = array("id" => $tag->getId(), "label" => $tag->getLabel(), "slug" => $tag->getSlug()); } $this->client->request("GET", "/api/entries/" . $entry->getId() . "/tags"); $this->assertSame(json_encode($tags, \JSON_HEX_QUOT), $this->client->getResponse()->getContent()); } public function testPostTagsOnEntry() { $entry = $this->client->getContainer()->get(EntityManagerInterface::class)->getRepository(Entry::class)->findOneByUser($this->getUserId()); if (!$entry) { $this->markTestSkipped("No content found in db."); } $nbTags = \count($entry->getTags()); $newTags = "tag1,tag2,tag3"; $this->client->request("POST", "/api/entries/" . $entry->getId() . "/tags", array("tags" => $newTags)); $this->assertSame(200, $this->client->getResponse()->getStatusCode()); $content = json_decode($this->client->getResponse()->getContent(), true); $this->assertArrayHasKey("tags", $content); $this->assertCount($nbTags + 3, $content["tags"]); $entryDB = $this->client->getContainer()->get(EntityManagerInterface::class)->getRepository(Entry::class)->find($entry->getId()); $tagsInDB = array(); foreach ($entryDB->getTags()->toArray() as $tag) { $tagsInDB[$tag->getId()] = $tag->getLabel(); } foreach (explode(",", $newTags) as $tag) { $this->assertContains($tag, $tagsInDB); } } public function testDeleteOneTagEntry() { $entry = $this->client->getContainer()->get(EntityManagerInterface::class)->getRepository(Entry::class)->findOneWithTags($this->user->getId()); $entry = $entry[0]; if (!$entry) { $this->markTestSkipped("No content found in db."); } $nbTags = \count($entry->getTags()); $tag = $entry->getTags()[0]; $this->client->request("DELETE", "/api/entries/" . $entry->getId() . "/tags/" . $tag->getId() . ".json"); $this->assertSame(200, $this->client->getResponse()->getStatusCode()); $content = json_decode($this->client->getResponse()->getContent(), true); $this->assertArrayHasKey("tags", $content); $this->assertCount($nbTags - 1, $content["tags"]); } public function testSaveIsArchivedAfterPost() { $entry = $this->client->getContainer()->get(EntityManagerInterface::class)->getRepository(Entry::class)->findOneBy(array("user" => $this->getUserId(), "isArchived" => true)); if (!$entry) { $this->markTestSkipped("No content found in db."); } $this->client->request("POST", "/api/entries.json", array("url" => $entry->getUrl())); $this->assertSame(200, $this->client->getResponse()->getStatusCode()); $content = json_decode($this->client->getResponse()->getContent(), true); $this->assertSame(1, $content["is_archived"]); } public function testSaveIsStarredAfterPost() { $entry = $this->client->getContainer()->get(EntityManagerInterface::class)->getRepository(Entry::class)->findOneBy(array("user" => $this->getUserId(), "isStarred" => true)); if (!$entry) { $this->markTestSkipped("No content found in db."); } $this->client->request("POST", "/api/entries.json", array("url" => $entry->getUrl())); $this->assertSame(200, $this->client->getResponse()->getStatusCode()); $content = json_decode($this->client->getResponse()->getContent(), true); $this->assertSame(1, $content["is_starred"]); } public function testSaveIsArchivedAfterPatch() { $now = new \DateTime(); $entry = $this->client->getContainer()->get(EntityManagerInterface::class)->getRepository(Entry::class)->findOneBy(array("user" => $this->getUserId(), "isArchived" => true)); if (!$entry) { $this->markTestSkipped("No content found in db."); } $previousTitle = $entry->getTitle(); $this->client->request("PATCH", "/api/entries/" . $entry->getId() . ".json", array("title" => $entry->getTitle() . "++")); $this->assertSame(200, $this->client->getResponse()->getStatusCode()); $content = json_decode($this->client->getResponse()->getContent(), true); $this->assertSame(1, $content["is_archived"]); $this->assertSame($previousTitle . "++", $content["title"]); $this->assertGreaterThanOrEqual((new \DateTime($content["archived_at"]))->getTimestamp(), $now->getTimestamp()); } public function testSaveIsStarredAfterPatch() { $now = new \DateTime(); $entry = $this->client->getContainer()->get(EntityManagerInterface::class)->getRepository(Entry::class)->findOneBy(array("user" => $this->getUserId(), "isStarred" => true)); if (!$entry) { $this->markTestSkipped("No content found in db."); } $previousTitle = $entry->getTitle(); $this->client->request("PATCH", "/api/entries/" . $entry->getId() . ".json", array("title" => $entry->getTitle() . "++")); $this->assertSame(200, $this->client->getResponse()->getStatusCode()); $content = json_decode($this->client->getResponse()->getContent(), true); $this->assertSame(1, $content["is_starred"]); $this->assertSame($previousTitle . "++", $content["title"]); $this->assertGreaterThanOrEqual((new \DateTime($content["starred_at"]))->getTimestamp(), $now->getTimestamp()); } public function dataForEntriesExistWithUrl() { $url = hash("sha1", "http://0.0.0.0/entry2"); return array("with_id" => array("url" => "/api/entries/exists?url=http://0.0.0.0/entry2&return_id=1", "expectedValue" => 2), "without_id" => array("url" => "/api/entries/exists?url=http://0.0.0.0/entry2", "expectedValue" => true), "hashed_url_with_id" => array("url" => "/api/entries/exists?hashed_url=" . $url . "&return_id=1", "expectedValue" => 2), "hashed_url_without_id" => array("url" => "/api/entries/exists?hashed_url=" . $url . '', "expectedValue" => true)); } public function testGetEntriesExists($url, $expectedValue) { $this->client->request("GET", $url); $this->assertSame(200, $this->client->getResponse()->getStatusCode()); $content = json_decode($this->client->getResponse()->getContent(), true); $this->assertSame($expectedValue, $content["exists"]); } public function testGetEntriesExistsWithManyUrls() { $url1 = "http://0.0.0.0/entry2"; $url2 = "http://0.0.0.0/entry10"; $this->client->request("GET", "/api/entries/exists?urls[]=" . $url1 . "&urls[]=" . $url2 . "&return_id=1"); $this->assertSame(200, $this->client->getResponse()->getStatusCode()); $content = json_decode($this->client->getResponse()->getContent(), true); $this->assertArrayHasKey($url1, $content); $this->assertArrayHasKey($url2, $content); $this->assertGreaterThan(1, $content[$url1]); $this->assertNull($content[$url2]); } public function testGetEntriesExistsWithManyUrlsReturnBool() { $url1 = "http://0.0.0.0/entry2"; $url2 = "http://0.0.0.0/entry10"; $this->client->request("GET", "/api/entries/exists?urls[]=" . $url1 . "&urls[]=" . $url2); $this->assertSame(200, $this->client->getResponse()->getStatusCode()); $content = json_decode($this->client->getResponse()->getContent(), true); $this->assertArrayHasKey($url1, $content); $this->assertArrayHasKey($url2, $content); $this->assertTrue($content[$url1]); $this->assertFalse($content[$url2]); } public function testGetEntriesExistsWithManyUrlsHashed() { $url1 = "http://0.0.0.0/entry2"; $url2 = "http://0.0.0.0/entry10"; $this->client->request("GET", "/api/entries/exists?hashed_urls[]=" . hash("sha1", $url1) . "&hashed_urls[]=" . hash("sha1", $url2) . "&return_id=1"); $this->assertSame(200, $this->client->getResponse()->getStatusCode()); $content = json_decode($this->client->getResponse()->getContent(), true); $this->assertArrayHasKey(hash("sha1", $url1), $content); $this->assertArrayHasKey(hash("sha1", $url2), $content); $this->assertSame(2, $content[hash("sha1", $url1)]); $this->assertNull($content[hash("sha1", $url2)]); } public function testGetEntriesExistsWithManyUrlsHashedReturnBool() { $url1 = "http://0.0.0.0/entry2"; $url2 = "http://0.0.0.0/entry10"; $this->client->request("GET", "/api/entries/exists?hashed_urls[]=" . hash("sha1", $url1) . "&hashed_urls[]=" . hash("sha1", $url2)); $this->assertSame(200, $this->client->getResponse()->getStatusCode()); $content = json_decode($this->client->getResponse()->getContent(), true); $this->assertArrayHasKey(hash("sha1", $url1), $content); $this->assertArrayHasKey(hash("sha1", $url2), $content); $this->assertTrue($content[hash("sha1", $url1)]); $this->assertFalse($content[hash("sha1", $url2)]); } public function testGetEntriesExistsWhichDoesNotExists() { $this->client->request("GET", "/api/entries/exists?url=http://google.com/entry2"); $this->assertSame(200, $this->client->getResponse()->getStatusCode()); $content = json_decode($this->client->getResponse()->getContent(), true); $this->assertFalse($content["exists"]); } public function testGetEntriesExistsWhichDoesNotExistsWithHashedUrl() { $this->client->request("GET", "/api/entries/exists?hashed_url=" . hash("sha1", "http://google.com/entry2")); $this->assertSame(200, $this->client->getResponse()->getStatusCode()); $content = json_decode($this->client->getResponse()->getContent(), true); $this->assertFalse($content["exists"]); } public function testGetEntriesExistsWithNoUrl() { $this->client->request("GET", "/api/entries/exists?url="); $this->assertSame(403, $this->client->getResponse()->getStatusCode()); } public function testGetEntriesExistsWithNoHashedUrl() { $this->client->request("GET", "/api/entries/exists?hashed_url="); $this->assertSame(403, $this->client->getResponse()->getStatusCode()); } public function testReloadEntryErrorWhileFetching() { $entry = $this->client->getContainer()->get(EntityManagerInterface::class)->getRepository(Entry::class)->findByUrlAndUserId("http://0.0.0.0/entry4", $this->getUserId()); if (!$entry) { $this->markTestSkipped("No content found in db."); } $this->client->request("PATCH", "/api/entries/" . $entry->getId() . "/reload.json"); $this->assertSame(304, $this->client->getResponse()->getStatusCode()); } public function testReloadEntry() { $this->client->request("POST", "/api/entries.json", array("url" => "https://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", "tags" => "google, apple")); $json = json_decode($this->client->getResponse()->getContent(), true); $this->setUp(); $this->client->request("PATCH", "/api/entries/" . $json["id"] . "/reload.json"); $this->assertSame(200, $this->client->getResponse()->getStatusCode()); $content = json_decode($this->client->getResponse()->getContent(), true); $this->assertNotEmpty($content["title"]); $this->assertSame("application/json", $this->client->getResponse()->headers->get("Content-Type")); } public function testPostEntriesTagsListAction() { $entry = $this->client->getContainer()->get(EntityManagerInterface::class)->getRepository(Entry::class)->findByUrlAndUserId("http://0.0.0.0/entry4", $this->getUserId()); $tags = $entry->getTags(); $this->assertCount(2, $tags); $list = array(array("url" => "http://0.0.0.0/entry4", "tags" => "new tag 1, new tag 2")); $this->client->request("POST", "/api/entries/tags/lists?list=" . json_encode($list)); $this->assertSame(200, $this->client->getResponse()->getStatusCode()); $content = json_decode($this->client->getResponse()->getContent(), true); $this->assertIsInt($content[0]["entry"]); $this->assertSame("http://0.0.0.0/entry4", $content[0]["url"]); $entry = $this->client->getContainer()->get(EntityManagerInterface::class)->getRepository(Entry::class)->findByUrlAndUserId("http://0.0.0.0/entry4", $this->getUserId()); $tags = $entry->getTags(); $this->assertCount(4, $tags); } public function testPostEntriesTagsListActionNoList() { $this->client->request("POST", "/api/entries/tags/lists?list=" . json_encode(array())); $this->assertSame(200, $this->client->getResponse()->getStatusCode()); $content = json_decode($this->client->getResponse()->getContent(), true); $this->assertEmpty($content); } public function testDeleteEntriesTagsListAction() { $em = $this->client->getContainer()->get(EntityManagerInterface::class); $entry = new Entry($em->getReference(User::class, $this->getUserId())); $entry->setUrl("http://0.0.0.0/test-entry"); $entry->addTag((new Tag())->setLabel("foo-tag")); $entry->addTag((new Tag())->setLabel("bar-tag")); $em->persist($entry); $em->flush(); $em->clear(); $list = array(array("url" => "http://0.0.0.0/test-entry", "tags" => "foo-tag, bar-tag")); $this->client->request("DELETE", "/api/entries/tags/list?list=" . json_encode($list)); $this->assertSame(200, $this->client->getResponse()->getStatusCode()); $entry = $em->getRepository(Entry::class)->find($entry->getId()); $this->assertCount(0, $entry->getTags()); } public function testDeleteEntriesTagsListActionNoList() { $this->client->request("DELETE", "/api/entries/tags/list?list=" . json_encode(array())); $this->assertSame(200, $this->client->getResponse()->getStatusCode()); $content = json_decode($this->client->getResponse()->getContent(), true); $this->assertEmpty($content); } public function testPostEntriesListAction() { $list = array("https://www.lemonde.fr/musiques/article/2017/04/23/loin-de-la-politique-le-printemps-de-bourges-retombe-en-enfance_5115862_1654986.html", "http://0.0.0.0/entry2"); $this->client->request("POST", "/api/entries/lists?urls=" . json_encode($list)); $this->assertSame(200, $this->client->getResponse()->getStatusCode()); $content = json_decode($this->client->getResponse()->getContent(), true); $this->assertIsInt($content[0]["entry"]); $this->assertSame("https://www.lemonde.fr/musiques/article/2017/04/23/loin-de-la-politique-le-printemps-de-bourges-retombe-en-enfance_5115862_1654986.html", $content[0]["url"]); $this->assertIsInt($content[1]["entry"]); $this->assertSame("http://0.0.0.0/entry2", $content[1]["url"]); } public function testPostEntriesListActionWithNoUrls() { $this->client->request("POST", "/api/entries/lists?urls=" . json_encode(array())); $this->assertSame(200, $this->client->getResponse()->getStatusCode()); $content = json_decode($this->client->getResponse()->getContent(), true); $this->assertEmpty($content); } public function testDeleteEntriesListAction() { $em = $this->client->getContainer()->get(EntityManagerInterface::class); $em->persist((new Entry($em->getReference(User::class, $this->getUserId())))->setUrl("http://0.0.0.0/test-entry1")); $em->flush(); $em->clear(); $list = array("http://0.0.0.0/test-entry1", "http://0.0.0.0/test-entry-not-exist"); $this->client->request("DELETE", "/api/entries/list?urls=" . json_encode($list)); $this->assertSame(200, $this->client->getResponse()->getStatusCode()); $content = json_decode($this->client->getResponse()->getContent(), true); $this->assertTrue($content[0]["entry"]); $this->assertSame("http://0.0.0.0/test-entry1", $content[0]["url"]); $this->assertFalse($content[1]["entry"]); $this->assertSame("http://0.0.0.0/test-entry-not-exist", $content[1]["url"]); } public function testDeleteEntriesListActionWithNoUrls() { $this->client->request("DELETE", "/api/entries/list?urls=" . json_encode(array())); $this->assertSame(200, $this->client->getResponse()->getStatusCode()); $content = json_decode($this->client->getResponse()->getContent(), true); $this->assertEmpty($content); } public function testLimitBulkAction() { $list = array("http://0.0.0.0/entry1", "http://0.0.0.0/entry1", "http://0.0.0.0/entry1", "http://0.0.0.0/entry1", "http://0.0.0.0/entry1", "http://0.0.0.0/entry1", "http://0.0.0.0/entry1", "http://0.0.0.0/entry1", "http://0.0.0.0/entry1", "http://0.0.0.0/entry1", "http://0.0.0.0/entry1"); $this->client->request("POST", "/api/entries/lists?urls=" . json_encode($list)); $this->assertSame(400, $this->client->getResponse()->getStatusCode()); $this->assertStringContainsString("API limit reached", $this->client->getResponse()->getContent()); } public function testRePostEntryAndReUsePublishedAt() { $em = $this->client->getContainer()->get(EntityManagerInterface::class); $entry = new Entry($em->getReference(User::class, $this->getUserId())); $entry->setTitle("Antoine de Caunes : \xc2\xab Je veux avoir le droit de t\xc3\242tonner \xc2\273"); $entry->setContent("hihi"); $entry->setUrl("https://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", array("url" => "https://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("https://www.lemonde.fr/m-perso/article/2017/06/25/antoine-de-caunes-je-veux-avoir-le-droit-de-tatonner_5150728_4497916.html", $content["url"]); } } ?>
Did this file decode correctly?
Original Code
<?php
namespace Tests\Wallabag\Controller\Api; use Doctrine\ORM\EntityManagerInterface; use Symfony\Component\DependencyInjection\Container; use Wallabag\Entity\Entry; use Wallabag\Entity\Tag; use Wallabag\Entity\User; use Wallabag\Helper\ContentProxy; class EntryRestControllerTest extends WallabagApiTestCase { public function testGetOneEntry() { $entry = $this->client->getContainer()->get(EntityManagerInterface::class)->getRepository(Entry::class)->findOneBy(array("\165\x73\145\162" => $this->getUserId(), "\151\163\101\x72\x63\x68\151\x76\x65\144" => false)); if (!$entry) { $this->markTestSkipped("\116\157\40\143\x6f\x6e\x74\x65\156\164\x20\146\x6f\165\156\x64\40\151\x6e\40\144\142\56"); } $this->client->request("\x47\105\x54", "\x2f\141\160\151\x2f\x65\156\164\x72\151\x65\163\57" . $entry->getId() . "\x2e\152\163\x6f\156"); $this->assertSame(200, $this->client->getResponse()->getStatusCode()); $content = json_decode($this->client->getResponse()->getContent(), true); $this->assertSame($entry->getTitle(), $content["\x74\x69\164\154\x65"]); $this->assertSame($entry->getUrl(), $content["\x75\162\154"]); $this->assertCount(\count($entry->getTags()), $content["\164\141\147\163"]); $this->assertSame($entry->getUserName(), $content["\165\163\145\x72\x5f\x6e\x61\155\145"]); $this->assertSame($entry->getUserEmail(), $content["\165\163\x65\162\x5f\145\155\141\151\154"]); $this->assertSame($entry->getUserId(), $content["\165\x73\145\x72\x5f\151\x64"]); $this->assertSame("\x61\x70\x70\154\151\x63\x61\164\151\x6f\156\57\x6a\x73\157\156", $this->client->getResponse()->headers->get("\x43\157\156\164\x65\x6e\164\x2d\124\x79\x70\145")); } public function testGetOneEntryWithOriginUrl() { $entry = $this->client->getContainer()->get(EntityManagerInterface::class)->getRepository(Entry::class)->findOneBy(array("\x75\x73\145\162" => $this->getUserId(), "\165\x72\x6c" => "\150\164\x74\160\x3a\x2f\x2f\60\x2e\x30\56\60\x2e\x30\x2f\145\x6e\x74\162\171\x32")); if (!$entry) { $this->markTestSkipped("\116\157\x20\x63\x6f\156\164\x65\x6e\x74\x20\146\x6f\x75\x6e\144\40\151\156\40\x64\x62\56"); } $this->client->request("\107\x45\124", "\x2f\x61\x70\151\57\145\x6e\x74\x72\151\145\x73\57" . $entry->getId() . "\x2e\152\x73\157\156"); $this->assertSame(200, $this->client->getResponse()->getStatusCode()); $content = json_decode($this->client->getResponse()->getContent(), true); $this->assertSame($entry->getOriginUrl(), $content["\x6f\x72\151\147\x69\156\137\x75\x72\x6c"]); } public function testExportEntry() { $entry = $this->client->getContainer()->get(EntityManagerInterface::class)->getRepository(Entry::class)->findOneBy(array("\x75\x73\145\162" => $this->getUserId(), "\x69\163\x41\x72\143\x68\151\166\x65\144" => false)); if (!$entry) { $this->markTestSkipped("\116\157\x20\143\157\156\164\145\156\x74\x20\146\157\165\156\x64\40\151\156\x20\x64\142\x2e"); } $this->client->request("\107\105\x54", "\x2f\x61\160\x69\x2f\145\156\x74\162\151\145\x73\x2f" . $entry->getId() . "\57\x65\x78\160\157\162\x74\56\145\x70\x75\142"); $this->assertSame(200, $this->client->getResponse()->getStatusCode()); $this->assertStringContainsString("\141\160\160\154\x69\143\141\x74\x69\157\x6e\57\x65\160\165\x62", $this->client->getResponse()->getContent()); $this->assertSame("\x61\160\160\x6c\151\143\x61\164\x69\157\x6e\57\145\160\x75\x62\x2b\172\x69\x70", $this->client->getResponse()->headers->get("\103\157\x6e\164\145\156\x74\55\x54\171\x70\x65")); $client = $this->createAuthorizedClient(); $client->request("\x47\105\x54", "\57\141\x70\x69\57\145\156\164\x72\x69\x65\x73\57" . $entry->getId() . "\57\145\x78\160\157\x72\x74\56\160\x64\x66"); $this->assertSame(200, $client->getResponse()->getStatusCode()); $this->assertStringContainsString("\120\x44\106\x2d", $client->getResponse()->getContent()); $this->assertSame("\141\160\160\154\x69\x63\141\164\x69\x6f\156\x2f\x70\x64\146", $client->getResponse()->headers->get("\x43\157\156\x74\x65\156\x74\55\124\171\160\x65")); $client = $this->createAuthorizedClient(); $client->request("\107\105\124", "\x2f\141\160\151\x2f\x65\x6e\x74\x72\x69\145\x73\57" . $entry->getId() . "\x2f\145\x78\x70\157\162\164\56\164\170\x74"); $this->assertSame(200, $client->getResponse()->getStatusCode()); $this->assertStringContainsString("\x74\145\x78\164\x2f\160\x6c\x61\x69\156", $client->getResponse()->headers->get("\103\157\x6e\164\145\x6e\x74\x2d\124\171\x70\145")); $client = $this->createAuthorizedClient(); $client->request("\x47\105\124", "\x2f\141\160\x69\x2f\x65\x6e\x74\x72\x69\145\x73\x2f" . $entry->getId() . "\x2f\145\x78\160\x6f\162\164\56\x63\163\x76"); $this->assertSame(200, $client->getResponse()->getStatusCode()); $this->assertStringContainsString("\x61\160\160\x6c\x69\x63\x61\164\151\x6f\x6e\57\x63\x73\x76", $client->getResponse()->headers->get("\103\x6f\x6e\x74\145\156\x74\x2d\124\x79\160\145")); } public function testGetOneEntryWrongUser() { $entry = $this->client->getContainer()->get(EntityManagerInterface::class)->getRepository(Entry::class)->findOneBy(array("\165\163\145\162" => $this->getUserId("\142\x6f\142"), "\x69\163\x41\x72\143\x68\151\166\x65\x64" => false)); if (!$entry) { $this->markTestSkipped("\116\x6f\x20\143\x6f\156\164\x65\156\x74\40\146\157\165\x6e\x64\40\151\x6e\40\144\142\x2e"); } $this->client->request("\107\105\x54", "\57\141\160\x69\57\x65\156\164\x72\151\145\163\x2f" . $entry->getId() . "\56\152\x73\157\x6e"); $this->assertSame(403, $this->client->getResponse()->getStatusCode()); } public function testGetEntries() { $this->client->request("\107\105\124", "\57\x61\x70\x69\x2f\145\156\164\162\x69\145\x73"); $this->assertSame(200, $this->client->getResponse()->getStatusCode()); $content = json_decode($this->client->getResponse()->getContent(), true); $this->assertGreaterThanOrEqual(1, \count($content)); $this->assertNotEmpty($content["\137\x65\x6d\x62\x65\144\144\145\144"]["\x69\164\145\155\163"]); $this->assertGreaterThanOrEqual(1, $content["\164\x6f\164\x61\x6c"]); $this->assertSame(1, $content["\x70\x61\147\x65"]); $this->assertGreaterThanOrEqual(1, $content["\x70\x61\x67\145\163"]); $this->assertNotNull($content["\137\145\x6d\x62\x65\x64\144\x65\x64"]["\151\x74\145\x6d\x73"][0]["\143\x6f\156\x74\145\156\164"]); $this->assertSame("\x61\160\x70\x6c\x69\x63\x61\x74\151\157\156\57\152\x73\x6f\156", $this->client->getResponse()->headers->get("\x43\x6f\x6e\164\145\x6e\164\55\124\171\x70\x65")); } public function testGetEntriesDetailMetadata() { $this->client->request("\x47\x45\x54", "\x2f\x61\160\x69\x2f\145\x6e\164\x72\151\145\x73\x3f\144\x65\164\141\151\x6c\x3d\x6d\145\x74\x61\144\141\x74\141"); $this->assertSame(200, $this->client->getResponse()->getStatusCode()); $content = json_decode($this->client->getResponse()->getContent(), true); $this->assertGreaterThanOrEqual(1, \count($content)); $this->assertNotEmpty($content["\137\145\x6d\142\145\144\x64\x65\144"]["\151\x74\x65\x6d\163"]); $this->assertGreaterThanOrEqual(1, $content["\x74\x6f\164\141\x6c"]); $this->assertSame(1, $content["\x70\141\147\x65"]); $this->assertGreaterThanOrEqual(1, $content["\160\x61\x67\145\163"]); $this->assertNull($content["\x5f\x65\155\x62\145\144\144\145\x64"]["\151\x74\x65\155\163"][0]["\143\x6f\x6e\164\145\156\x74"]); $this->assertSame("\x61\160\160\x6c\151\143\141\x74\151\x6f\x6e\x2f\x6a\x73\157\x6e", $this->client->getResponse()->headers->get("\103\157\156\x74\x65\x6e\x74\55\x54\x79\x70\145")); } public function testGetEntriesByDomainName() { $this->client->request("\x47\105\124", "\57\x61\160\x69\57\145\156\x74\x72\x69\145\163\77\x64\157\x6d\x61\x69\156\137\x6e\x61\x6d\x65\x3d\144\x6f\155\141\151\x6e\56\x69\x6f"); $this->assertSame(200, $this->client->getResponse()->getStatusCode()); $content = json_decode($this->client->getResponse()->getContent(), true); $this->assertGreaterThanOrEqual(1, \count($content)); $this->assertNotEmpty($content["\137\x65\155\x62\145\144\x64\145\144"]["\x69\164\145\x6d\x73"]); $this->assertGreaterThanOrEqual(1, $content["\164\x6f\164\x61\x6c"]); $this->assertSame(1, $content["\160\141\x67\145"]); $this->assertGreaterThanOrEqual(1, $content["\x70\x61\x67\145\163"]); $this->assertSame("\164\145\x73\x74\40\x74\151\x74\x6c\x65\x20\145\156\164\x72\x79\x36", $content["\137\145\155\x62\145\144\x64\x65\x64"]["\151\164\x65\x6d\x73"][0]["\164\x69\164\x6c\145"]); $this->assertSame("\141\x70\160\154\151\x63\141\x74\x69\x6f\156\57\152\x73\157\x6e", $this->client->getResponse()->headers->get("\103\x6f\156\x74\x65\156\164\55\x54\171\160\x65")); } public function testGetEntriesWithFullOptions() { $this->client->request("\x47\x45\x54", "\x2f\x61\160\x69\x2f\x65\x6e\x74\162\x69\x65\x73", array("\141\162\143\150\151\166\145" => 1, "\163\x74\141\162\162\x65\144" => 1, "\163\157\x72\x74" => "\165\160\x64\141\164\145\144", "\157\x72\144\x65\162" => "\141\x73\x63", "\x70\x61\x67\145" => 1, "\160\x65\x72\120\x61\147\145" => 2, "\x74\141\147\x73" => "\146\x6f\157", "\163\x69\156\x63\145" => 1443274283, "\160\x75\x62\x6c\151\x63" => 0, "\x6e\x6f\164\x50\141\162\163\x65\x64" => 0)); $this->assertSame(200, $this->client->getResponse()->getStatusCode()); $content = json_decode($this->client->getResponse()->getContent(), true); $this->assertGreaterThanOrEqual(1, \count($content)); $this->assertArrayHasKey("\x69\164\x65\x6d\x73", $content["\137\145\x6d\142\145\144\x64\x65\x64"]); $this->assertGreaterThanOrEqual(0, $content["\x74\157\x74\141\154"]); $this->assertSame(1, $content["\x70\x61\147\145"]); $this->assertSame(2, $content["\x6c\x69\x6d\151\x74"]); $this->assertGreaterThanOrEqual(1, $content["\160\x61\x67\145\x73"]); $this->assertArrayHasKey("\x5f\x6c\151\156\153\x73", $content); $this->assertArrayHasKey("\x73\x65\x6c\x66", $content["\x5f\154\x69\156\x6b\x73"]); $this->assertArrayHasKey("\x66\x69\x72\x73\x74", $content["\x5f\154\151\x6e\153\163"]); $this->assertArrayHasKey("\154\141\163\164", $content["\137\154\151\156\x6b\163"]); foreach (array("\x73\145\154\146", "\146\151\162\x73\164", "\154\141\x73\x74") as $link) { $this->assertArrayHasKey("\150\x72\x65\x66", $content["\137\x6c\151\156\153\163"][$link]); $this->assertStringContainsString("\141\162\x63\150\151\x76\145\75\61", $content["\137\x6c\151\156\153\x73"][$link]["\150\x72\145\146"]); $this->assertStringContainsString("\163\x74\141\162\162\x65\x64\75\61", $content["\137\x6c\151\156\153\163"][$link]["\x68\x72\x65\146"]); $this->assertStringContainsString("\163\157\162\x74\75\x75\160\x64\x61\x74\145\144", $content["\x5f\154\x69\156\x6b\163"][$link]["\150\x72\145\x66"]); $this->assertStringContainsString("\157\162\144\145\162\x3d\x61\x73\143", $content["\x5f\x6c\151\x6e\153\163"][$link]["\x68\162\x65\x66"]); $this->assertStringContainsString("\164\141\x67\163\x3d\146\157\x6f", $content["\137\x6c\151\156\153\x73"][$link]["\x68\162\145\146"]); $this->assertStringContainsString("\163\151\156\143\145\75\x31\64\x34\63\62\67\x34\x32\x38\x33", $content["\137\x6c\x69\156\153\x73"][$link]["\x68\x72\x65\x66"]); $this->assertStringContainsString("\x70\165\142\x6c\151\x63\75\60", $content["\x5f\154\151\x6e\153\163"][$link]["\150\162\x65\x66"]); } $this->assertSame("\x61\160\160\154\x69\143\141\x74\x69\x6f\x6e\57\x6a\163\157\156", $this->client->getResponse()->headers->get("\x43\157\156\164\x65\x6e\x74\55\124\171\x70\145")); } public function testGetEntriesPublicOnly() { $entry = $this->client->getContainer()->get(EntityManagerInterface::class)->getRepository(Entry::class)->findOneByUser($this->getUserId()); if (!$entry) { $this->markTestSkipped("\116\x6f\x20\143\157\156\x74\x65\156\164\x20\x66\x6f\x75\156\144\40\x69\x6e\x20\x64\142\56"); } $entry->generateUid(); $em = $this->client->getContainer()->get(EntityManagerInterface::class); $em->persist($entry); $em->flush(); $this->client->request("\107\105\x54", "\x2f\141\x70\151\57\145\156\x74\x72\x69\x65\x73", array("\x70\x75\142\x6c\x69\143" => 1)); $this->assertSame(200, $this->client->getResponse()->getStatusCode()); $content = json_decode($this->client->getResponse()->getContent(), true); $this->assertGreaterThanOrEqual(1, \count($content)); $this->assertArrayHasKey("\151\164\x65\155\163", $content["\x5f\145\155\142\145\144\144\145\x64"]); $this->assertGreaterThanOrEqual(1, $content["\164\157\164\141\x6c"]); $this->assertSame(1, $content["\160\141\x67\x65"]); $this->assertSame(30, $content["\154\151\155\x69\164"]); $this->assertGreaterThanOrEqual(1, $content["\160\x61\147\145\x73"]); $this->assertArrayHasKey("\137\154\151\x6e\153\163", $content); $this->assertArrayHasKey("\x73\x65\x6c\146", $content["\137\x6c\151\156\153\x73"]); $this->assertArrayHasKey("\x66\151\x72\x73\164", $content["\x5f\x6c\151\x6e\x6b\163"]); $this->assertArrayHasKey("\x6c\141\x73\x74", $content["\137\154\151\156\x6b\x73"]); foreach (array("\163\145\154\x66", "\146\x69\162\163\164", "\154\141\x73\x74") as $link) { $this->assertArrayHasKey("\x68\162\x65\x66", $content["\137\x6c\151\x6e\x6b\x73"][$link]); $this->assertStringContainsString("\160\x75\142\154\151\x63\x3d\61", $content["\x5f\x6c\x69\x6e\x6b\x73"][$link]["\x68\x72\145\x66"]); } $this->assertSame("\141\x70\x70\154\151\143\141\x74\151\x6f\156\x2f\x6a\163\157\x6e", $this->client->getResponse()->headers->get("\x43\157\x6e\x74\145\156\x74\55\124\171\x70\x65")); } public function testGetEntriesOnPageTwo() { $this->client->request("\x47\105\x54", "\57\141\160\151\57\x65\x6e\x74\162\151\x65\x73", array("\160\x61\x67\x65" => 2, "\160\145\162\x50\141\147\145" => 2)); $this->assertSame(200, $this->client->getResponse()->getStatusCode()); $content = json_decode($this->client->getResponse()->getContent(), true); $this->assertGreaterThanOrEqual(0, $content["\164\x6f\x74\x61\154"]); $this->assertSame(2, $content["\x70\141\x67\x65"]); $this->assertSame(2, $content["\x6c\151\155\x69\x74"]); } public function testGetStarredEntriesWithBadSort() { $this->client->request("\x47\x45\x54", "\x2f\x61\160\151\57\145\156\x74\x72\151\x65\x73", array("\x73\164\141\162\162\145\x64" => 1, "\163\157\162\x74" => "\165\160\144\141\164\x65\x64", "\x6f\162\x64\145\162" => "\165\156\x6b\x6e\157\x77\x6e")); $this->assertSame(400, $this->client->getResponse()->getStatusCode()); $this->assertSame("\141\160\x70\154\x69\143\x61\x74\x69\x6f\156\57\x6a\163\157\156", $this->client->getResponse()->headers->get("\x43\x6f\x6e\x74\x65\x6e\164\x2d\x54\x79\x70\145")); } public function testGetStarredEntries() { $this->client->request("\x47\x45\124", "\57\x61\160\x69\57\145\156\x74\x72\x69\x65\x73", array("\x73\164\x61\162\162\x65\144" => 1, "\163\157\162\x74" => "\x75\x70\x64\141\x74\145\144")); $this->assertSame(200, $this->client->getResponse()->getStatusCode()); $content = json_decode($this->client->getResponse()->getContent(), true); $this->assertGreaterThanOrEqual(1, \count($content)); $this->assertNotEmpty($content["\137\x65\155\142\145\144\144\x65\144"]["\151\x74\145\x6d\x73"]); $this->assertGreaterThanOrEqual(1, $content["\x74\x6f\164\141\x6c"]); $this->assertSame(1, $content["\x70\141\147\x65"]); $this->assertGreaterThanOrEqual(1, $content["\160\141\x67\x65\163"]); $this->assertArrayHasKey("\x5f\x6c\x69\156\153\163", $content); $this->assertArrayHasKey("\x73\145\x6c\146", $content["\137\154\151\x6e\x6b\x73"]); $this->assertArrayHasKey("\146\151\x72\x73\164", $content["\x5f\154\x69\x6e\x6b\163"]); $this->assertArrayHasKey("\x6c\141\x73\164", $content["\137\x6c\151\156\x6b\x73"]); foreach (array("\x73\145\x6c\146", "\x66\151\x72\x73\164", "\154\141\163\164") as $link) { $this->assertArrayHasKey("\150\162\145\x66", $content["\x5f\x6c\151\156\153\163"][$link]); $this->assertStringContainsString("\x73\164\141\x72\162\x65\x64\75\x31", $content["\137\x6c\151\x6e\x6b\163"][$link]["\x68\x72\145\146"]); $this->assertStringContainsString("\x73\x6f\162\164\x3d\x75\160\x64\x61\164\x65\144", $content["\x5f\x6c\x69\x6e\153\163"][$link]["\x68\x72\145\146"]); } $this->assertSame("\141\x70\x70\x6c\x69\x63\141\x74\x69\157\x6e\x2f\x6a\163\157\156", $this->client->getResponse()->headers->get("\x43\x6f\156\x74\x65\x6e\164\x2d\124\x79\160\145")); } public function testGetArchiveEntries() { $this->client->request("\x47\105\124", "\x2f\141\160\x69\57\x65\x6e\x74\162\151\145\x73", array("\x61\x72\143\x68\151\x76\x65" => 1)); $this->assertSame(200, $this->client->getResponse()->getStatusCode()); $content = json_decode($this->client->getResponse()->getContent(), true); $this->assertGreaterThanOrEqual(1, \count($content)); $this->assertNotEmpty($content["\137\x65\x6d\x62\145\144\x64\x65\144"]["\x69\x74\145\155\x73"]); $this->assertGreaterThanOrEqual(1, $content["\x74\157\164\141\154"]); $this->assertSame(1, $content["\160\x61\x67\145"]); $this->assertGreaterThanOrEqual(1, $content["\160\x61\147\x65\x73"]); $this->assertArrayHasKey("\137\154\151\156\153\163", $content); $this->assertArrayHasKey("\x73\145\x6c\x66", $content["\x5f\154\151\156\x6b\163"]); $this->assertArrayHasKey("\146\x69\162\163\164", $content["\x5f\154\151\x6e\153\x73"]); $this->assertArrayHasKey("\x6c\x61\163\164", $content["\x5f\x6c\x69\x6e\x6b\x73"]); foreach (array("\x73\x65\154\146", "\146\151\162\x73\x74", "\154\141\163\164") as $link) { $this->assertArrayHasKey("\150\x72\145\146", $content["\x5f\x6c\x69\x6e\153\x73"][$link]); $this->assertStringContainsString("\x61\x72\x63\150\x69\x76\145\75\x31", $content["\137\x6c\151\x6e\x6b\x73"][$link]["\150\162\x65\146"]); } $this->assertSame("\x61\x70\160\x6c\x69\143\x61\x74\x69\157\x6e\x2f\152\x73\x6f\156", $this->client->getResponse()->headers->get("\103\x6f\156\164\x65\x6e\164\x2d\x54\x79\160\x65")); } public function testGetNotParsedEntries() { $this->client->request("\107\x45\124", "\x2f\x61\160\x69\57\x65\156\164\x72\151\x65\x73", array("\x6e\157\x74\120\x61\162\163\145\x64" => 1)); $this->assertSame(200, $this->client->getResponse()->getStatusCode()); $content = json_decode($this->client->getResponse()->getContent(), true); $this->assertGreaterThanOrEqual(1, \count($content)); $this->assertNotEmpty($content["\x5f\x65\155\142\145\144\144\x65\144"]["\151\x74\x65\x6d\163"]); $this->assertGreaterThanOrEqual(1, $content["\x74\x6f\164\141\x6c"]); $this->assertSame(1, $content["\x70\141\147\x65"]); $this->assertGreaterThanOrEqual(1, $content["\160\141\147\x65\x73"]); $this->assertArrayHasKey("\137\x6c\x69\x6e\153\163", $content); $this->assertArrayHasKey("\x73\x65\x6c\146", $content["\x5f\154\151\156\153\163"]); $this->assertArrayHasKey("\x66\x69\162\163\x74", $content["\x5f\154\151\x6e\153\x73"]); $this->assertArrayHasKey("\154\x61\x73\164", $content["\x5f\154\151\156\153\163"]); foreach (array("\x73\145\x6c\146", "\x66\x69\x72\x73\x74", "\x6c\x61\x73\x74") as $link) { $this->assertArrayHasKey("\150\x72\x65\x66", $content["\x5f\x6c\x69\x6e\x6b\x73"][$link]); $this->assertStringContainsString("\156\x6f\164\x50\x61\x72\x73\145\144\x3d\61", $content["\x5f\x6c\x69\156\x6b\163"][$link]["\150\x72\x65\x66"]); } $this->assertSame("\141\x70\160\154\x69\x63\141\x74\151\x6f\x6e\x2f\152\163\157\x6e", $this->client->getResponse()->headers->get("\103\x6f\x6e\164\x65\156\x74\x2d\x54\171\x70\145")); } public function testGetParsedEntries() { $this->client->request("\x47\105\x54", "\x2f\141\160\x69\57\x65\x6e\x74\162\151\145\163", array("\156\157\164\x50\x61\162\x73\x65\x64" => 0)); $this->assertSame(200, $this->client->getResponse()->getStatusCode()); $content = json_decode($this->client->getResponse()->getContent(), true); $this->assertGreaterThanOrEqual(1, \count($content)); $this->assertNotEmpty($content["\137\x65\x6d\142\145\x64\144\x65\144"]["\x69\x74\x65\x6d\163"]); $this->assertGreaterThanOrEqual(1, $content["\x74\157\164\141\x6c"]); $this->assertSame(1, $content["\160\141\147\x65"]); $this->assertGreaterThanOrEqual(1, $content["\160\x61\147\145\x73"]); $this->assertArrayHasKey("\137\x6c\x69\x6e\153\x73", $content); $this->assertArrayHasKey("\x73\x65\154\146", $content["\x5f\x6c\x69\x6e\153\x73"]); $this->assertArrayHasKey("\146\x69\x72\163\164", $content["\137\x6c\x69\156\153\x73"]); $this->assertArrayHasKey("\x6c\141\x73\x74", $content["\137\154\x69\x6e\153\163"]); foreach (array("\x73\x65\x6c\146", "\146\151\162\163\164", "\x6c\x61\x73\x74") as $link) { $this->assertArrayHasKey("\x68\162\x65\x66", $content["\x5f\x6c\151\156\x6b\x73"][$link]); $this->assertStringContainsString("\x6e\x6f\164\120\x61\x72\163\145\x64\x3d\60", $content["\x5f\x6c\151\156\153\163"][$link]["\x68\x72\x65\146"]); } $this->assertSame("\141\x70\x70\154\151\143\x61\164\x69\x6f\x6e\x2f\x6a\163\x6f\x6e", $this->client->getResponse()->headers->get("\x43\157\x6e\x74\x65\156\164\55\124\x79\160\x65")); } public function testGetTaggedEntries() { $this->client->request("\x47\x45\124", "\x2f\x61\x70\151\57\145\x6e\164\x72\x69\145\163", array("\x74\141\x67\x73" => "\146\157\157\54\142\x61\162")); $this->assertSame(200, $this->client->getResponse()->getStatusCode()); $content = json_decode($this->client->getResponse()->getContent(), true); $this->assertGreaterThanOrEqual(1, \count($content)); $this->assertNotEmpty($content["\x5f\145\155\142\x65\144\144\145\144"]["\x69\164\145\155\163"]); $this->assertGreaterThanOrEqual(1, $content["\x74\x6f\x74\141\154"]); $this->assertSame(1, $content["\x70\x61\x67\x65"]); $this->assertGreaterThanOrEqual(1, $content["\x70\141\x67\145\x73"]); $this->assertContains("\146\x6f\157", array_column($content["\x5f\145\x6d\x62\x65\x64\x64\145\x64"]["\151\164\x65\155\x73"][0]["\x74\x61\x67\x73"], "\154\x61\142\145\154"), "\105\x6e\164\x72\x69\x65\163\40\164\141\147\163\40\163\150\x6f\x75\154\x64\40\x68\x61\x76\x65\x20\42\x66\157\x6f\x22\x20\x74\141\147"); $this->assertContains("\142\141\x72", array_column($content["\137\x65\x6d\x62\x65\x64\x64\x65\x64"]["\151\164\x65\x6d\x73"][0]["\x74\141\147\x73"], "\x6c\141\142\x65\154"), "\105\x6e\164\162\151\x65\x73\40\x74\x61\x67\x73\40\163\x68\157\165\154\x64\x20\150\x61\166\145\x20\x22\x62\141\162\x22\40\164\x61\x67"); $this->assertArrayHasKey("\137\x6c\x69\156\153\x73", $content); $this->assertArrayHasKey("\163\145\x6c\x66", $content["\x5f\154\x69\x6e\x6b\x73"]); $this->assertArrayHasKey("\x66\151\162\x73\164", $content["\137\x6c\151\x6e\153\x73"]); $this->assertArrayHasKey("\x6c\141\163\x74", $content["\x5f\154\x69\156\153\x73"]); foreach (array("\163\145\154\x66", "\146\x69\162\x73\x74", "\x6c\141\163\x74") as $link) { $this->assertArrayHasKey("\150\162\145\x66", $content["\x5f\154\x69\156\153\163"][$link]); $this->assertStringContainsString("\164\141\147\163\75\x66\x6f\x6f\54\142\141\162", $content["\x5f\154\x69\156\153\x73"][$link]["\150\x72\x65\146"]); } $this->assertSame("\x61\x70\x70\x6c\151\x63\x61\164\151\157\x6e\57\152\x73\x6f\156", $this->client->getResponse()->headers->get("\103\x6f\156\x74\x65\x6e\x74\55\x54\171\x70\x65")); } public function testGetTaggedEntriesWithBadParams() { $this->client->request("\x47\105\x54", "\57\x61\x70\151\x2f\145\x6e\x74\162\x69\x65\163", array("\x74\141\x67\163" => array("\146\x6f\157", "\142\141\x72"))); $this->assertSame(200, $this->client->getResponse()->getStatusCode()); } public function testGetDatedEntries() { $this->client->request("\107\105\x54", "\57\141\x70\x69\57\x65\156\x74\x72\x69\x65\x73", array("\x73\x69\156\x63\x65" => 1443274283)); $this->assertSame(200, $this->client->getResponse()->getStatusCode()); $content = json_decode($this->client->getResponse()->getContent(), true); $this->assertGreaterThanOrEqual(1, \count($content)); $this->assertNotEmpty($content["\x5f\x65\155\142\145\x64\144\145\x64"]["\x69\164\x65\155\163"]); $this->assertGreaterThanOrEqual(1, $content["\x74\157\x74\141\154"]); $this->assertSame(1, $content["\x70\x61\x67\145"]); $this->assertGreaterThanOrEqual(1, $content["\160\141\x67\145\163"]); $this->assertArrayHasKey("\137\154\151\156\153\163", $content); $this->assertArrayHasKey("\x73\x65\154\146", $content["\137\x6c\x69\x6e\153\x73"]); $this->assertArrayHasKey("\x66\151\x72\x73\x74", $content["\137\154\151\x6e\x6b\x73"]); $this->assertArrayHasKey("\154\x61\x73\x74", $content["\x5f\x6c\x69\156\153\163"]); foreach (array("\163\145\154\146", "\x66\151\162\163\x74", "\154\141\x73\164") as $link) { $this->assertArrayHasKey("\x68\162\145\146", $content["\x5f\154\x69\x6e\153\163"][$link]); $this->assertStringContainsString("\163\x69\x6e\143\x65\x3d\x31\64\64\x33\62\67\64\x32\x38\x33", $content["\x5f\154\x69\x6e\x6b\163"][$link]["\x68\x72\145\x66"]); } $this->assertSame("\x61\160\x70\x6c\x69\143\141\164\151\157\156\57\x6a\x73\157\x6e", $this->client->getResponse()->headers->get("\103\157\x6e\x74\145\156\164\55\x54\x79\x70\145")); } public function testGetDatedSupEntries() { $future = new \DateTime(date("\x59\55\155\55\144\40\x48\x3a\151\72\163")); $this->client->request("\107\105\124", "\x2f\x61\160\151\x2f\x65\156\164\x72\151\145\163", array("\163\x69\x6e\x63\145" => $future->getTimestamp() + 1000)); $this->assertSame(200, $this->client->getResponse()->getStatusCode()); $content = json_decode($this->client->getResponse()->getContent(), true); $this->assertGreaterThanOrEqual(1, \count($content)); $this->assertEmpty($content["\137\x65\155\142\x65\x64\144\x65\144"]["\151\x74\x65\155\163"]); $this->assertSame(0, $content["\x74\157\x74\x61\x6c"]); $this->assertSame(1, $content["\x70\141\x67\x65"]); $this->assertSame(1, $content["\x70\141\x67\x65\x73"]); $this->assertArrayHasKey("\137\x6c\x69\156\x6b\163", $content); $this->assertArrayHasKey("\163\x65\x6c\146", $content["\137\154\x69\x6e\x6b\x73"]); $this->assertArrayHasKey("\146\x69\x72\x73\164", $content["\137\154\x69\156\x6b\x73"]); $this->assertArrayHasKey("\x6c\x61\x73\164", $content["\137\x6c\x69\156\153\163"]); foreach (array("\163\145\154\146", "\146\x69\162\163\x74", "\154\141\163\x74") as $link) { $this->assertArrayHasKey("\150\162\x65\x66", $content["\137\154\x69\x6e\x6b\x73"][$link]); $this->assertStringContainsString("\x73\151\x6e\143\145\75" . ($future->getTimestamp() + 1000), $content["\x5f\154\x69\x6e\x6b\163"][$link]["\150\x72\145\x66"]); } $this->assertSame("\141\x70\160\154\x69\x63\x61\164\x69\157\x6e\x2f\x6a\163\157\156", $this->client->getResponse()->headers->get("\103\157\156\x74\x65\156\164\x2d\124\x79\x70\145")); } public function testDeleteEntry() { $em = $this->client->getContainer()->get(EntityManagerInterface::class); $entry = new Entry($em->getReference(User::class, 1)); $entry->setUrl("\x68\164\164\160\x3a\57\x2f\x30\x2e\60\x2e\x30\56\x30\x2f\x74\x65\163\x74\x2d\x64\145\154\x65\x74\145\x2d\145\x6e\164\162\x79"); $entry->setTitle("\x54\x65\163\x74\40\144\x65\x6c\145\164\x65\40\x65\x6e\164\x72\171"); $em->persist($entry); $em->flush(); $em->clear(); $e = array("\x74\x69\164\154\x65" => $entry->getTitle(), "\165\x72\x6c" => $entry->getUrl(), "\151\x64" => $entry->getId()); $this->client->request("\104\x45\x4c\105\x54\105", "\57\x61\160\x69\x2f\x65\156\x74\x72\151\x65\x73\x2f" . $e["\x69\144"] . "\x2e\152\163\157\x6e"); $this->assertSame(200, $this->client->getResponse()->getStatusCode()); $content = json_decode($this->client->getResponse()->getContent(), true); $this->assertSame($e["\x74\x69\x74\x6c\x65"], $content["\x74\x69\x74\154\145"]); $this->assertSame($e["\165\162\x6c"], $content["\165\x72\154"]); $this->assertSame($e["\x69\x64"], $content["\151\x64"]); $client = $this->createAuthorizedClient(); $client->request("\x44\x45\x4c\105\x54\105", "\x2f\x61\x70\x69\57\x65\156\x74\162\x69\145\x73\x2f" . $e["\151\x64"] . "\56\x6a\x73\157\x6e"); $this->assertSame(404, $client->getResponse()->getStatusCode()); } public function testDeleteEntryExpectId() { $em = $this->client->getContainer()->get(EntityManagerInterface::class); $entry = new Entry($em->getReference(User::class, 1)); $entry->setUrl("\150\164\164\160\x3a\57\x2f\60\56\60\56\x30\x2e\60\57\x74\145\163\164\55\x64\x65\154\x65\x74\x65\55\x65\x6e\164\x72\171\x2d\x69\x64"); $em->persist($entry); $em->flush(); $em->clear(); $id = $entry->getId(); $this->client->request("\x44\105\x4c\x45\124\105", "\x2f\141\160\151\x2f\145\156\164\x72\x69\x65\x73\x2f" . $id . "\56\152\163\157\156\77\145\x78\160\145\143\x74\x3d\151\144"); $this->assertSame(200, $this->client->getResponse()->getStatusCode()); $content = json_decode($this->client->getResponse()->getContent(), true); $this->assertSame($id, $content["\x69\x64"]); $this->assertArrayNotHasKey("\165\x72\x6c", $content); $client = $this->createAuthorizedClient(); $client->request("\104\x45\x4c\x45\x54\105", "\x2f\x61\160\x69\x2f\145\156\x74\x72\151\x65\163\x2f" . $id . "\x2e\x6a\x73\157\x6e"); $this->assertSame(404, $client->getResponse()->getStatusCode()); } public function testDeleteEntryExpectBadRequest() { $this->client->request("\104\105\114\105\124\105", "\x2f\x61\x70\151\x2f\145\156\164\162\151\x65\x73\x2f\x31\56\152\163\x6f\156\x3f\x65\x78\160\145\x63\164\75\x62\x61\x64\162\x65\x71\x75\145\163\x74"); $this->assertSame(400, $this->client->getResponse()->getStatusCode()); } public function testPostEntry() { $this->client->request("\120\x4f\x53\124", "\x2f\x61\x70\151\x2f\145\x6e\x74\162\151\145\x73\56\152\x73\157\x6e", array("\165\x72\154" => "\150\164\164\160\163\x3a\x2f\57\x77\167\x77\56\x6c\x65\x6d\157\156\144\x65\x2e\146\x72\x2f\x70\151\x78\145\x6c\163\57\141\x72\164\x69\143\154\145\57\62\60\x31\65\x2f\60\63\57\x32\x38\57\160\x6c\157\x6e\147\x65\x65\55\x64\141\x6e\x73\55\154\x2d\165\156\151\x76\145\x72\163\55\x64\x2d\151\x6e\147\162\145\163\163\55\154\x65\x2d\x6a\x65\x75\55\144\x65\55\x67\157\x6f\x67\x6c\145\x2d\x61\x75\170\x2d\146\162\157\156\164\x69\145\162\145\x73\55\144\165\x2d\162\x65\145\154\x5f\64\66\60\x31\x31\65\65\x5f\64\64\60\70\71\71\66\56\150\164\x6d\x6c", "\x74\x61\147\x73" => "\x67\x6f\x6f\147\154\x65", "\x74\x69\x74\154\145" => "\116\145\167\40\x74\151\164\x6c\145\40\146\157\162\x20\x6d\171\40\141\162\x74\x69\143\x6c\145", "\x63\157\156\x74\x65\156\164" => "\155\171\40\x63\x6f\x6e\164\145\x6e\x74", "\154\x61\156\147\165\x61\x67\145" => "\144\x65", "\160\165\142\154\x69\x73\150\145\x64\137\x61\x74" => "\62\x30\61\66\55\60\x39\55\60\70\124\61\x31\72\65\65\x3a\65\x38\x2b\60\x32\x30\x30", "\x61\165\x74\x68\157\162\x73" => "\x62\x6f\x62\54\x68\145\x6c\x65\x6e", "\160\x75\x62\154\151\x63" => 1)); $this->assertSame(200, $this->client->getResponse()->getStatusCode()); $content = json_decode($this->client->getResponse()->getContent(), true); $this->assertGreaterThan(0, $content["\x69\144"]); $this->assertSame("\150\164\164\x70\x73\x3a\57\57\167\x77\x77\x2e\154\145\155\157\156\144\x65\56\146\x72\x2f\160\151\170\x65\x6c\163\57\x61\162\x74\x69\x63\x6c\145\57\x32\x30\61\x35\57\60\63\57\x32\70\x2f\x70\x6c\157\x6e\147\x65\145\x2d\144\x61\x6e\163\x2d\154\55\x75\x6e\x69\x76\x65\162\x73\55\x64\x2d\151\x6e\147\x72\145\163\x73\x2d\154\145\x2d\152\x65\165\x2d\x64\145\x2d\x67\x6f\x6f\x67\154\145\x2d\141\165\x78\55\146\x72\157\156\x74\151\145\162\145\163\x2d\144\165\55\162\145\x65\154\137\x34\x36\x30\61\x31\65\65\x5f\x34\64\x30\x38\x39\71\x36\56\150\164\x6d\154", $content["\x75\x72\154"]); $this->assertSame(0, $content["\x69\163\x5f\x61\162\143\x68\151\166\x65\x64"]); $this->assertSame(0, $content["\x69\x73\x5f\x73\164\x61\x72\x72\x65\x64"]); $this->assertNull($content["\163\x74\x61\x72\x72\x65\144\x5f\141\164"]); $this->assertNull($content["\x61\x72\143\150\x69\166\145\144\137\141\x74"]); $this->assertSame("\x4e\x65\x77\40\164\x69\x74\154\145\40\x66\x6f\x72\40\155\171\x20\x61\x72\164\x69\143\x6c\145", $content["\164\x69\x74\154\x65"]); $this->assertSame($this->getUserId(), $content["\165\x73\x65\x72\137\151\144"]); $this->assertCount(2, $content["\x74\141\147\163"]); $this->assertNull($content["\x6f\162\151\x67\151\x6e\137\x75\162\x6c"]); $this->assertSame("\x6d\171\x20\x63\x6f\x6e\164\x65\x6e\x74", $content["\x63\x6f\x6e\x74\145\156\x74"]); $this->assertSame("\144\x65", $content["\154\x61\156\x67\x75\141\x67\145"]); $this->assertSame("\x32\x30\61\66\55\x30\x39\55\x30\70\124\x31\x31\x3a\65\65\x3a\x35\x38\53\60\x32\x30\x30", $content["\160\165\x62\x6c\x69\163\150\145\x64\137\x61\x74"]); $this->assertCount(2, $content["\x70\x75\x62\x6c\x69\163\x68\145\x64\137\x62\x79"]); $this->assertContains("\142\157\x62", $content["\160\x75\142\x6c\151\163\150\145\x64\x5f\x62\171"]); $this->assertContains("\x68\x65\154\145\x6e", $content["\160\165\142\154\151\163\x68\x65\144\137\x62\x79"]); $this->assertTrue($content["\x69\x73\137\x70\x75\142\154\x69\143"], "\x41\40\x70\165\142\x6c\151\143\40\154\x69\x6e\x6b\40\150\x61\x73\x20\142\145\145\x6e\40\x67\145\156\145\x72\141\164\145\144\x20\x66\x6f\162\x20\x74\x68\141\164\x20\x65\156\164\x72\171"); } public function testPostSameEntry() { $em = $this->client->getContainer()->get(EntityManagerInterface::class); $entry = new Entry($em->getReference(User::class, $this->getUserId())); $entry->setUrl("\x68\x74\164\x70\163\x3a\57\x2f\x77\167\167\x2e\x6c\x65\x6d\x6f\156\x64\x65\x2e\x66\162\x2f\x70\x69\x78\145\x6c\163\x2f\x61\162\x74\151\143\154\145\57\62\x30\x31\x35\57\60\x33\57\62\x38\x2f\x70\x6c\157\156\147\145\145\x2d\x64\141\x6e\163\55\154\x2d\x75\156\x69\166\x65\x72\163\55\x64\x2d\151\x6e\x67\x72\145\x73\x73\55\154\x65\x2d\152\145\165\55\x64\145\55\147\x6f\x6f\x67\154\145\55\x61\165\x78\55\x66\x72\157\x6e\x74\x69\145\x72\x65\x73\x2d\x64\x75\55\162\x65\145\154\137\64\x36\60\x31\x31\65\x35\x5f\64\64\x30\x38\71\x39\66\x2e\150\164\x6d\154"); $entry->setArchived(true); $entry->addTag((new Tag())->setLabel("\147\x6f\x6f\147\x6c\x65")); $entry->addTag((new Tag())->setLabel("\141\160\160\154\145")); $em->persist($entry); $em->flush(); $em->clear(); $this->client->request("\x50\117\123\124", "\57\x61\160\x69\x2f\x65\156\164\162\x69\x65\x73\56\x6a\163\x6f\156", array("\165\x72\154" => "\150\x74\164\x70\163\72\57\57\x77\167\167\x2e\154\145\155\157\x6e\144\x65\x2e\x66\162\57\x70\151\170\145\x6c\163\x2f\x61\162\164\151\x63\x6c\x65\x2f\62\60\61\65\x2f\60\x33\57\62\x38\57\x70\x6c\x6f\x6e\x67\145\145\x2d\x64\x61\156\163\x2d\x6c\55\165\x6e\151\x76\x65\x72\163\x2d\144\x2d\151\x6e\147\162\x65\x73\163\x2d\154\x65\55\152\145\165\55\144\145\55\147\x6f\x6f\147\x6c\x65\x2d\141\165\170\55\146\162\x6f\156\x74\151\x65\162\145\x73\x2d\x64\x75\x2d\162\145\145\154\x5f\64\x36\x30\x31\x31\65\65\137\64\x34\x30\x38\x39\x39\x36\56\150\164\155\154", "\141\162\143\x68\x69\x76\x65" => "\61", "\164\x61\147\x73" => "\x67\157\157\147\x6c\x65\54\x20\141\x70\x70\x6c\145")); $this->assertSame(200, $this->client->getResponse()->getStatusCode()); $content = json_decode($this->client->getResponse()->getContent(), true); $this->assertGreaterThan(0, $content["\151\144"]); $this->assertSame("\150\x74\x74\160\x73\x3a\57\57\x77\x77\x77\x2e\x6c\145\155\x6f\x6e\x64\145\x2e\146\162\x2f\x70\x69\x78\145\x6c\x73\57\x61\162\164\x69\143\x6c\x65\57\62\x30\61\x35\x2f\x30\x33\x2f\62\x38\57\160\154\x6f\156\x67\145\145\55\144\141\x6e\163\x2d\154\x2d\165\156\x69\x76\145\x72\163\55\144\55\x69\x6e\147\162\x65\163\x73\55\154\x65\55\152\x65\x75\55\144\x65\55\x67\x6f\x6f\147\154\x65\55\x61\x75\x78\x2d\x66\x72\x6f\156\x74\x69\x65\x72\x65\x73\55\x64\x75\55\162\145\145\154\x5f\64\66\60\61\61\x35\x35\137\x34\x34\x30\x38\x39\x39\66\56\x68\x74\155\x6c", $content["\165\162\x6c"]); $this->assertSame(1, $content["\x69\163\137\x61\162\x63\x68\x69\166\x65\144"]); $this->assertSame(0, $content["\151\x73\137\x73\164\141\162\x72\145\144"]); $this->assertCount(3, $content["\x74\x61\x67\163"]); } public function testPostEntryWhenFetchContentFails() { $container = $this->client->getContainer(); $contentProxy = $this->getMockBuilder(ContentProxy::class)->disableOriginalConstructor()->setMethods(array("\x75\160\144\141\164\145\105\x6e\164\x72\171"))->getMock(); $contentProxy->expects($this->any())->method("\165\x70\144\141\x74\145\x45\156\164\x72\x79")->willThrowException(new \Exception("\x54\145\163\164\x20\106\145\164\143\150\x20\x63\157\156\x74\x65\x6e\x74\x20\146\141\151\x6c\163")); $container->set(ContentProxy::class, $contentProxy); try { $this->client->request("\x50\117\x53\x54", "\57\x61\160\x69\x2f\145\x6e\164\162\x69\145\163\56\152\163\x6f\x6e", array("\x75\162\x6c" => "\x68\164\164\x70\x3a\x2f\57\167\167\x77\x2e\145\x78\141\x6d\x70\x6c\x65\56\x63\x6f\x6d\x2f")); $this->assertSame(200, $this->client->getResponse()->getStatusCode()); $content = json_decode($this->client->getResponse()->getContent(), true); $this->assertGreaterThan(0, $content["\151\144"]); $this->assertSame("\x68\164\x74\160\x3a\57\x2f\x77\167\x77\x2e\145\170\x61\155\160\x6c\x65\x2e\x63\157\155\x2f", $content["\165\x72\x6c"]); $this->assertSame("\167\x77\x77\x2e\x65\x78\x61\x6d\160\154\145\x2e\x63\x6f\155", $content["\x64\x6f\x6d\141\151\x6e\x5f\156\x61\x6d\145"]); $this->assertSame("\167\167\167\x2e\145\x78\x61\155\160\154\145\x2e\x63\157\x6d", $content["\164\151\x74\x6c\145"]); } finally { if (isset($content["\x69\144"])) { $em = $this->client->getContainer()->get(EntityManagerInterface::class); $entry = $em->getReference(Entry::class, $content["\x69\x64"]); $em->remove($entry); $em->flush(); } } } public function testPostArchivedAndStarredEntry() { $now = new \DateTime(); $this->client->request("\120\117\123\124", "\x2f\x61\x70\x69\x2f\145\x6e\x74\x72\151\x65\163\x2e\x6a\163\157\156", array("\x75\x72\154" => "\150\164\164\160\163\x3a\57\57\x77\167\167\56\x6c\x65\155\x6f\x6e\144\145\56\x66\162\x2f\x69\144\145\x65\163\57\x61\162\x74\x69\143\154\145\x2f\62\60\61\66\57\60\62\x2f\x30\x38\57\160\x72\x65\x73\145\162\x76\x65\x72\55\x6c\141\55\x6c\151\142\145\162\164\x65\55\x64\x2d\x65\170\160\x72\x65\163\163\151\157\156\55\163\x75\x72\55\x6c\x65\163\x2d\162\x65\x73\x65\141\165\170\55\163\x6f\x63\x69\x61\x75\x78\x5f\64\70\66\61\65\x30\x33\137\63\x32\x33\x32\x2e\150\x74\x6d\154", "\x61\x72\143\x68\151\166\x65" => "\x31", "\163\164\x61\x72\162\x65\x64" => "\61")); $this->assertSame(200, $this->client->getResponse()->getStatusCode()); $content = json_decode($this->client->getResponse()->getContent(), true); $this->assertGreaterThan(0, $content["\151\144"]); $this->assertSame("\150\164\x74\160\x73\x3a\x2f\57\167\x77\167\x2e\154\x65\155\157\156\x64\145\x2e\x66\x72\x2f\151\144\145\145\163\57\x61\x72\164\x69\143\154\x65\x2f\62\60\x31\x36\57\x30\62\57\60\x38\x2f\160\162\145\x73\x65\162\166\145\x72\55\154\141\55\x6c\x69\x62\145\x72\x74\145\x2d\144\x2d\145\x78\x70\x72\145\x73\x73\x69\157\156\x2d\x73\x75\162\x2d\154\x65\x73\55\x72\145\163\145\x61\165\x78\55\x73\157\x63\x69\x61\x75\x78\137\x34\70\x36\x31\x35\60\63\137\x33\62\63\62\x2e\150\164\x6d\154", $content["\165\x72\x6c"]); $this->assertSame(1, $content["\151\x73\137\x61\162\143\150\151\166\145\x64"]); $this->assertSame(1, $content["\x69\x73\x5f\163\x74\x61\162\162\x65\144"]); $this->assertGreaterThanOrEqual($now->getTimestamp(), (new \DateTime($content["\163\x74\x61\162\x72\x65\144\x5f\x61\x74"]))->getTimestamp()); $this->assertGreaterThanOrEqual($now->getTimestamp(), (new \DateTime($content["\x61\x72\x63\x68\x69\166\x65\x64\x5f\x61\x74"]))->getTimestamp()); $this->assertSame($this->getUserId(), $content["\165\163\x65\x72\x5f\x69\144"]); } public function testPostArchivedAndStarredEntryWithoutQuotes() { $this->client->request("\x50\117\x53\124", "\x2f\x61\x70\x69\57\x65\156\164\x72\x69\x65\163\x2e\152\x73\x6f\156", array("\165\162\154" => "\150\164\x74\160\x73\72\57\x2f\167\167\x77\56\x6c\145\x6d\x6f\156\144\x65\56\146\x72\57\x69\x64\145\x65\x73\57\141\162\164\151\x63\x6c\x65\x2f\x32\60\x31\66\x2f\60\62\x2f\60\x38\57\x70\x72\x65\x73\x65\162\166\145\x72\x2d\154\x61\55\x6c\x69\x62\x65\162\x74\x65\x2d\144\x2d\x65\x78\x70\162\145\163\163\151\157\156\55\x73\165\x72\x2d\154\145\163\55\x72\x65\x73\x65\x61\x75\170\x2d\x73\x6f\x63\151\x61\165\x78\x5f\64\70\x36\61\65\60\63\137\x33\x32\x33\x32\x2e\x68\164\x6d\x6c", "\x61\162\x63\x68\x69\166\x65" => 0, "\x73\x74\141\162\x72\x65\144" => 1)); $this->assertSame(200, $this->client->getResponse()->getStatusCode()); $content = json_decode($this->client->getResponse()->getContent(), true); $this->assertGreaterThan(0, $content["\x69\x64"]); $this->assertSame("\150\164\x74\160\163\x3a\x2f\57\x77\x77\x77\56\154\x65\x6d\157\156\144\145\x2e\146\162\x2f\x69\x64\x65\145\163\57\x61\162\x74\x69\143\154\x65\57\x32\x30\x31\x36\57\60\x32\x2f\60\x38\57\160\x72\145\x73\145\x72\166\145\x72\55\154\x61\x2d\154\151\142\x65\162\x74\x65\x2d\144\55\145\170\x70\x72\145\163\x73\151\157\x6e\x2d\163\165\162\55\154\145\163\55\x72\x65\x73\145\x61\165\x78\55\x73\157\143\151\x61\165\170\x5f\x34\70\66\61\x35\x30\x33\x5f\x33\62\63\x32\56\150\164\155\x6c", $content["\x75\x72\154"]); $this->assertSame(0, $content["\151\163\x5f\x61\x72\143\150\x69\166\x65\144"]); $this->assertSame(1, $content["\x69\x73\137\x73\164\x61\162\162\145\x64"]); } public function testPostEntryWithOriginUrl() { $this->client->request("\x50\x4f\x53\124", "\x2f\x61\x70\x69\x2f\145\x6e\x74\x72\x69\145\163\56\152\163\x6f\156", array("\x75\162\x6c" => "\150\x74\x74\160\x73\72\57\x2f\167\x77\x77\x2e\154\145\x6d\x6f\x6e\x64\x65\56\x66\162\x2f\160\151\170\145\x6c\x73\57\x61\x72\164\151\143\x6c\145\x2f\62\60\x31\65\57\x30\63\57\x32\70\x2f\x70\154\x6f\x6e\147\145\x65\55\x64\141\156\x73\x2d\x6c\x2d\165\x6e\x69\166\x65\x72\163\x2d\144\x2d\151\x6e\147\162\145\163\163\x2d\154\x65\x2d\x6a\145\165\x2d\144\145\55\147\x6f\157\147\x6c\x65\55\x61\165\x78\55\x66\162\157\x6e\x74\x69\145\x72\145\163\x2d\144\x75\x2d\162\145\145\154\137\x34\x36\60\x31\x31\65\x35\137\64\x34\60\x38\71\71\x36\56\150\x74\155\154", "\x74\141\147\x73" => "\147\x6f\x6f\147\x6c\145", "\x74\x69\x74\x6c\x65" => "\116\145\x77\40\164\151\x74\154\145\40\146\157\x72\40\155\171\x20\x61\162\164\151\143\x6c\x65", "\x63\157\x6e\164\145\x6e\x74" => "\x6d\x79\x20\143\x6f\156\164\145\x6e\x74", "\x6c\x61\x6e\x67\x75\141\147\x65" => "\144\145", "\x70\165\142\x6c\x69\x73\x68\x65\144\137\141\x74" => "\x32\x30\61\x36\55\x30\71\55\60\70\124\61\x31\x3a\x35\x35\x3a\65\x38\x2b\60\x32\60\x30", "\141\x75\x74\150\157\x72\x73" => "\x62\x6f\142\54\150\145\x6c\145\156", "\160\165\x62\x6c\151\x63" => 1, "\x6f\162\x69\147\x69\x6e\x5f\165\x72\154" => "\150\164\164\160\72\x2f\x2f\x6d\x79\x73\x6f\165\x72\x63\x65\56\x74\x6c\x64")); $this->assertSame(200, $this->client->getResponse()->getStatusCode()); $content = json_decode($this->client->getResponse()->getContent(), true); $this->assertGreaterThan(0, $content["\151\x64"]); $this->assertSame("\x68\x74\x74\x70\x73\x3a\57\x2f\x77\x77\x77\56\154\145\x6d\157\x6e\144\145\56\x66\x72\x2f\160\x69\x78\145\154\x73\57\141\x72\164\x69\x63\154\145\x2f\x32\60\x31\x35\x2f\x30\63\x2f\62\x38\x2f\160\x6c\157\x6e\x67\145\x65\55\x64\141\156\x73\x2d\x6c\55\x75\x6e\x69\166\x65\x72\163\x2d\x64\55\x69\x6e\147\162\145\x73\x73\55\x6c\x65\x2d\152\145\165\55\144\145\x2d\147\157\x6f\147\x6c\145\55\141\x75\170\55\146\162\157\x6e\x74\x69\145\162\x65\163\55\x64\165\x2d\x72\x65\x65\154\137\64\66\x30\x31\61\65\x35\137\x34\x34\x30\x38\71\x39\x36\x2e\150\x74\155\x6c", $content["\x75\x72\154"]); $this->assertSame("\150\x74\x74\x70\x3a\x2f\57\155\x79\x73\157\165\x72\x63\x65\x2e\164\154\x64", $content["\157\162\151\147\151\156\x5f\x75\162\x6c"]); } public function testPatchEntry() { $entry = $this->client->getContainer()->get(EntityManagerInterface::class)->getRepository(Entry::class)->findOneByUser($this->getUserId()); if (!$entry) { $this->markTestSkipped("\x4e\157\x20\143\x6f\156\164\x65\156\x74\40\146\157\x75\x6e\144\40\151\x6e\x20\144\x62\x2e"); } $this->client->request("\x50\101\124\103\110", "\57\x61\160\x69\57\145\156\x74\x72\x69\x65\163\57" . $entry->getId() . "\56\x6a\163\157\x6e", array("\x74\151\164\x6c\145" => "\116\145\167\x20\141\167\145\163\x6f\x6d\x65\x20\x74\x69\x74\x6c\145", "\x74\141\x67\x73" => "\x6e\x65\167\40\x74\141\147\40" . uniqid(), "\163\x74\x61\162\x72\x65\x64" => "\61", "\x61\x72\143\x68\151\x76\145" => "\x30", "\x6c\x61\x6e\x67\x75\x61\x67\x65" => "\144\x65\137\101\x54", "\x70\162\145\166\x69\145\x77\137\x70\151\x63\x74\x75\162\x65" => "\x68\x74\x74\160\72\x2f\57\160\162\145\166\151\145\167\x2e\x69\157\x2f\160\x69\x63\164\x75\162\145\56\x6a\x70\147", "\141\165\x74\150\x6f\x72\x73" => "\x62\157\142\54\x73\160\x6f\x6e\x67\145", "\143\x6f\x6e\164\x65\x6e\x74" => "\x61\x77\x65\163\157\x6d\145", "\160\x75\x62\154\x69\143" => 0, "\x70\x75\x62\x6c\151\x73\150\145\144\x5f\141\164" => 1488833381)); $this->assertSame(200, $this->client->getResponse()->getStatusCode()); $content = json_decode($this->client->getResponse()->getContent(), true); $this->assertSame($entry->getId(), $content["\151\144"]); $this->assertSame($entry->getUrl(), $content["\x75\x72\154"]); $this->assertSame("\116\x65\x77\x20\x61\x77\145\x73\x6f\155\x65\x20\164\151\x74\154\145", $content["\x74\x69\x74\x6c\x65"]); $this->assertGreaterThanOrEqual(1, \count($content["\164\x61\147\163"]), "\x57\x65\x20\x66\x6f\x72\143\145\x20\157\x6e\154\x79\x20\157\x6e\145\40\164\x61\147"); $this->assertSame($this->getUserId(), $content["\x75\163\x65\x72\x5f\x69\144"]); $this->assertSame("\x64\x65\x5f\x41\x54", $content["\154\x61\156\147\165\x61\147\145"]); $this->assertSame("\150\x74\164\160\x3a\57\x2f\160\x72\145\166\151\x65\167\x2e\151\x6f\x2f\x70\151\x63\x74\x75\162\145\56\x6a\160\147", $content["\160\x72\145\x76\x69\145\167\137\x70\x69\143\x74\165\162\x65"]); $this->assertContains("\163\x70\157\x6e\147\145", $content["\160\165\142\x6c\x69\163\x68\x65\144\x5f\142\171"]); $this->assertContains("\142\x6f\x62", $content["\160\x75\x62\x6c\151\x73\x68\x65\144\x5f\142\171"]); $this->assertSame("\x61\167\145\163\x6f\x6d\145", $content["\143\157\156\164\x65\x6e\164"]); $this->assertFalse($content["\151\163\x5f\160\x75\x62\154\x69\143"], "\105\x6e\164\162\171\40\x69\x73\x20\156\x6f\40\x6d\x6f\162\x65\x20\x73\150\141\x72\145\x64"); $this->assertStringContainsString("\x32\x30\61\67\x2d\60\x33\55\60\66", $content["\x70\x75\142\154\151\163\150\145\144\137\x61\164"]); } public function testPatchEntryWithoutQuotes() { $entry = $this->client->getContainer()->get(EntityManagerInterface::class)->getRepository(Entry::class)->findOneByUser($this->getUserId()); if (!$entry) { $this->markTestSkipped("\x4e\x6f\x20\143\157\x6e\x74\x65\156\x74\40\x66\x6f\165\x6e\144\x20\x69\x6e\x20\144\x62\56"); } $previousContent = $entry->getContent(); $previousLanguage = $entry->getLanguage(); $this->client->request("\x50\101\x54\103\x48", "\x2f\141\160\x69\57\x65\x6e\x74\162\x69\145\x73\57" . $entry->getId() . "\56\x6a\x73\x6f\156", array("\164\x69\x74\x6c\x65" => "\x4e\145\x77\x20\141\x77\x65\x73\x6f\x6d\x65\40\164\151\x74\154\145", "\x74\x61\x67\x73" => "\156\x65\x77\x20\x74\141\147\40" . uniqid(), "\x73\x74\x61\162\162\x65\144" => 1, "\x61\x72\143\x68\x69\x76\145" => 0, "\x61\165\164\150\x6f\x72\x73" => array("\x62\157\x62", "\x73\160\x6f\x6e\x67\x65"))); $this->assertSame(200, $this->client->getResponse()->getStatusCode()); $content = json_decode($this->client->getResponse()->getContent(), true); $this->assertSame($entry->getId(), $content["\151\144"]); $this->assertSame($entry->getUrl(), $content["\x75\x72\154"]); $this->assertGreaterThanOrEqual(1, \count($content["\x74\141\x67\x73"]), "\127\145\x20\146\x6f\x72\x63\145\x20\x6f\156\154\x79\40\157\156\x65\x20\x74\x61\x67"); $this->assertEmpty($content["\x70\x75\x62\154\x69\x73\x68\145\144\137\142\171"], "\x41\x75\x74\150\157\162\163\40\x77\x65\x72\x65\x20\156\x6f\164\40\x73\x61\x76\145\x64\x20\x62\145\x63\x61\165\x73\145\40\x6f\x66\x20\141\156\40\x61\x72\x72\141\171\x20\x69\x6e\x73\164\145\x61\144\x20\157\x66\40\x61\x20\163\164\x72\151\156\x67"); $this->assertSame($previousContent, $content["\143\x6f\x6e\x74\145\x6e\x74"], "\x45\x6e\163\165\x72\x65\40\143\x6f\156\164\145\x6e\164\x20\150\x61\x73\x20\x6e\157\x74\x20\x6d\x6f\x76\145\144"); $this->assertSame($previousLanguage, $content["\154\x61\x6e\x67\165\x61\147\x65"], "\x45\x6e\x73\165\x72\145\x20\x6c\x61\156\147\x75\x61\x67\145\x20\150\x61\163\x20\156\157\x74\x20\x6d\157\166\145\144"); } public function testPatchEntryWithOriginUrl() { $entry = $this->client->getContainer()->get(EntityManagerInterface::class)->getRepository(Entry::class)->findOneByUser($this->getUserId()); if (!$entry) { $this->markTestSkipped("\116\157\x20\x63\157\x6e\164\x65\x6e\x74\x20\x66\x6f\165\156\144\x20\x69\156\x20\x64\142\x2e"); } $previousContent = $entry->getContent(); $previousLanguage = $entry->getLanguage(); $this->client->request("\120\101\124\x43\110", "\57\x61\x70\x69\x2f\145\x6e\x74\x72\151\x65\163\57" . $entry->getId() . "\56\152\x73\157\x6e", array("\164\x69\164\154\145" => "\101\x6e\157\x74\x68\145\162\x20\141\167\x65\163\157\x6d\145\40\x74\x69\164\154\145\40\x6a\x75\163\x74\x20\146\x6f\162\x20\x70\162\x6f\146\x69\164", "\157\x72\151\x67\151\156\137\165\162\154" => "\x68\164\x74\x70\163\x3a\57\57\x6d\171\141\x77\145\x73\x6f\x6d\x65\163\x6f\165\x72\x63\x65\56\x65\x78\141\x6d\x70\154\145\56\x63\157\155")); $this->assertSame(200, $this->client->getResponse()->getStatusCode()); $content = json_decode($this->client->getResponse()->getContent(), true); $this->assertSame($entry->getId(), $content["\x69\x64"]); $this->assertSame($entry->getUrl(), $content["\165\162\154"]); $this->assertSame("\150\164\164\160\x73\x3a\x2f\x2f\x6d\171\x61\167\x65\163\157\x6d\145\x73\157\165\162\143\x65\56\x65\170\141\155\160\154\x65\56\143\x6f\155", $content["\x6f\x72\151\147\151\x6e\137\x75\x72\x6c"]); $this->assertEmpty($content["\160\165\x62\154\x69\x73\x68\145\144\137\x62\171"], "\x41\x75\x74\150\x6f\x72\163\40\x77\x65\x72\x65\40\x6e\x6f\164\40\163\141\x76\x65\x64\40\142\145\143\x61\165\163\x65\x20\157\146\40\x61\x6e\x20\141\162\x72\x61\171\x20\x69\x6e\x73\x74\x65\x61\144\x20\157\146\40\x61\x20\163\164\162\151\156\x67"); $this->assertSame($previousContent, $content["\x63\157\156\164\x65\x6e\164"], "\x45\x6e\x73\165\x72\145\40\143\x6f\x6e\164\x65\x6e\x74\40\x68\x61\163\40\x6e\x6f\x74\x20\x6d\x6f\166\x65\x64"); $this->assertSame($previousLanguage, $content["\154\x61\156\147\165\x61\x67\145"], "\x45\x6e\x73\165\x72\145\40\154\x61\x6e\147\x75\x61\x67\x65\x20\x68\x61\x73\40\x6e\157\164\x20\x6d\x6f\x76\145\144"); } public function testPatchEntryRemoveOriginUrl() { $entry = $this->client->getContainer()->get(EntityManagerInterface::class)->getRepository(Entry::class)->findOneByUser($this->getUserId()); if (!$entry) { $this->markTestSkipped("\116\157\x20\x63\157\156\164\x65\156\164\x20\x66\157\x75\156\x64\40\x69\x6e\40\x64\142\56"); } $previousContent = $entry->getContent(); $previousLanguage = $entry->getLanguage(); $previousTitle = $entry->getTitle(); $this->client->request("\120\x41\124\103\110", "\57\141\160\151\57\145\x6e\x74\x72\151\145\163\57" . $entry->getId() . "\56\152\163\157\156", array("\x6f\162\151\x67\x69\156\x5f\165\162\x6c" => '')); $this->assertSame(200, $this->client->getResponse()->getStatusCode()); $content = json_decode($this->client->getResponse()->getContent(), true); $this->assertSame($entry->getId(), $content["\151\x64"]); $this->assertSame($entry->getUrl(), $content["\165\162\154"]); $this->assertEmpty($content["\157\162\151\147\x69\156\x5f\165\x72\154"]); $this->assertEmpty($content["\x70\x75\142\x6c\x69\x73\150\x65\x64\137\x62\x79"], "\101\165\164\x68\x6f\162\163\x20\x77\x65\x72\145\40\156\157\164\x20\163\141\166\x65\144\40\x62\x65\x63\141\x75\x73\145\40\157\146\x20\141\x6e\x20\x61\x72\x72\141\x79\40\151\x6e\163\164\145\x61\144\40\157\x66\40\x61\x20\x73\164\x72\x69\156\x67"); $this->assertSame($previousContent, $content["\143\x6f\x6e\164\x65\x6e\x74"], "\105\x6e\x73\165\162\145\x20\143\157\x6e\x74\x65\x6e\164\x20\150\x61\x73\x20\156\157\164\40\155\157\x76\x65\144"); $this->assertSame($previousLanguage, $content["\154\141\x6e\x67\165\141\x67\145"], "\x45\x6e\x73\165\162\x65\40\154\141\156\147\x75\x61\147\x65\x20\150\141\x73\40\x6e\157\x74\x20\x6d\x6f\166\145\x64"); $this->assertSame($previousTitle, $content["\164\151\164\x6c\x65"], "\x45\156\163\165\x72\145\x20\164\151\x74\154\x65\x20\150\x61\163\x20\156\x6f\x74\x20\155\157\x76\x65\x64"); } public function testPatchEntryNullOriginUrl() { $entry = $this->client->getContainer()->get(EntityManagerInterface::class)->getRepository(Entry::class)->findOneByUser($this->getUserId()); if (!$entry) { $this->markTestSkipped("\x4e\x6f\40\x63\x6f\x6e\164\x65\156\x74\40\x66\157\x75\156\x64\40\x69\156\x20\144\142\x2e"); } $this->client->request("\x50\x41\124\103\110", "\x2f\141\160\151\57\x65\156\164\162\151\145\163\57" . $entry->getId() . "\x2e\x6a\x73\157\x6e", array("\157\x72\151\147\x69\x6e\x5f\x75\162\x6c" => null)); $this->assertSame(200, $this->client->getResponse()->getStatusCode()); $content = json_decode($this->client->getResponse()->getContent(), true); $this->assertNull($content["\x6f\x72\x69\x67\x69\156\137\x75\x72\154"]); } public function testGetTagsEntry() { $entry = $this->client->getContainer()->get(EntityManagerInterface::class)->getRepository(Entry::class)->findOneWithTags($this->user->getId()); $entry = $entry[0]; if (!$entry) { $this->markTestSkipped("\116\x6f\x20\143\157\x6e\164\x65\x6e\x74\x20\x66\x6f\x75\156\144\40\x69\x6e\x20\x64\142\x2e"); } $tags = array(); foreach ($entry->getTags() as $tag) { $tags[] = array("\151\144" => $tag->getId(), "\x6c\x61\x62\x65\x6c" => $tag->getLabel(), "\163\x6c\x75\x67" => $tag->getSlug()); } $this->client->request("\x47\x45\124", "\x2f\x61\x70\151\x2f\145\x6e\164\x72\x69\x65\163\x2f" . $entry->getId() . "\x2f\x74\x61\x67\163"); $this->assertSame(json_encode($tags, \JSON_HEX_QUOT), $this->client->getResponse()->getContent()); } public function testPostTagsOnEntry() { $entry = $this->client->getContainer()->get(EntityManagerInterface::class)->getRepository(Entry::class)->findOneByUser($this->getUserId()); if (!$entry) { $this->markTestSkipped("\x4e\157\40\x63\x6f\x6e\164\145\x6e\164\40\146\157\165\x6e\x64\x20\151\x6e\40\x64\x62\56"); } $nbTags = \count($entry->getTags()); $newTags = "\x74\141\147\61\x2c\164\x61\x67\x32\x2c\x74\x61\x67\x33"; $this->client->request("\x50\x4f\x53\x54", "\57\141\160\x69\x2f\x65\x6e\164\162\151\145\x73\x2f" . $entry->getId() . "\57\x74\141\147\163", array("\164\141\147\x73" => $newTags)); $this->assertSame(200, $this->client->getResponse()->getStatusCode()); $content = json_decode($this->client->getResponse()->getContent(), true); $this->assertArrayHasKey("\x74\141\147\163", $content); $this->assertCount($nbTags + 3, $content["\x74\141\147\163"]); $entryDB = $this->client->getContainer()->get(EntityManagerInterface::class)->getRepository(Entry::class)->find($entry->getId()); $tagsInDB = array(); foreach ($entryDB->getTags()->toArray() as $tag) { $tagsInDB[$tag->getId()] = $tag->getLabel(); } foreach (explode("\54", $newTags) as $tag) { $this->assertContains($tag, $tagsInDB); } } public function testDeleteOneTagEntry() { $entry = $this->client->getContainer()->get(EntityManagerInterface::class)->getRepository(Entry::class)->findOneWithTags($this->user->getId()); $entry = $entry[0]; if (!$entry) { $this->markTestSkipped("\x4e\x6f\x20\143\157\x6e\164\x65\156\x74\x20\x66\x6f\x75\x6e\x64\40\151\x6e\40\144\x62\56"); } $nbTags = \count($entry->getTags()); $tag = $entry->getTags()[0]; $this->client->request("\104\x45\x4c\105\124\x45", "\x2f\x61\160\x69\57\x65\156\x74\x72\151\x65\x73\x2f" . $entry->getId() . "\57\164\x61\x67\x73\x2f" . $tag->getId() . "\56\x6a\x73\x6f\x6e"); $this->assertSame(200, $this->client->getResponse()->getStatusCode()); $content = json_decode($this->client->getResponse()->getContent(), true); $this->assertArrayHasKey("\164\x61\147\x73", $content); $this->assertCount($nbTags - 1, $content["\164\x61\147\x73"]); } public function testSaveIsArchivedAfterPost() { $entry = $this->client->getContainer()->get(EntityManagerInterface::class)->getRepository(Entry::class)->findOneBy(array("\x75\163\145\x72" => $this->getUserId(), "\x69\163\x41\x72\x63\x68\151\166\x65\x64" => true)); if (!$entry) { $this->markTestSkipped("\116\x6f\x20\x63\157\156\x74\x65\x6e\x74\40\x66\x6f\x75\x6e\144\40\x69\x6e\x20\144\x62\x2e"); } $this->client->request("\120\x4f\x53\x54", "\x2f\141\160\x69\x2f\145\156\164\x72\x69\145\163\56\x6a\163\157\x6e", array("\x75\x72\154" => $entry->getUrl())); $this->assertSame(200, $this->client->getResponse()->getStatusCode()); $content = json_decode($this->client->getResponse()->getContent(), true); $this->assertSame(1, $content["\x69\163\137\x61\162\143\150\151\x76\145\x64"]); } public function testSaveIsStarredAfterPost() { $entry = $this->client->getContainer()->get(EntityManagerInterface::class)->getRepository(Entry::class)->findOneBy(array("\x75\163\x65\162" => $this->getUserId(), "\x69\163\x53\x74\x61\162\x72\x65\x64" => true)); if (!$entry) { $this->markTestSkipped("\116\157\40\x63\157\x6e\164\x65\x6e\x74\x20\x66\x6f\x75\156\x64\40\151\156\40\x64\x62\x2e"); } $this->client->request("\120\x4f\x53\124", "\x2f\x61\160\x69\57\x65\156\164\x72\151\145\x73\56\152\x73\x6f\x6e", array("\x75\x72\x6c" => $entry->getUrl())); $this->assertSame(200, $this->client->getResponse()->getStatusCode()); $content = json_decode($this->client->getResponse()->getContent(), true); $this->assertSame(1, $content["\151\163\x5f\163\164\141\x72\x72\145\x64"]); } public function testSaveIsArchivedAfterPatch() { $now = new \DateTime(); $entry = $this->client->getContainer()->get(EntityManagerInterface::class)->getRepository(Entry::class)->findOneBy(array("\x75\163\145\162" => $this->getUserId(), "\151\x73\101\162\143\150\x69\x76\x65\144" => true)); if (!$entry) { $this->markTestSkipped("\x4e\x6f\x20\143\x6f\156\164\x65\x6e\164\40\x66\x6f\165\x6e\x64\x20\x69\x6e\x20\144\142\56"); } $previousTitle = $entry->getTitle(); $this->client->request("\x50\101\124\103\x48", "\x2f\x61\160\151\57\145\156\164\x72\151\145\163\57" . $entry->getId() . "\56\152\x73\x6f\156", array("\164\151\x74\154\x65" => $entry->getTitle() . "\53\x2b")); $this->assertSame(200, $this->client->getResponse()->getStatusCode()); $content = json_decode($this->client->getResponse()->getContent(), true); $this->assertSame(1, $content["\x69\x73\x5f\141\162\x63\150\x69\166\145\x64"]); $this->assertSame($previousTitle . "\x2b\x2b", $content["\164\x69\x74\x6c\145"]); $this->assertGreaterThanOrEqual((new \DateTime($content["\141\162\x63\x68\x69\x76\x65\x64\137\x61\x74"]))->getTimestamp(), $now->getTimestamp()); } public function testSaveIsStarredAfterPatch() { $now = new \DateTime(); $entry = $this->client->getContainer()->get(EntityManagerInterface::class)->getRepository(Entry::class)->findOneBy(array("\165\x73\x65\162" => $this->getUserId(), "\151\163\x53\x74\x61\162\162\145\144" => true)); if (!$entry) { $this->markTestSkipped("\x4e\157\x20\143\157\156\x74\x65\156\164\40\x66\x6f\x75\x6e\144\40\x69\x6e\40\x64\x62\56"); } $previousTitle = $entry->getTitle(); $this->client->request("\120\101\124\x43\x48", "\x2f\141\x70\x69\x2f\x65\156\x74\162\x69\x65\x73\x2f" . $entry->getId() . "\56\x6a\163\157\x6e", array("\164\151\164\154\145" => $entry->getTitle() . "\53\x2b")); $this->assertSame(200, $this->client->getResponse()->getStatusCode()); $content = json_decode($this->client->getResponse()->getContent(), true); $this->assertSame(1, $content["\151\x73\137\x73\x74\x61\162\x72\x65\x64"]); $this->assertSame($previousTitle . "\x2b\53", $content["\164\x69\164\x6c\x65"]); $this->assertGreaterThanOrEqual((new \DateTime($content["\x73\x74\141\x72\x72\x65\144\137\x61\x74"]))->getTimestamp(), $now->getTimestamp()); } public function dataForEntriesExistWithUrl() { $url = hash("\x73\x68\x61\61", "\x68\x74\x74\160\x3a\x2f\57\60\56\60\56\x30\56\60\x2f\145\156\164\x72\x79\62"); return array("\x77\x69\164\150\137\151\x64" => array("\x75\x72\154" => "\x2f\x61\x70\x69\x2f\x65\x6e\x74\162\x69\x65\x73\57\145\170\151\163\x74\x73\77\165\x72\154\x3d\x68\164\x74\160\72\57\57\60\56\60\x2e\x30\56\x30\57\145\x6e\164\162\171\x32\x26\x72\x65\164\x75\162\x6e\137\x69\144\x3d\61", "\145\x78\160\145\143\164\x65\x64\126\141\x6c\x75\145" => 2), "\167\x69\164\x68\x6f\x75\x74\x5f\151\x64" => array("\165\x72\x6c" => "\57\141\160\x69\57\145\x6e\164\162\151\145\x73\x2f\145\170\x69\x73\164\x73\x3f\165\162\x6c\75\x68\164\164\x70\72\x2f\x2f\x30\x2e\60\56\60\56\x30\57\145\x6e\164\x72\171\x32", "\x65\x78\x70\x65\143\164\145\x64\x56\141\x6c\165\x65" => true), "\x68\x61\x73\150\x65\x64\137\x75\x72\x6c\137\167\x69\x74\x68\x5f\x69\x64" => array("\165\x72\154" => "\x2f\141\x70\151\57\145\156\164\162\x69\145\163\57\x65\170\x69\163\164\x73\77\x68\x61\x73\x68\145\x64\137\x75\x72\x6c\75" . $url . "\x26\x72\x65\x74\165\162\156\x5f\151\x64\75\61", "\x65\170\x70\145\x63\164\145\144\126\x61\154\x75\145" => 2), "\x68\141\x73\150\145\144\137\165\162\154\x5f\x77\x69\x74\x68\157\165\x74\x5f\x69\x64" => array("\x75\x72\x6c" => "\x2f\141\x70\x69\57\x65\x6e\164\162\x69\145\163\57\145\x78\151\163\164\x73\77\x68\x61\163\x68\x65\x64\137\x75\x72\154\75" . $url . '', "\145\170\x70\x65\x63\x74\x65\x64\x56\141\x6c\165\x65" => true)); } public function testGetEntriesExists($url, $expectedValue) { $this->client->request("\x47\105\x54", $url); $this->assertSame(200, $this->client->getResponse()->getStatusCode()); $content = json_decode($this->client->getResponse()->getContent(), true); $this->assertSame($expectedValue, $content["\145\x78\x69\163\x74\x73"]); } public function testGetEntriesExistsWithManyUrls() { $url1 = "\150\164\x74\x70\x3a\57\57\x30\x2e\60\x2e\60\x2e\60\x2f\x65\x6e\x74\162\x79\x32"; $url2 = "\x68\164\x74\x70\x3a\57\57\60\x2e\x30\x2e\x30\x2e\x30\x2f\145\x6e\x74\162\x79\x31\60"; $this->client->request("\x47\x45\124", "\x2f\141\x70\151\x2f\x65\156\164\x72\x69\145\x73\57\145\170\x69\163\164\x73\x3f\x75\x72\154\163\133\x5d\75" . $url1 . "\46\x75\x72\154\x73\133\x5d\x3d" . $url2 . "\46\x72\x65\164\x75\x72\x6e\137\151\144\75\61"); $this->assertSame(200, $this->client->getResponse()->getStatusCode()); $content = json_decode($this->client->getResponse()->getContent(), true); $this->assertArrayHasKey($url1, $content); $this->assertArrayHasKey($url2, $content); $this->assertGreaterThan(1, $content[$url1]); $this->assertNull($content[$url2]); } public function testGetEntriesExistsWithManyUrlsReturnBool() { $url1 = "\150\x74\164\160\72\x2f\x2f\60\56\60\56\60\56\60\57\145\156\164\x72\171\62"; $url2 = "\150\x74\164\160\x3a\57\x2f\x30\56\x30\x2e\60\56\60\57\145\x6e\x74\162\x79\x31\60"; $this->client->request("\x47\x45\124", "\57\141\160\151\57\x65\x6e\x74\162\151\x65\163\x2f\145\170\x69\x73\x74\163\77\165\162\154\x73\133\x5d\x3d" . $url1 . "\46\165\x72\x6c\163\133\x5d\75" . $url2); $this->assertSame(200, $this->client->getResponse()->getStatusCode()); $content = json_decode($this->client->getResponse()->getContent(), true); $this->assertArrayHasKey($url1, $content); $this->assertArrayHasKey($url2, $content); $this->assertTrue($content[$url1]); $this->assertFalse($content[$url2]); } public function testGetEntriesExistsWithManyUrlsHashed() { $url1 = "\150\164\x74\160\x3a\x2f\57\x30\56\x30\56\x30\x2e\60\x2f\x65\x6e\164\x72\x79\62"; $url2 = "\x68\164\164\160\72\x2f\x2f\x30\56\x30\56\60\56\60\x2f\145\x6e\164\x72\x79\x31\x30"; $this->client->request("\x47\x45\124", "\57\x61\160\151\x2f\145\x6e\164\x72\x69\x65\x73\x2f\145\x78\x69\x73\164\x73\x3f\150\x61\163\x68\x65\x64\137\x75\x72\154\163\133\x5d\x3d" . hash("\x73\x68\141\x31", $url1) . "\46\x68\x61\163\x68\x65\144\x5f\165\x72\154\163\x5b\x5d\75" . hash("\x73\150\141\61", $url2) . "\46\162\x65\x74\165\162\156\x5f\151\144\75\61"); $this->assertSame(200, $this->client->getResponse()->getStatusCode()); $content = json_decode($this->client->getResponse()->getContent(), true); $this->assertArrayHasKey(hash("\163\150\141\61", $url1), $content); $this->assertArrayHasKey(hash("\x73\x68\141\61", $url2), $content); $this->assertSame(2, $content[hash("\x73\x68\141\x31", $url1)]); $this->assertNull($content[hash("\163\150\141\x31", $url2)]); } public function testGetEntriesExistsWithManyUrlsHashedReturnBool() { $url1 = "\150\164\x74\x70\72\x2f\57\60\x2e\60\x2e\x30\x2e\60\57\145\x6e\x74\x72\x79\x32"; $url2 = "\x68\x74\164\160\x3a\57\57\x30\x2e\x30\x2e\x30\56\60\57\x65\156\164\x72\x79\x31\60"; $this->client->request("\107\x45\x54", "\x2f\141\x70\151\57\145\x6e\164\162\x69\x65\x73\x2f\145\170\151\163\164\x73\77\x68\141\x73\x68\x65\x64\x5f\165\x72\154\x73\x5b\x5d\75" . hash("\163\150\141\x31", $url1) . "\46\x68\x61\x73\150\145\144\137\x75\x72\x6c\x73\x5b\x5d\x3d" . hash("\163\150\141\x31", $url2)); $this->assertSame(200, $this->client->getResponse()->getStatusCode()); $content = json_decode($this->client->getResponse()->getContent(), true); $this->assertArrayHasKey(hash("\x73\150\x61\x31", $url1), $content); $this->assertArrayHasKey(hash("\x73\150\x61\61", $url2), $content); $this->assertTrue($content[hash("\x73\x68\x61\x31", $url1)]); $this->assertFalse($content[hash("\163\x68\141\x31", $url2)]); } public function testGetEntriesExistsWhichDoesNotExists() { $this->client->request("\107\x45\124", "\x2f\141\160\151\57\145\x6e\x74\x72\x69\x65\163\57\145\x78\151\163\x74\163\x3f\x75\162\154\x3d\150\164\164\160\72\57\57\147\157\157\147\x6c\x65\56\143\x6f\x6d\57\x65\156\164\162\x79\x32"); $this->assertSame(200, $this->client->getResponse()->getStatusCode()); $content = json_decode($this->client->getResponse()->getContent(), true); $this->assertFalse($content["\145\170\x69\x73\164\x73"]); } public function testGetEntriesExistsWhichDoesNotExistsWithHashedUrl() { $this->client->request("\x47\105\x54", "\57\x61\x70\x69\x2f\x65\x6e\164\162\x69\x65\163\57\x65\x78\151\x73\164\163\x3f\150\x61\163\x68\x65\144\x5f\165\162\154\x3d" . hash("\163\150\141\x31", "\x68\164\x74\x70\x3a\57\57\147\x6f\157\147\x6c\x65\56\143\x6f\155\x2f\x65\156\164\162\x79\62")); $this->assertSame(200, $this->client->getResponse()->getStatusCode()); $content = json_decode($this->client->getResponse()->getContent(), true); $this->assertFalse($content["\x65\170\x69\x73\164\163"]); } public function testGetEntriesExistsWithNoUrl() { $this->client->request("\x47\x45\124", "\x2f\141\x70\x69\57\x65\x6e\x74\162\151\x65\163\x2f\x65\x78\151\163\x74\163\77\x75\x72\154\75"); $this->assertSame(403, $this->client->getResponse()->getStatusCode()); } public function testGetEntriesExistsWithNoHashedUrl() { $this->client->request("\x47\105\x54", "\x2f\141\x70\x69\57\x65\x6e\x74\x72\x69\145\163\x2f\x65\170\151\163\164\x73\77\x68\141\x73\150\145\144\137\165\162\154\75"); $this->assertSame(403, $this->client->getResponse()->getStatusCode()); } public function testReloadEntryErrorWhileFetching() { $entry = $this->client->getContainer()->get(EntityManagerInterface::class)->getRepository(Entry::class)->findByUrlAndUserId("\150\164\164\160\72\57\x2f\x30\56\x30\x2e\x30\x2e\60\x2f\x65\x6e\x74\162\x79\64", $this->getUserId()); if (!$entry) { $this->markTestSkipped("\116\x6f\x20\143\x6f\x6e\164\145\x6e\x74\x20\x66\x6f\x75\x6e\x64\40\151\156\x20\x64\x62\56"); } $this->client->request("\x50\101\124\103\x48", "\57\x61\x70\x69\57\145\156\x74\162\151\145\163\x2f" . $entry->getId() . "\x2f\162\145\154\x6f\x61\x64\x2e\152\x73\x6f\x6e"); $this->assertSame(304, $this->client->getResponse()->getStatusCode()); } public function testReloadEntry() { $this->client->request("\x50\117\x53\124", "\x2f\x61\x70\x69\x2f\145\x6e\164\162\151\145\163\56\x6a\163\x6f\x6e", array("\x75\162\x6c" => "\x68\164\164\160\x73\x3a\57\57\x77\x77\167\56\154\x65\x6d\x6f\x6e\x64\x65\56\x66\162\x2f\160\151\170\145\154\x73\57\x61\x72\164\x69\x63\x6c\x65\x2f\62\60\61\x35\57\x30\63\x2f\x32\70\x2f\x70\x6c\x6f\156\x67\145\x65\x2d\x64\x61\156\163\x2d\154\x2d\165\156\151\x76\145\x72\163\x2d\x64\x2d\151\156\x67\x72\145\163\x73\55\154\x65\55\152\x65\x75\55\144\145\x2d\147\x6f\157\147\x6c\145\x2d\x61\165\x78\55\x66\162\157\x6e\164\151\145\162\x65\163\55\x64\165\55\162\145\x65\x6c\x5f\64\x36\x30\61\x31\x35\65\137\x34\64\x30\70\71\x39\x36\56\150\164\155\154", "\x61\162\x63\x68\151\x76\145" => "\61", "\x74\141\x67\163" => "\x67\x6f\x6f\x67\154\x65\x2c\x20\x61\160\160\154\x65")); $json = json_decode($this->client->getResponse()->getContent(), true); $this->setUp(); $this->client->request("\120\x41\124\x43\x48", "\x2f\141\160\x69\x2f\145\156\164\162\x69\145\x73\57" . $json["\151\x64"] . "\x2f\162\145\x6c\x6f\141\x64\x2e\152\x73\x6f\156"); $this->assertSame(200, $this->client->getResponse()->getStatusCode()); $content = json_decode($this->client->getResponse()->getContent(), true); $this->assertNotEmpty($content["\164\151\164\x6c\145"]); $this->assertSame("\x61\x70\160\x6c\151\143\x61\x74\151\x6f\156\57\x6a\163\157\x6e", $this->client->getResponse()->headers->get("\103\157\156\x74\145\156\164\x2d\x54\171\160\145")); } public function testPostEntriesTagsListAction() { $entry = $this->client->getContainer()->get(EntityManagerInterface::class)->getRepository(Entry::class)->findByUrlAndUserId("\x68\164\164\x70\x3a\x2f\x2f\x30\56\60\56\x30\56\60\x2f\145\156\x74\162\x79\64", $this->getUserId()); $tags = $entry->getTags(); $this->assertCount(2, $tags); $list = array(array("\165\x72\x6c" => "\150\x74\164\x70\x3a\x2f\x2f\60\x2e\x30\56\60\x2e\x30\57\145\x6e\164\x72\171\64", "\x74\x61\147\x73" => "\156\x65\x77\40\x74\x61\147\x20\x31\54\40\x6e\x65\x77\40\164\141\147\40\62")); $this->client->request("\120\x4f\123\x54", "\57\141\x70\x69\57\x65\156\164\x72\x69\x65\163\57\x74\x61\147\x73\x2f\x6c\x69\x73\x74\x73\77\154\151\x73\x74\75" . json_encode($list)); $this->assertSame(200, $this->client->getResponse()->getStatusCode()); $content = json_decode($this->client->getResponse()->getContent(), true); $this->assertIsInt($content[0]["\x65\x6e\x74\162\171"]); $this->assertSame("\x68\164\164\x70\x3a\x2f\x2f\60\x2e\60\56\60\56\60\x2f\145\156\x74\162\x79\x34", $content[0]["\165\162\154"]); $entry = $this->client->getContainer()->get(EntityManagerInterface::class)->getRepository(Entry::class)->findByUrlAndUserId("\x68\164\164\160\x3a\x2f\57\60\x2e\60\56\60\x2e\60\x2f\x65\x6e\164\x72\x79\x34", $this->getUserId()); $tags = $entry->getTags(); $this->assertCount(4, $tags); } public function testPostEntriesTagsListActionNoList() { $this->client->request("\x50\117\x53\x54", "\x2f\x61\160\151\57\x65\156\164\162\151\x65\x73\x2f\x74\141\147\x73\57\x6c\151\163\x74\163\x3f\x6c\x69\163\164\x3d" . json_encode(array())); $this->assertSame(200, $this->client->getResponse()->getStatusCode()); $content = json_decode($this->client->getResponse()->getContent(), true); $this->assertEmpty($content); } public function testDeleteEntriesTagsListAction() { $em = $this->client->getContainer()->get(EntityManagerInterface::class); $entry = new Entry($em->getReference(User::class, $this->getUserId())); $entry->setUrl("\150\164\164\160\x3a\x2f\57\x30\x2e\60\x2e\x30\56\60\57\164\x65\163\164\55\145\x6e\164\162\x79"); $entry->addTag((new Tag())->setLabel("\146\157\157\x2d\164\141\x67")); $entry->addTag((new Tag())->setLabel("\x62\141\x72\x2d\164\141\147")); $em->persist($entry); $em->flush(); $em->clear(); $list = array(array("\x75\162\154" => "\x68\x74\164\x70\72\x2f\57\x30\56\x30\x2e\x30\x2e\60\57\x74\145\x73\x74\x2d\145\x6e\x74\x72\x79", "\x74\141\147\x73" => "\146\157\x6f\55\164\141\147\x2c\40\x62\x61\162\55\x74\x61\x67")); $this->client->request("\104\105\x4c\x45\x54\105", "\57\141\160\151\x2f\x65\x6e\x74\x72\151\145\163\57\164\x61\x67\163\57\x6c\x69\163\164\77\154\x69\x73\164\75" . json_encode($list)); $this->assertSame(200, $this->client->getResponse()->getStatusCode()); $entry = $em->getRepository(Entry::class)->find($entry->getId()); $this->assertCount(0, $entry->getTags()); } public function testDeleteEntriesTagsListActionNoList() { $this->client->request("\x44\x45\x4c\x45\124\x45", "\x2f\141\160\151\57\x65\x6e\164\162\x69\145\163\57\x74\x61\x67\163\x2f\154\151\163\164\77\x6c\151\163\x74\x3d" . json_encode(array())); $this->assertSame(200, $this->client->getResponse()->getStatusCode()); $content = json_decode($this->client->getResponse()->getContent(), true); $this->assertEmpty($content); } public function testPostEntriesListAction() { $list = array("\x68\164\164\x70\x73\x3a\x2f\x2f\x77\167\x77\x2e\154\145\155\157\156\x64\145\56\146\162\57\x6d\x75\x73\151\161\165\x65\163\57\x61\162\164\x69\x63\x6c\x65\57\62\x30\x31\67\57\x30\64\x2f\62\x33\57\x6c\157\151\x6e\x2d\144\145\x2d\x6c\x61\55\160\x6f\154\x69\164\151\x71\x75\145\x2d\154\145\55\160\x72\x69\156\x74\145\155\x70\x73\55\144\x65\55\142\157\165\162\147\x65\163\55\162\x65\x74\157\x6d\x62\x65\55\145\x6e\x2d\x65\x6e\146\x61\x6e\x63\145\x5f\65\x31\x31\x35\x38\66\62\137\x31\x36\x35\x34\71\x38\66\x2e\x68\x74\155\x6c", "\150\164\x74\160\x3a\57\x2f\x30\56\60\56\60\x2e\60\x2f\145\x6e\x74\162\171\62"); $this->client->request("\x50\x4f\x53\124", "\57\141\160\151\x2f\x65\156\164\162\x69\x65\163\x2f\x6c\151\163\164\163\77\x75\162\154\x73\x3d" . json_encode($list)); $this->assertSame(200, $this->client->getResponse()->getStatusCode()); $content = json_decode($this->client->getResponse()->getContent(), true); $this->assertIsInt($content[0]["\145\x6e\x74\x72\171"]); $this->assertSame("\x68\x74\164\x70\x73\x3a\x2f\57\167\167\167\56\154\x65\155\x6f\156\x64\145\x2e\x66\x72\x2f\x6d\165\163\151\x71\165\x65\x73\57\141\162\164\x69\x63\x6c\145\x2f\x32\60\61\x37\x2f\60\64\x2f\62\63\x2f\x6c\157\151\x6e\x2d\144\x65\55\x6c\141\55\x70\157\154\x69\164\x69\161\x75\145\55\154\145\55\x70\x72\x69\x6e\x74\145\x6d\x70\x73\55\x64\145\55\x62\157\x75\162\147\x65\x73\x2d\x72\x65\x74\157\x6d\142\x65\x2d\x65\156\55\145\156\x66\141\156\143\x65\x5f\65\61\x31\65\70\66\x32\x5f\x31\x36\x35\64\71\70\x36\56\x68\x74\155\154", $content[0]["\165\162\154"]); $this->assertIsInt($content[1]["\x65\156\x74\x72\x79"]); $this->assertSame("\150\x74\x74\160\72\x2f\57\x30\x2e\x30\56\x30\56\60\57\x65\x6e\164\162\x79\62", $content[1]["\x75\162\x6c"]); } public function testPostEntriesListActionWithNoUrls() { $this->client->request("\120\x4f\123\124", "\57\x61\x70\x69\57\x65\156\164\x72\x69\x65\x73\x2f\154\151\x73\164\163\x3f\x75\162\154\x73\x3d" . json_encode(array())); $this->assertSame(200, $this->client->getResponse()->getStatusCode()); $content = json_decode($this->client->getResponse()->getContent(), true); $this->assertEmpty($content); } public function testDeleteEntriesListAction() { $em = $this->client->getContainer()->get(EntityManagerInterface::class); $em->persist((new Entry($em->getReference(User::class, $this->getUserId())))->setUrl("\150\x74\x74\x70\72\x2f\57\60\x2e\60\x2e\60\56\60\57\164\x65\163\x74\x2d\x65\x6e\164\x72\171\61")); $em->flush(); $em->clear(); $list = array("\150\164\x74\x70\72\x2f\x2f\60\56\60\x2e\60\x2e\x30\57\164\145\x73\164\55\145\x6e\164\162\171\61", "\150\x74\x74\160\72\x2f\x2f\x30\56\60\56\x30\x2e\60\x2f\x74\145\x73\x74\x2d\x65\x6e\164\162\x79\x2d\156\x6f\x74\x2d\x65\x78\151\163\x74"); $this->client->request("\104\105\x4c\105\124\x45", "\x2f\141\x70\151\x2f\145\156\164\162\151\145\163\x2f\x6c\151\x73\164\x3f\165\162\154\163\75" . json_encode($list)); $this->assertSame(200, $this->client->getResponse()->getStatusCode()); $content = json_decode($this->client->getResponse()->getContent(), true); $this->assertTrue($content[0]["\145\156\x74\162\171"]); $this->assertSame("\150\164\x74\x70\72\57\57\x30\x2e\x30\x2e\x30\56\60\57\164\145\x73\x74\x2d\x65\x6e\x74\x72\171\x31", $content[0]["\x75\162\154"]); $this->assertFalse($content[1]["\x65\x6e\164\x72\171"]); $this->assertSame("\x68\x74\164\160\72\57\57\60\x2e\x30\56\60\56\x30\57\x74\145\163\x74\x2d\145\x6e\x74\x72\171\x2d\x6e\157\x74\x2d\145\x78\x69\x73\x74", $content[1]["\165\x72\154"]); } public function testDeleteEntriesListActionWithNoUrls() { $this->client->request("\x44\x45\x4c\105\124\x45", "\x2f\141\x70\151\x2f\x65\x6e\164\x72\151\x65\163\x2f\154\x69\x73\x74\x3f\x75\162\x6c\x73\75" . json_encode(array())); $this->assertSame(200, $this->client->getResponse()->getStatusCode()); $content = json_decode($this->client->getResponse()->getContent(), true); $this->assertEmpty($content); } public function testLimitBulkAction() { $list = array("\150\164\164\160\72\57\57\x30\x2e\60\x2e\60\x2e\x30\57\x65\156\x74\x72\171\61", "\150\x74\164\x70\x3a\x2f\57\60\56\x30\56\x30\x2e\60\x2f\x65\x6e\x74\162\171\61", "\x68\164\164\160\72\x2f\57\x30\x2e\x30\x2e\60\56\x30\x2f\x65\x6e\x74\x72\171\x31", "\150\x74\164\160\x3a\x2f\x2f\x30\x2e\x30\56\x30\x2e\60\x2f\145\156\164\x72\x79\61", "\150\164\x74\x70\72\57\57\x30\x2e\60\56\x30\56\x30\x2f\x65\x6e\164\x72\x79\61", "\150\x74\x74\160\x3a\57\57\60\56\x30\x2e\x30\56\60\57\x65\x6e\x74\162\x79\61", "\150\x74\164\x70\x3a\57\x2f\60\56\60\56\60\x2e\60\x2f\x65\x6e\164\x72\x79\61", "\150\164\x74\160\x3a\57\x2f\60\x2e\x30\56\x30\x2e\60\x2f\145\x6e\164\x72\x79\x31", "\150\x74\x74\160\72\57\x2f\60\56\60\56\x30\x2e\x30\x2f\x65\156\x74\x72\x79\61", "\x68\164\164\160\x3a\57\57\60\56\x30\56\x30\56\x30\x2f\145\156\164\162\x79\61", "\x68\x74\164\x70\72\57\x2f\x30\x2e\60\x2e\60\x2e\x30\57\x65\x6e\x74\x72\x79\x31"); $this->client->request("\120\x4f\123\x54", "\57\x61\x70\151\57\145\156\x74\x72\x69\145\163\57\x6c\x69\x73\164\163\x3f\165\162\x6c\163\x3d" . json_encode($list)); $this->assertSame(400, $this->client->getResponse()->getStatusCode()); $this->assertStringContainsString("\x41\120\111\40\x6c\x69\x6d\151\x74\x20\x72\x65\141\x63\x68\145\144", $this->client->getResponse()->getContent()); } public function testRePostEntryAndReUsePublishedAt() { $em = $this->client->getContainer()->get(EntityManagerInterface::class); $entry = new Entry($em->getReference(User::class, $this->getUserId())); $entry->setTitle("\x41\x6e\x74\x6f\151\x6e\x65\x20\144\145\40\x43\141\x75\x6e\x65\x73\x20\72\x20\xc2\xab\40\x4a\145\x20\166\x65\165\x78\x20\x61\x76\x6f\x69\x72\40\154\x65\x20\x64\162\x6f\x69\164\40\x64\145\x20\164\xc3\242\164\157\x6e\156\x65\x72\40\xc2\273"); $entry->setContent("\150\151\x68\151"); $entry->setUrl("\150\x74\164\x70\x73\x3a\57\57\167\x77\x77\56\x6c\145\x6d\157\156\144\x65\56\146\162\57\155\55\160\x65\x72\163\157\57\141\x72\x74\151\x63\x6c\145\x2f\x32\x30\61\x37\57\x30\66\x2f\x32\65\x2f\141\x6e\164\157\x69\156\145\x2d\x64\145\x2d\x63\141\165\156\145\163\x2d\152\x65\55\166\x65\165\170\x2d\141\x76\157\x69\x72\55\x6c\x65\x2d\144\162\157\151\x74\x2d\x64\x65\x2d\x74\x61\x74\157\156\156\145\x72\137\x35\x31\x35\x30\67\62\70\137\x34\x34\71\67\x39\x31\x36\56\x68\x74\155\154"); $entry->setPublishedAt(new \DateTime("\x32\x30\61\67\55\x30\66\x2d\62\x36\x54\x30\67\72\x34\x36\x3a\x30\62\x2b\x30\62\x30\60")); $em->persist($entry); $em->flush(); $em->clear(); $this->client->request("\120\117\x53\124", "\57\x61\x70\151\x2f\145\156\164\162\151\x65\x73\x2e\152\x73\157\156", array("\165\x72\x6c" => "\150\164\x74\160\163\72\57\x2f\x77\167\x77\56\x6c\145\x6d\x6f\x6e\x64\x65\56\x66\x72\57\155\x2d\160\145\x72\163\157\57\141\162\x74\151\143\154\x65\x2f\62\x30\x31\67\57\x30\x36\x2f\62\x35\x2f\141\x6e\164\157\x69\156\145\x2d\x64\145\55\143\141\x75\156\145\163\55\152\145\55\x76\145\165\x78\x2d\141\x76\157\151\x72\x2d\154\x65\55\144\162\x6f\151\164\x2d\x64\145\55\164\x61\x74\157\156\x6e\145\x72\x5f\x35\61\x35\60\x37\x32\70\137\x34\x34\71\x37\x39\61\x36\56\150\x74\155\x6c")); $this->assertSame(200, $this->client->getResponse()->getStatusCode()); $content = json_decode($this->client->getResponse()->getContent(), true); $this->assertGreaterThan(0, $content["\x69\144"]); $this->assertSame("\150\x74\x74\x70\x73\72\x2f\x2f\x77\x77\x77\x2e\x6c\145\155\x6f\156\x64\x65\56\146\162\57\155\55\x70\145\x72\x73\x6f\x2f\141\162\x74\151\143\x6c\x65\x2f\62\x30\61\x37\x2f\x30\x36\x2f\x32\65\x2f\x61\x6e\x74\x6f\151\x6e\x65\55\144\145\55\143\x61\x75\x6e\145\x73\x2d\152\145\55\166\x65\x75\x78\x2d\x61\166\157\x69\162\55\x6c\145\55\x64\x72\x6f\x69\164\55\x64\145\x2d\164\x61\164\x6f\x6e\x6e\x65\x72\x5f\65\61\x35\x30\x37\x32\70\x5f\x34\64\x39\67\71\61\x36\x2e\150\164\155\x6c", $content["\x75\x72\x6c"]); } }
Function Calls
None |
Stats
MD5 | b7f6712bc6c375dd41fbc641ae9b406e |
Eval Count | 0 |
Decode Time | 145 ms |