]> git.immae.eu Git - github/wallabag/wallabag.git/blobdiff - tests/Wallabag/ImportBundle/Controller/WallabagV2ControllerTest.php
Add more tests
[github/wallabag/wallabag.git] / tests / Wallabag / ImportBundle / Controller / WallabagV2ControllerTest.php
index d8d2c8bf60267d34fd9119492e5ec668a85c4b0f..b20226ad183469e398da44cc96e1435acbe12723 100644 (file)
@@ -19,6 +19,55 @@ class WallabagV2ControllerTest extends WallabagCoreTestCase
         $this->assertEquals(1, $crawler->filter('input[type=file]')->count());
     }
 
+    public function testImportWallabagWithRabbitEnabled()
+    {
+        $this->logInAs('admin');
+        $client = $this->getClient();
+
+        $client->getContainer()->get('craue_config')->set('import_with_rabbitmq', 1);
+
+        $crawler = $client->request('GET', '/import/wallabag-v2');
+
+        $this->assertEquals(200, $client->getResponse()->getStatusCode());
+        $this->assertEquals(1, $crawler->filter('form[name=upload_import_file] > button[type=submit]')->count());
+        $this->assertEquals(1, $crawler->filter('input[type=file]')->count());
+
+        $client->getContainer()->get('craue_config')->set('import_with_rabbitmq', 0);
+    }
+
+    public function testImportWallabagWithRedisEnabled()
+    {
+        $this->logInAs('admin');
+        $client = $this->getClient();
+
+        $client->getContainer()->get('craue_config')->set('import_with_redis', 1);
+
+        $crawler = $client->request('GET', '/import/wallabag-v2');
+
+        $this->assertEquals(200, $client->getResponse()->getStatusCode());
+        $this->assertEquals(1, $crawler->filter('form[name=upload_import_file] > button[type=submit]')->count());
+        $this->assertEquals(1, $crawler->filter('input[type=file]')->count());
+
+        $client->getContainer()->get('craue_config')->set('import_with_redis', 0);
+    }
+
+    public function testImportWallabagBadFile()
+    {
+        $this->logInAs('admin');
+        $client = $this->getClient();
+
+        $crawler = $client->request('GET', '/import/wallabag-v2');
+        $form = $crawler->filter('form[name=upload_import_file] > button[type=submit]')->form();
+
+        $data = [
+            'upload_import_file[file]' => '',
+        ];
+
+        $client->submit($form, $data);
+
+        $this->assertEquals(200, $client->getResponse()->getStatusCode());
+    }
+
     public function testImportWallabagWithFile()
     {
         $this->logInAs('admin');
@@ -67,6 +116,8 @@ class WallabagV2ControllerTest extends WallabagCoreTestCase
         $this->assertNotEmpty($content->getPreviewPicture());
         $this->assertNotEmpty($content->getLanguage());
         $this->assertEquals(2, count($content->getTags()));
+        $this->assertInstanceOf(\DateTime::class, $content->getCreatedAt());
+        $this->assertEquals('2016-09-08', $content->getCreatedAt()->format('Y-m-d'));
     }
 
     public function testImportWallabagWithEmptyFile()