aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests/Wallabag/ImportBundle/Import/WallabagV2ImportTest.php
diff options
context:
space:
mode:
authorJeremy Benoist <jeremy.benoist@gmail.com>2016-09-09 21:02:03 +0200
committerJeremy Benoist <jeremy.benoist@gmail.com>2016-09-11 21:58:56 +0200
commitb3437d58ae224121375c99e9288d8b808524e624 (patch)
tree94ce3446aed4396ba9304b8c97e421eba35e4edf /tests/Wallabag/ImportBundle/Import/WallabagV2ImportTest.php
parent7f7531171f6e49110b5842f869e37c766a682473 (diff)
downloadwallabag-b3437d58ae224121375c99e9288d8b808524e624.tar.gz
wallabag-b3437d58ae224121375c99e9288d8b808524e624.tar.zst
wallabag-b3437d58ae224121375c99e9288d8b808524e624.zip
Enable Redis async import
- using javibravo/simpleue - internal config value are now `import_with_redis` & `import_with_rabbit` which are more clear - if both option are enable rabbit will be choosen - services imports related to async are now splitted into 2 files: `redis.yml` & `rabbit.yml` -
Diffstat (limited to 'tests/Wallabag/ImportBundle/Import/WallabagV2ImportTest.php')
-rw-r--r--tests/Wallabag/ImportBundle/Import/WallabagV2ImportTest.php41
1 files changed, 40 insertions, 1 deletions
diff --git a/tests/Wallabag/ImportBundle/Import/WallabagV2ImportTest.php b/tests/Wallabag/ImportBundle/Import/WallabagV2ImportTest.php
index 51f0aada..18998b35 100644
--- a/tests/Wallabag/ImportBundle/Import/WallabagV2ImportTest.php
+++ b/tests/Wallabag/ImportBundle/Import/WallabagV2ImportTest.php
@@ -5,8 +5,11 @@ namespace Tests\Wallabag\ImportBundle\Import;
5use Wallabag\ImportBundle\Import\WallabagV2Import; 5use Wallabag\ImportBundle\Import\WallabagV2Import;
6use Wallabag\UserBundle\Entity\User; 6use Wallabag\UserBundle\Entity\User;
7use Wallabag\CoreBundle\Entity\Entry; 7use Wallabag\CoreBundle\Entity\Entry;
8use Wallabag\ImportBundle\Redis\Producer;
8use Monolog\Logger; 9use Monolog\Logger;
9use Monolog\Handler\TestHandler; 10use Monolog\Handler\TestHandler;
11use Simpleue\Queue\RedisQueue;
12use M6Web\Component\RedisMock\RedisMockFactory;
10 13
11class WallabagV2ImportTest extends \PHPUnit_Framework_TestCase 14class WallabagV2ImportTest extends \PHPUnit_Framework_TestCase
12{ 15{
@@ -144,7 +147,7 @@ class WallabagV2ImportTest extends \PHPUnit_Framework_TestCase
144 ->expects($this->exactly(24)) 147 ->expects($this->exactly(24))
145 ->method('publish'); 148 ->method('publish');
146 149
147 $wallabagV2Import->setRabbitmqProducer($producer); 150 $wallabagV2Import->setProducer($producer);
148 151
149 $res = $wallabagV2Import->setMarkAsRead(true)->import(); 152 $res = $wallabagV2Import->setMarkAsRead(true)->import();
150 153
@@ -152,6 +155,42 @@ class WallabagV2ImportTest extends \PHPUnit_Framework_TestCase
152 $this->assertEquals(['skipped' => 0, 'imported' => 24], $wallabagV2Import->getSummary()); 155 $this->assertEquals(['skipped' => 0, 'imported' => 24], $wallabagV2Import->getSummary());
153 } 156 }
154 157
158 public function testImportWithRedis()
159 {
160 $wallabagV2Import = $this->getWallabagV2Import();
161 $wallabagV2Import->setFilepath(__DIR__.'/../fixtures/wallabag-v2.json');
162
163 $entryRepo = $this->getMockBuilder('Wallabag\CoreBundle\Repository\EntryRepository')
164 ->disableOriginalConstructor()
165 ->getMock();
166
167 $entryRepo->expects($this->never())
168 ->method('findByUrlAndUserId');
169
170 $this->em
171 ->expects($this->never())
172 ->method('getRepository');
173
174 $this->contentProxy
175 ->expects($this->never())
176 ->method('updateEntry');
177
178 $factory = new RedisMockFactory();
179 $redisMock = $factory->getAdapter('Predis\Client', true);
180
181 $queue = new RedisQueue($redisMock, 'wallabag_v2');
182 $producer = new Producer($queue);
183
184 $wallabagV2Import->setProducer($producer);
185
186 $res = $wallabagV2Import->setMarkAsRead(true)->import();
187
188 $this->assertTrue($res);
189 $this->assertEquals(['skipped' => 0, 'imported' => 24], $wallabagV2Import->getSummary());
190
191 $this->assertNotEmpty($redisMock->lpop('wallabag_v2'));
192 }
193
155 public function testImportBadFile() 194 public function testImportBadFile()
156 { 195 {
157 $wallabagV1Import = $this->getWallabagV2Import(); 196 $wallabagV1Import = $this->getWallabagV2Import();