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