aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests/Wallabag
diff options
context:
space:
mode:
authorJeremy Benoist <jeremy.benoist@gmail.com>2016-09-13 22:27:27 +0200
committerJeremy Benoist <jeremy.benoist@gmail.com>2016-09-13 22:27:27 +0200
commit47d7c682a453a4831c07db926d22461f310642c6 (patch)
treeb130045d2198e4e7b14fb814860ef864ede30006 /tests/Wallabag
parentc80cc01afa315dcfa38b2a01c5b05d4516659c24 (diff)
downloadwallabag-47d7c682a453a4831c07db926d22461f310642c6.tar.gz
wallabag-47d7c682a453a4831c07db926d22461f310642c6.tar.zst
wallabag-47d7c682a453a4831c07db926d22461f310642c6.zip
Add more “real” tests
Diffstat (limited to 'tests/Wallabag')
-rw-r--r--tests/Wallabag/ImportBundle/Controller/ReadabilityControllerTest.php39
-rw-r--r--tests/Wallabag/ImportBundle/Controller/WallabagV1ControllerTest.php39
-rw-r--r--tests/Wallabag/ImportBundle/Controller/WallabagV2ControllerTest.php39
3 files changed, 87 insertions, 30 deletions
diff --git a/tests/Wallabag/ImportBundle/Controller/ReadabilityControllerTest.php b/tests/Wallabag/ImportBundle/Controller/ReadabilityControllerTest.php
index fb835f62..7b88d891 100644
--- a/tests/Wallabag/ImportBundle/Controller/ReadabilityControllerTest.php
+++ b/tests/Wallabag/ImportBundle/Controller/ReadabilityControllerTest.php
@@ -35,37 +35,56 @@ class ReadabilityControllerTest extends WallabagCoreTestCase
35 $client->getContainer()->get('craue_config')->set('import_with_rabbitmq', 0); 35 $client->getContainer()->get('craue_config')->set('import_with_rabbitmq', 0);
36 } 36 }
37 37
38 public function testImportReadabilityWithRedisEnabled() 38 public function testImportReadabilityBadFile()
39 { 39 {
40 $this->logInAs('admin'); 40 $this->logInAs('admin');
41 $client = $this->getClient(); 41 $client = $this->getClient();
42 42
43 $client->getContainer()->get('craue_config')->set('import_with_redis', 1);
44
45 $crawler = $client->request('GET', '/import/readability'); 43 $crawler = $client->request('GET', '/import/readability');
44 $form = $crawler->filter('form[name=upload_import_file] > button[type=submit]')->form();
46 45
47 $this->assertEquals(200, $client->getResponse()->getStatusCode()); 46 $data = [
48 $this->assertEquals(1, $crawler->filter('form[name=upload_import_file] > button[type=submit]')->count()); 47 'upload_import_file[file]' => '',
49 $this->assertEquals(1, $crawler->filter('input[type=file]')->count()); 48 ];
50 49
51 $client->getContainer()->get('craue_config')->set('import_with_redis', 0); 50 $client->submit($form, $data);
51
52 $this->assertEquals(200, $client->getResponse()->getStatusCode());
52 } 53 }
53 54
54 public function testImportReadabilityBadFile() 55 public function testImportReadabilityWithRedisEnabled()
55 { 56 {
56 $this->logInAs('admin'); 57 $this->logInAs('admin');
57 $client = $this->getClient(); 58 $client = $this->getClient();
58 59
60 $client->getContainer()->get('craue_config')->set('import_with_redis', 1);
61
59 $crawler = $client->request('GET', '/import/readability'); 62 $crawler = $client->request('GET', '/import/readability');
63
64 $this->assertEquals(200, $client->getResponse()->getStatusCode());
65 $this->assertEquals(1, $crawler->filter('form[name=upload_import_file] > button[type=submit]')->count());
66 $this->assertEquals(1, $crawler->filter('input[type=file]')->count());
67
60 $form = $crawler->filter('form[name=upload_import_file] > button[type=submit]')->form(); 68 $form = $crawler->filter('form[name=upload_import_file] > button[type=submit]')->form();
61 69
70 $file = new UploadedFile(__DIR__.'/../fixtures/readability.json', 'readability.json');
71
62 $data = [ 72 $data = [
63 'upload_import_file[file]' => '', 73 'upload_import_file[file]' => $file,
64 ]; 74 ];
65 75
66 $client->submit($form, $data); 76 $client->submit($form, $data);
67 77
68 $this->assertEquals(200, $client->getResponse()->getStatusCode()); 78 $this->assertEquals(302, $client->getResponse()->getStatusCode());
79
80 $crawler = $client->followRedirect();
81
82 $this->assertGreaterThan(1, $body = $crawler->filter('body')->extract(['_text']));
83 $this->assertContains('flashes.import.notice.summary', $body[0]);
84
85 $this->assertNotEmpty($client->getContainer()->get('wallabag_core.redis.client')->lpop('wallabag.import.readability'));
86
87 $client->getContainer()->get('craue_config')->set('import_with_redis', 0);
69 } 88 }
70 89
71 public function testImportReadabilityWithFile() 90 public function testImportReadabilityWithFile()
diff --git a/tests/Wallabag/ImportBundle/Controller/WallabagV1ControllerTest.php b/tests/Wallabag/ImportBundle/Controller/WallabagV1ControllerTest.php
index f1113365..98e85d45 100644
--- a/tests/Wallabag/ImportBundle/Controller/WallabagV1ControllerTest.php
+++ b/tests/Wallabag/ImportBundle/Controller/WallabagV1ControllerTest.php
@@ -35,37 +35,56 @@ class WallabagV1ControllerTest extends WallabagCoreTestCase
35 $client->getContainer()->get('craue_config')->set('import_with_rabbitmq', 0); 35 $client->getContainer()->get('craue_config')->set('import_with_rabbitmq', 0);
36 } 36 }
37 37
38 public function testImportWallabagWithRedisEnabled() 38 public function testImportWallabagBadFile()
39 { 39 {
40 $this->logInAs('admin'); 40 $this->logInAs('admin');
41 $client = $this->getClient(); 41 $client = $this->getClient();
42 42
43 $client->getContainer()->get('craue_config')->set('import_with_redis', 1);
44
45 $crawler = $client->request('GET', '/import/wallabag-v1'); 43 $crawler = $client->request('GET', '/import/wallabag-v1');
44 $form = $crawler->filter('form[name=upload_import_file] > button[type=submit]')->form();
46 45
47 $this->assertEquals(200, $client->getResponse()->getStatusCode()); 46 $data = [
48 $this->assertEquals(1, $crawler->filter('form[name=upload_import_file] > button[type=submit]')->count()); 47 'upload_import_file[file]' => '',
49 $this->assertEquals(1, $crawler->filter('input[type=file]')->count()); 48 ];
50 49
51 $client->getContainer()->get('craue_config')->set('import_with_redis', 0); 50 $client->submit($form, $data);
51
52 $this->assertEquals(200, $client->getResponse()->getStatusCode());
52 } 53 }
53 54
54 public function testImportWallabagBadFile() 55 public function testImportWallabagWithRedisEnabled()
55 { 56 {
56 $this->logInAs('admin'); 57 $this->logInAs('admin');
57 $client = $this->getClient(); 58 $client = $this->getClient();
58 59
60 $client->getContainer()->get('craue_config')->set('import_with_redis', 1);
61
59 $crawler = $client->request('GET', '/import/wallabag-v1'); 62 $crawler = $client->request('GET', '/import/wallabag-v1');
63
64 $this->assertEquals(200, $client->getResponse()->getStatusCode());
65 $this->assertEquals(1, $crawler->filter('form[name=upload_import_file] > button[type=submit]')->count());
66 $this->assertEquals(1, $crawler->filter('input[type=file]')->count());
67
60 $form = $crawler->filter('form[name=upload_import_file] > button[type=submit]')->form(); 68 $form = $crawler->filter('form[name=upload_import_file] > button[type=submit]')->form();
61 69
70 $file = new UploadedFile(__DIR__.'/../fixtures/wallabag-v1.json', 'wallabag-v1.json');
71
62 $data = [ 72 $data = [
63 'upload_import_file[file]' => '', 73 'upload_import_file[file]' => $file,
64 ]; 74 ];
65 75
66 $client->submit($form, $data); 76 $client->submit($form, $data);
67 77
68 $this->assertEquals(200, $client->getResponse()->getStatusCode()); 78 $this->assertEquals(302, $client->getResponse()->getStatusCode());
79
80 $crawler = $client->followRedirect();
81
82 $this->assertGreaterThan(1, $body = $crawler->filter('body')->extract(['_text']));
83 $this->assertContains('flashes.import.notice.summary', $body[0]);
84
85 $this->assertNotEmpty($client->getContainer()->get('wallabag_core.redis.client')->lpop('wallabag.import.wallabag_v1'));
86
87 $client->getContainer()->get('craue_config')->set('import_with_redis', 0);
69 } 88 }
70 89
71 public function testImportWallabagWithFile() 90 public function testImportWallabagWithFile()
diff --git a/tests/Wallabag/ImportBundle/Controller/WallabagV2ControllerTest.php b/tests/Wallabag/ImportBundle/Controller/WallabagV2ControllerTest.php
index ca20c85b..74d61f9a 100644
--- a/tests/Wallabag/ImportBundle/Controller/WallabagV2ControllerTest.php
+++ b/tests/Wallabag/ImportBundle/Controller/WallabagV2ControllerTest.php
@@ -35,37 +35,56 @@ class WallabagV2ControllerTest extends WallabagCoreTestCase
35 $client->getContainer()->get('craue_config')->set('import_with_rabbitmq', 0); 35 $client->getContainer()->get('craue_config')->set('import_with_rabbitmq', 0);
36 } 36 }
37 37
38 public function testImportWallabagWithRedisEnabled() 38 public function testImportWallabagBadFile()
39 { 39 {
40 $this->logInAs('admin'); 40 $this->logInAs('admin');
41 $client = $this->getClient(); 41 $client = $this->getClient();
42 42
43 $client->getContainer()->get('craue_config')->set('import_with_redis', 1);
44
45 $crawler = $client->request('GET', '/import/wallabag-v2'); 43 $crawler = $client->request('GET', '/import/wallabag-v2');
44 $form = $crawler->filter('form[name=upload_import_file] > button[type=submit]')->form();
46 45
47 $this->assertEquals(200, $client->getResponse()->getStatusCode()); 46 $data = [
48 $this->assertEquals(1, $crawler->filter('form[name=upload_import_file] > button[type=submit]')->count()); 47 'upload_import_file[file]' => '',
49 $this->assertEquals(1, $crawler->filter('input[type=file]')->count()); 48 ];
50 49
51 $client->getContainer()->get('craue_config')->set('import_with_redis', 0); 50 $client->submit($form, $data);
51
52 $this->assertEquals(200, $client->getResponse()->getStatusCode());
52 } 53 }
53 54
54 public function testImportWallabagBadFile() 55 public function testImportWallabagWithRedisEnabled()
55 { 56 {
56 $this->logInAs('admin'); 57 $this->logInAs('admin');
57 $client = $this->getClient(); 58 $client = $this->getClient();
58 59
60 $client->getContainer()->get('craue_config')->set('import_with_redis', 1);
61
59 $crawler = $client->request('GET', '/import/wallabag-v2'); 62 $crawler = $client->request('GET', '/import/wallabag-v2');
63
64 $this->assertEquals(200, $client->getResponse()->getStatusCode());
65 $this->assertEquals(1, $crawler->filter('form[name=upload_import_file] > button[type=submit]')->count());
66 $this->assertEquals(1, $crawler->filter('input[type=file]')->count());
67
60 $form = $crawler->filter('form[name=upload_import_file] > button[type=submit]')->form(); 68 $form = $crawler->filter('form[name=upload_import_file] > button[type=submit]')->form();
61 69
70 $file = new UploadedFile(__DIR__.'/../fixtures/wallabag-v2.json', 'wallabag-v2.json');
71
62 $data = [ 72 $data = [
63 'upload_import_file[file]' => '', 73 'upload_import_file[file]' => $file,
64 ]; 74 ];
65 75
66 $client->submit($form, $data); 76 $client->submit($form, $data);
67 77
68 $this->assertEquals(200, $client->getResponse()->getStatusCode()); 78 $this->assertEquals(302, $client->getResponse()->getStatusCode());
79
80 $crawler = $client->followRedirect();
81
82 $this->assertGreaterThan(1, $body = $crawler->filter('body')->extract(['_text']));
83 $this->assertContains('flashes.import.notice.summary', $body[0]);
84
85 $this->assertNotEmpty($client->getContainer()->get('wallabag_core.redis.client')->lpop('wallabag.import.wallabag_v2'));
86
87 $client->getContainer()->get('craue_config')->set('import_with_redis', 0);
69 } 88 }
70 89
71 public function testImportWallabagWithFile() 90 public function testImportWallabagWithFile()