aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests/Wallabag/CoreBundle/Controller/EntryControllerTest.php
diff options
context:
space:
mode:
Diffstat (limited to 'tests/Wallabag/CoreBundle/Controller/EntryControllerTest.php')
-rw-r--r--tests/Wallabag/CoreBundle/Controller/EntryControllerTest.php53
1 files changed, 53 insertions, 0 deletions
diff --git a/tests/Wallabag/CoreBundle/Controller/EntryControllerTest.php b/tests/Wallabag/CoreBundle/Controller/EntryControllerTest.php
index 8f5c372d..104f60f1 100644
--- a/tests/Wallabag/CoreBundle/Controller/EntryControllerTest.php
+++ b/tests/Wallabag/CoreBundle/Controller/EntryControllerTest.php
@@ -5,6 +5,7 @@ namespace Tests\Wallabag\CoreBundle\Controller;
5use Tests\Wallabag\CoreBundle\WallabagCoreTestCase; 5use Tests\Wallabag\CoreBundle\WallabagCoreTestCase;
6use Wallabag\CoreBundle\Entity\Config; 6use Wallabag\CoreBundle\Entity\Config;
7use Wallabag\CoreBundle\Entity\Entry; 7use Wallabag\CoreBundle\Entity\Entry;
8use Wallabag\CoreBundle\Entity\SiteCredential;
8 9
9class EntryControllerTest extends WallabagCoreTestCase 10class EntryControllerTest extends WallabagCoreTestCase
10{ 11{
@@ -1321,4 +1322,56 @@ class EntryControllerTest extends WallabagCoreTestCase
1321 $this->assertEquals($url, $content->getUrl()); 1322 $this->assertEquals($url, $content->getUrl());
1322 $this->assertEquals($expectedLanguage, $content->getLanguage()); 1323 $this->assertEquals($expectedLanguage, $content->getLanguage());
1323 } 1324 }
1325
1326 /**
1327 * This test will require an internet connection.
1328 */
1329 public function testRestrictedArticle()
1330 {
1331 $url = 'http://www.monde-diplomatique.fr/2017/05/BONNET/57475';
1332 $this->logInAs('admin');
1333 $client = $this->getClient();
1334 $em = $client->getContainer()->get('doctrine.orm.entity_manager');
1335
1336 // enable restricted access
1337 $client->getContainer()->get('craue_config')->set('restricted_access', 1);
1338
1339 // create a new site_credential
1340 $user = $client->getContainer()->get('security.token_storage')->getToken()->getUser();
1341 $credential = new SiteCredential($user);
1342 $credential->setHost('monde-diplomatique.fr');
1343 $credential->setUsername('foo');
1344 $credential->setPassword('bar');
1345
1346 $em->persist($credential);
1347 $em->flush();
1348
1349 $crawler = $client->request('GET', '/new');
1350
1351 $this->assertEquals(200, $client->getResponse()->getStatusCode());
1352
1353 $form = $crawler->filter('form[name=entry]')->form();
1354
1355 $data = [
1356 'entry[url]' => $url,
1357 ];
1358
1359 $client->submit($form, $data);
1360
1361 $this->assertEquals(302, $client->getResponse()->getStatusCode());
1362
1363 $crawler = $client->followRedirect();
1364
1365 $this->assertEquals(200, $client->getResponse()->getStatusCode());
1366 $this->assertContains('flashes.entry.notice.entry_saved', $crawler->filter('body')->extract(['_text'])[0]);
1367
1368 $content = $em
1369 ->getRepository('WallabagCoreBundle:Entry')
1370 ->findByUrlAndUserId($url, $this->getLoggedInUserId());
1371
1372 $this->assertInstanceOf('Wallabag\CoreBundle\Entity\Entry', $content);
1373 $this->assertSame('Crimes et réformes aux Philippines', $content->getTitle());
1374
1375 $client->getContainer()->get('craue_config')->set('restricted_access', 0);
1376 }
1324} 1377}