aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/Wallabag/ImportBundle/Tests/Controller/WallabagV2ControllerTest.php
diff options
context:
space:
mode:
Diffstat (limited to 'src/Wallabag/ImportBundle/Tests/Controller/WallabagV2ControllerTest.php')
-rw-r--r--src/Wallabag/ImportBundle/Tests/Controller/WallabagV2ControllerTest.php69
1 files changed, 69 insertions, 0 deletions
diff --git a/src/Wallabag/ImportBundle/Tests/Controller/WallabagV2ControllerTest.php b/src/Wallabag/ImportBundle/Tests/Controller/WallabagV2ControllerTest.php
new file mode 100644
index 00000000..a77c0f6b
--- /dev/null
+++ b/src/Wallabag/ImportBundle/Tests/Controller/WallabagV2ControllerTest.php
@@ -0,0 +1,69 @@
1<?php
2
3namespace Wallabag\ImportBundle\Tests\Controller;
4
5use Wallabag\CoreBundle\Tests\WallabagCoreTestCase;
6use Symfony\Component\HttpFoundation\File\UploadedFile;
7
8class WallabagV2ControllerTest extends WallabagCoreTestCase
9{
10 public function testImportWallabag()
11 {
12 $this->logInAs('admin');
13 $client = $this->getClient();
14
15 $crawler = $client->request('GET', '/import/wallabag-v2');
16
17 $this->assertEquals(200, $client->getResponse()->getStatusCode());
18 $this->assertEquals(1, $crawler->filter('form[name=upload_import_file] > button[type=submit]')->count());
19 $this->assertEquals(1, $crawler->filter('input[type=file]')->count());
20 }
21
22 public function testImportWallabagWithFile()
23 {
24 $this->logInAs('admin');
25 $client = $this->getClient();
26
27 $crawler = $client->request('GET', '/import/wallabag-v2');
28 $form = $crawler->filter('form[name=upload_import_file] > button[type=submit]')->form();
29
30 $file = new UploadedFile(__DIR__.'/../fixtures/wallabag-v2.json', 'wallabag-v2.json');
31
32 $data = array(
33 'upload_import_file[file]' => $file,
34 );
35
36 $client->submit($form, $data);
37
38 $this->assertEquals(302, $client->getResponse()->getStatusCode());
39
40 $crawler = $client->followRedirect();
41
42 $this->assertGreaterThan(1, $alert = $crawler->filter('div.messages.success')->extract(array('_text')));
43 $this->assertContains('Import summary', $alert[0]);
44 }
45
46 public function testImportWallabagWithEmptyFile()
47 {
48 $this->logInAs('admin');
49 $client = $this->getClient();
50
51 $crawler = $client->request('GET', '/import/wallabag-v2');
52 $form = $crawler->filter('form[name=upload_import_file] > button[type=submit]')->form();
53
54 $file = new UploadedFile(__DIR__.'/../fixtures/test.txt', 'test.txt');
55
56 $data = array(
57 'upload_import_file[file]' => $file,
58 );
59
60 $client->submit($form, $data);
61
62 $this->assertEquals(302, $client->getResponse()->getStatusCode());
63
64 $crawler = $client->followRedirect();
65
66 $this->assertGreaterThan(1, $alert = $crawler->filter('div.messages.success')->extract(array('_text')));
67 $this->assertContains('Import failed, please try again', $alert[0]);
68 }
69}