aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/Wallabag/ImportBundle/Tests/Import
diff options
context:
space:
mode:
authorJeremy Benoist <jeremy.benoist@gmail.com>2015-12-31 11:24:46 +0100
committerJeremy Benoist <jeremy.benoist@gmail.com>2016-01-02 23:27:41 +0100
commit7019c7cf6c6af39c0f458769e20c3f9306477943 (patch)
tree12acceaa458cdf6d24367eba85f690265acddcdb /src/Wallabag/ImportBundle/Tests/Import
parentb1d05721cf37ab94ec1a6837fe79cf19474dd0ff (diff)
downloadwallabag-7019c7cf6c6af39c0f458769e20c3f9306477943.tar.gz
wallabag-7019c7cf6c6af39c0f458769e20c3f9306477943.tar.zst
wallabag-7019c7cf6c6af39c0f458769e20c3f9306477943.zip
Add tagged services for import
- list services in /import - add url to import service - ImportBundle routing are now prefixed by /import - optimize flush in each import (flushing each 20 contents) - improve design of each import - add more tests
Diffstat (limited to 'src/Wallabag/ImportBundle/Tests/Import')
-rw-r--r--src/Wallabag/ImportBundle/Tests/Import/ImportChainTest.php21
-rw-r--r--src/Wallabag/ImportBundle/Tests/Import/ImportCompilerPassTest.php47
-rw-r--r--src/Wallabag/ImportBundle/Tests/Import/PocketImportTest.php3
-rw-r--r--src/Wallabag/ImportBundle/Tests/Import/WallabagV1ImportTest.php3
4 files changed, 72 insertions, 2 deletions
diff --git a/src/Wallabag/ImportBundle/Tests/Import/ImportChainTest.php b/src/Wallabag/ImportBundle/Tests/Import/ImportChainTest.php
new file mode 100644
index 00000000..702d2a9b
--- /dev/null
+++ b/src/Wallabag/ImportBundle/Tests/Import/ImportChainTest.php
@@ -0,0 +1,21 @@
1<?php
2
3namespace Wallabag\ImportBundle\Tests\Import;
4
5use Wallabag\ImportBundle\Import\ImportChain;
6
7class ImportChainTest extends \PHPUnit_Framework_TestCase
8{
9 public function testGetAll()
10 {
11 $import = $this->getMockBuilder('Wallabag\ImportBundle\Import\ImportInterface')
12 ->disableOriginalConstructor()
13 ->getMock();
14
15 $importChain = new ImportChain();
16 $importChain->addImport($import, 'alias');
17
18 $this->assertCount(1, $importChain->getAll());
19 $this->assertEquals($import, $importChain->getAll()['alias']);
20 }
21}
diff --git a/src/Wallabag/ImportBundle/Tests/Import/ImportCompilerPassTest.php b/src/Wallabag/ImportBundle/Tests/Import/ImportCompilerPassTest.php
new file mode 100644
index 00000000..bd62ab3b
--- /dev/null
+++ b/src/Wallabag/ImportBundle/Tests/Import/ImportCompilerPassTest.php
@@ -0,0 +1,47 @@
1<?php
2
3namespace Wallabag\ImportBundle\Tests\Import;
4
5use Symfony\Component\DependencyInjection\ContainerBuilder;
6use Wallabag\ImportBundle\Import\ImportCompilerPass;
7
8class ImportCompilerPassTest extends \PHPUnit_Framework_TestCase
9{
10 public function testProcessNoDefinition()
11 {
12 $container = new ContainerBuilder();
13 $res = $this->process($container);
14
15 $this->assertNull($res);
16 }
17
18 public function testProcess()
19 {
20 $container = new ContainerBuilder();
21 $container
22 ->register('wallabag_import.chain')
23 ->setPublic(false)
24 ;
25
26 $container
27 ->register('foo')
28 ->addTag('wallabag_import.import', array('alias' => 'pocket'))
29 ;
30
31 $this->process($container);
32
33 $this->assertTrue($container->hasDefinition('wallabag_import.chain'));
34
35 $definition = $container->getDefinition('wallabag_import.chain');
36 $this->assertTrue($definition->hasMethodCall('addImport'));
37
38 $calls = $definition->getMethodCalls();
39 $this->assertEquals('pocket', $calls[0][1][1]);
40 }
41
42 protected function process(ContainerBuilder $container)
43 {
44 $repeatedPass = new ImportCompilerPass();
45 $repeatedPass->process($container);
46 }
47}
diff --git a/src/Wallabag/ImportBundle/Tests/Import/PocketImportTest.php b/src/Wallabag/ImportBundle/Tests/Import/PocketImportTest.php
index cf706fa9..6ee70db0 100644
--- a/src/Wallabag/ImportBundle/Tests/Import/PocketImportTest.php
+++ b/src/Wallabag/ImportBundle/Tests/Import/PocketImportTest.php
@@ -74,7 +74,8 @@ class PocketImportTest extends \PHPUnit_Framework_TestCase
74 $pocketImport = $this->getPocketImport(); 74 $pocketImport = $this->getPocketImport();
75 75
76 $this->assertEquals('Pocket', $pocketImport->getName()); 76 $this->assertEquals('Pocket', $pocketImport->getName());
77 $this->assertEquals('This importer will import all your <a href="https://getpocket.com">Pocket</a> data.', $pocketImport->getDescription()); 77 $this->assertNotEmpty($pocketImport->getUrl());
78 $this->assertContains('This importer will import all your <a href="https://getpocket.com">Pocket</a> data.', $pocketImport->getDescription());
78 } 79 }
79 80
80 public function testOAuthRequest() 81 public function testOAuthRequest()
diff --git a/src/Wallabag/ImportBundle/Tests/Import/WallabagV1ImportTest.php b/src/Wallabag/ImportBundle/Tests/Import/WallabagV1ImportTest.php
index fc66d402..8a8eb3fa 100644
--- a/src/Wallabag/ImportBundle/Tests/Import/WallabagV1ImportTest.php
+++ b/src/Wallabag/ImportBundle/Tests/Import/WallabagV1ImportTest.php
@@ -39,7 +39,8 @@ class WallabagV1ImportTest extends \PHPUnit_Framework_TestCase
39 $wallabagV1Import = $this->getWallabagV1Import(); 39 $wallabagV1Import = $this->getWallabagV1Import();
40 40
41 $this->assertEquals('Wallabag v1', $wallabagV1Import->getName()); 41 $this->assertEquals('Wallabag v1', $wallabagV1Import->getName());
42 $this->assertEquals('This importer will import all your wallabag v1 articles.', $wallabagV1Import->getDescription()); 42 $this->assertNotEmpty($wallabagV1Import->getUrl());
43 $this->assertContains('This importer will import all your wallabag v1 articles.', $wallabagV1Import->getDescription());
43 } 44 }
44 45
45 public function testImport() 46 public function testImport()