mirror of
https://github.com/wallabag/wallabag.git
synced 2024-11-15 21:41:06 +00:00
Added tests for Chrome bookmarks import
This commit is contained in:
parent
06d13ddfbc
commit
f7c55b3812
4 changed files with 75 additions and 3 deletions
|
@ -6,7 +6,6 @@ use Symfony\Bundle\FrameworkBundle\Console\Application;
|
||||||
use Symfony\Component\Console\Tester\CommandTester;
|
use Symfony\Component\Console\Tester\CommandTester;
|
||||||
use Wallabag\ImportBundle\Command\ImportCommand;
|
use Wallabag\ImportBundle\Command\ImportCommand;
|
||||||
use Tests\Wallabag\CoreBundle\WallabagCoreTestCase;
|
use Tests\Wallabag\CoreBundle\WallabagCoreTestCase;
|
||||||
use M6Web\Component\RedisMock\RedisMockFactory;
|
|
||||||
|
|
||||||
class ImportCommandTest extends WallabagCoreTestCase
|
class ImportCommandTest extends WallabagCoreTestCase
|
||||||
{
|
{
|
||||||
|
|
|
@ -19,7 +19,7 @@ class BrowserControllerTest extends WallabagCoreTestCase
|
||||||
$this->assertEquals(1, $crawler->filter('input[type=file]')->count());
|
$this->assertEquals(1, $crawler->filter('input[type=file]')->count());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testImportWallabagWithFile()
|
public function testImportWallabagWithFirefoxFile()
|
||||||
{
|
{
|
||||||
$this->logInAs('admin');
|
$this->logInAs('admin');
|
||||||
$client = $this->getClient();
|
$client = $this->getClient();
|
||||||
|
@ -27,7 +27,7 @@ class BrowserControllerTest extends WallabagCoreTestCase
|
||||||
$crawler = $client->request('GET', '/import/browser');
|
$crawler = $client->request('GET', '/import/browser');
|
||||||
$form = $crawler->filter('form[name=upload_import_file] > button[type=submit]')->form();
|
$form = $crawler->filter('form[name=upload_import_file] > button[type=submit]')->form();
|
||||||
|
|
||||||
$file = new UploadedFile(__DIR__.'/../fixtures/bookmarks.json', 'Bookmarks');
|
$file = new UploadedFile(__DIR__.'/../fixtures/firefox-bookmarks.json', 'Bookmarks');
|
||||||
|
|
||||||
$data = [
|
$data = [
|
||||||
'upload_import_file[file]' => $file,
|
'upload_import_file[file]' => $file,
|
||||||
|
@ -68,6 +68,43 @@ class BrowserControllerTest extends WallabagCoreTestCase
|
||||||
$this->assertEmpty($content->getLanguage());
|
$this->assertEmpty($content->getLanguage());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testImportWallabagWithChromeFile()
|
||||||
|
{
|
||||||
|
$this->logInAs('admin');
|
||||||
|
$client = $this->getClient();
|
||||||
|
|
||||||
|
$crawler = $client->request('GET', '/import/browser');
|
||||||
|
$form = $crawler->filter('form[name=upload_import_file] > button[type=submit]')->form();
|
||||||
|
|
||||||
|
$file = new UploadedFile(__DIR__.'/../fixtures/chrome-bookmarks', 'Bookmarks');
|
||||||
|
|
||||||
|
$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]);
|
||||||
|
|
||||||
|
$content = $client->getContainer()
|
||||||
|
->get('doctrine.orm.entity_manager')
|
||||||
|
->getRepository('WallabagCoreBundle:Entry')
|
||||||
|
->findByUrlAndUserId(
|
||||||
|
'http://www.usinenouvelle.com/article/la-multiplication-des-chefs-de-projet-est-une-catastrophe-manageriale-majeure-affirme-le-sociologue-francois-dupuy.N307730',
|
||||||
|
$this->getLoggedInUserId()
|
||||||
|
);
|
||||||
|
|
||||||
|
$this->assertNotEmpty($content->getMimetype());
|
||||||
|
$this->assertNotEmpty($content->getPreviewPicture());
|
||||||
|
$this->assertNotEmpty($content->getLanguage());
|
||||||
|
$this->assertEquals(0, count($content->getTags()));
|
||||||
|
}
|
||||||
|
|
||||||
public function testImportWallabagWithEmptyFile()
|
public function testImportWallabagWithEmptyFile()
|
||||||
{
|
{
|
||||||
$this->logInAs('admin');
|
$this->logInAs('admin');
|
||||||
|
|
36
tests/Wallabag/ImportBundle/fixtures/chrome-bookmarks
Normal file
36
tests/Wallabag/ImportBundle/fixtures/chrome-bookmarks
Normal file
|
@ -0,0 +1,36 @@
|
||||||
|
{
|
||||||
|
"checksum": "f3aa0e9c0edad632a246f7e98ec64918",
|
||||||
|
"roots": {
|
||||||
|
"bookmark_bar": {
|
||||||
|
"children": [ {
|
||||||
|
"date_added": "13118850929335823",
|
||||||
|
"id": "6",
|
||||||
|
"name": "\"La multiplication des chefs de projet est une catastrophe managériale majeure\", affirme le sociologue François Dupuy - Ressources humaines",
|
||||||
|
"type": "url",
|
||||||
|
"url": "http://www.usinenouvelle.com/article/la-multiplication-des-chefs-de-projet-est-une-catastrophe-manageriale-majeure-affirme-le-sociologue-francois-dupuy.N307730"
|
||||||
|
} ],
|
||||||
|
"date_added": "13118829474385693",
|
||||||
|
"date_modified": "13118850929335823",
|
||||||
|
"id": "1",
|
||||||
|
"name": "Barre de favoris",
|
||||||
|
"type": "folder"
|
||||||
|
},
|
||||||
|
"other": {
|
||||||
|
"children": [ ],
|
||||||
|
"date_added": "13118829474385701",
|
||||||
|
"date_modified": "0",
|
||||||
|
"id": "2",
|
||||||
|
"name": "Autres favoris",
|
||||||
|
"type": "folder"
|
||||||
|
},
|
||||||
|
"synced": {
|
||||||
|
"children": [ ],
|
||||||
|
"date_added": "13118829474385702",
|
||||||
|
"date_modified": "0",
|
||||||
|
"id": "3",
|
||||||
|
"name": "Favoris sur mobile",
|
||||||
|
"type": "folder"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"version": 1
|
||||||
|
}
|
Loading…
Reference in a new issue