mirror of
https://github.com/wallabag/wallabag.git
synced 2025-01-09 16:35:27 +00:00
Add more “real” tests
This commit is contained in:
parent
c80cc01afa
commit
47d7c682a4
3 changed files with 105 additions and 48 deletions
|
@ -35,22 +35,6 @@ class ReadabilityControllerTest extends WallabagCoreTestCase
|
||||||
$client->getContainer()->get('craue_config')->set('import_with_rabbitmq', 0);
|
$client->getContainer()->get('craue_config')->set('import_with_rabbitmq', 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testImportReadabilityWithRedisEnabled()
|
|
||||||
{
|
|
||||||
$this->logInAs('admin');
|
|
||||||
$client = $this->getClient();
|
|
||||||
|
|
||||||
$client->getContainer()->get('craue_config')->set('import_with_redis', 1);
|
|
||||||
|
|
||||||
$crawler = $client->request('GET', '/import/readability');
|
|
||||||
|
|
||||||
$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 testImportReadabilityBadFile()
|
public function testImportReadabilityBadFile()
|
||||||
{
|
{
|
||||||
$this->logInAs('admin');
|
$this->logInAs('admin');
|
||||||
|
@ -68,6 +52,41 @@ class ReadabilityControllerTest extends WallabagCoreTestCase
|
||||||
$this->assertEquals(200, $client->getResponse()->getStatusCode());
|
$this->assertEquals(200, $client->getResponse()->getStatusCode());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testImportReadabilityWithRedisEnabled()
|
||||||
|
{
|
||||||
|
$this->logInAs('admin');
|
||||||
|
$client = $this->getClient();
|
||||||
|
|
||||||
|
$client->getContainer()->get('craue_config')->set('import_with_redis', 1);
|
||||||
|
|
||||||
|
$crawler = $client->request('GET', '/import/readability');
|
||||||
|
|
||||||
|
$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());
|
||||||
|
|
||||||
|
$form = $crawler->filter('form[name=upload_import_file] > button[type=submit]')->form();
|
||||||
|
|
||||||
|
$file = new UploadedFile(__DIR__.'/../fixtures/readability.json', 'readability.json');
|
||||||
|
|
||||||
|
$data = [
|
||||||
|
'upload_import_file[file]' => $file,
|
||||||
|
];
|
||||||
|
|
||||||
|
$client->submit($form, $data);
|
||||||
|
|
||||||
|
$this->assertEquals(302, $client->getResponse()->getStatusCode());
|
||||||
|
|
||||||
|
$crawler = $client->followRedirect();
|
||||||
|
|
||||||
|
$this->assertGreaterThan(1, $body = $crawler->filter('body')->extract(['_text']));
|
||||||
|
$this->assertContains('flashes.import.notice.summary', $body[0]);
|
||||||
|
|
||||||
|
$this->assertNotEmpty($client->getContainer()->get('wallabag_core.redis.client')->lpop('wallabag.import.readability'));
|
||||||
|
|
||||||
|
$client->getContainer()->get('craue_config')->set('import_with_redis', 0);
|
||||||
|
}
|
||||||
|
|
||||||
public function testImportReadabilityWithFile()
|
public function testImportReadabilityWithFile()
|
||||||
{
|
{
|
||||||
$this->logInAs('admin');
|
$this->logInAs('admin');
|
||||||
|
|
|
@ -35,22 +35,6 @@ class WallabagV1ControllerTest extends WallabagCoreTestCase
|
||||||
$client->getContainer()->get('craue_config')->set('import_with_rabbitmq', 0);
|
$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-v1');
|
|
||||||
|
|
||||||
$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()
|
public function testImportWallabagBadFile()
|
||||||
{
|
{
|
||||||
$this->logInAs('admin');
|
$this->logInAs('admin');
|
||||||
|
@ -68,6 +52,41 @@ class WallabagV1ControllerTest extends WallabagCoreTestCase
|
||||||
$this->assertEquals(200, $client->getResponse()->getStatusCode());
|
$this->assertEquals(200, $client->getResponse()->getStatusCode());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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-v1');
|
||||||
|
|
||||||
|
$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());
|
||||||
|
|
||||||
|
$form = $crawler->filter('form[name=upload_import_file] > button[type=submit]')->form();
|
||||||
|
|
||||||
|
$file = new UploadedFile(__DIR__.'/../fixtures/wallabag-v1.json', 'wallabag-v1.json');
|
||||||
|
|
||||||
|
$data = [
|
||||||
|
'upload_import_file[file]' => $file,
|
||||||
|
];
|
||||||
|
|
||||||
|
$client->submit($form, $data);
|
||||||
|
|
||||||
|
$this->assertEquals(302, $client->getResponse()->getStatusCode());
|
||||||
|
|
||||||
|
$crawler = $client->followRedirect();
|
||||||
|
|
||||||
|
$this->assertGreaterThan(1, $body = $crawler->filter('body')->extract(['_text']));
|
||||||
|
$this->assertContains('flashes.import.notice.summary', $body[0]);
|
||||||
|
|
||||||
|
$this->assertNotEmpty($client->getContainer()->get('wallabag_core.redis.client')->lpop('wallabag.import.wallabag_v1'));
|
||||||
|
|
||||||
|
$client->getContainer()->get('craue_config')->set('import_with_redis', 0);
|
||||||
|
}
|
||||||
|
|
||||||
public function testImportWallabagWithFile()
|
public function testImportWallabagWithFile()
|
||||||
{
|
{
|
||||||
$this->logInAs('admin');
|
$this->logInAs('admin');
|
||||||
|
|
|
@ -35,22 +35,6 @@ class WallabagV2ControllerTest extends WallabagCoreTestCase
|
||||||
$client->getContainer()->get('craue_config')->set('import_with_rabbitmq', 0);
|
$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()
|
public function testImportWallabagBadFile()
|
||||||
{
|
{
|
||||||
$this->logInAs('admin');
|
$this->logInAs('admin');
|
||||||
|
@ -68,6 +52,41 @@ class WallabagV2ControllerTest extends WallabagCoreTestCase
|
||||||
$this->assertEquals(200, $client->getResponse()->getStatusCode());
|
$this->assertEquals(200, $client->getResponse()->getStatusCode());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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());
|
||||||
|
|
||||||
|
$form = $crawler->filter('form[name=upload_import_file] > button[type=submit]')->form();
|
||||||
|
|
||||||
|
$file = new UploadedFile(__DIR__.'/../fixtures/wallabag-v2.json', 'wallabag-v2.json');
|
||||||
|
|
||||||
|
$data = [
|
||||||
|
'upload_import_file[file]' => $file,
|
||||||
|
];
|
||||||
|
|
||||||
|
$client->submit($form, $data);
|
||||||
|
|
||||||
|
$this->assertEquals(302, $client->getResponse()->getStatusCode());
|
||||||
|
|
||||||
|
$crawler = $client->followRedirect();
|
||||||
|
|
||||||
|
$this->assertGreaterThan(1, $body = $crawler->filter('body')->extract(['_text']));
|
||||||
|
$this->assertContains('flashes.import.notice.summary', $body[0]);
|
||||||
|
|
||||||
|
$this->assertNotEmpty($client->getContainer()->get('wallabag_core.redis.client')->lpop('wallabag.import.wallabag_v2'));
|
||||||
|
|
||||||
|
$client->getContainer()->get('craue_config')->set('import_with_redis', 0);
|
||||||
|
}
|
||||||
|
|
||||||
public function testImportWallabagWithFile()
|
public function testImportWallabagWithFile()
|
||||||
{
|
{
|
||||||
$this->logInAs('admin');
|
$this->logInAs('admin');
|
||||||
|
|
Loading…
Reference in a new issue