aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests/Wallabag/ImportBundle/Import/WallabagV1ImportTest.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/WallabagV1ImportTest.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/WallabagV1ImportTest.php')
-rw-r--r--tests/Wallabag/ImportBundle/Import/WallabagV1ImportTest.php45
1 files changed, 44 insertions, 1 deletions
diff --git a/tests/Wallabag/ImportBundle/Import/WallabagV1ImportTest.php b/tests/Wallabag/ImportBundle/Import/WallabagV1ImportTest.php
index ada5493e..b43682cd 100644
--- a/tests/Wallabag/ImportBundle/Import/WallabagV1ImportTest.php
+++ b/tests/Wallabag/ImportBundle/Import/WallabagV1ImportTest.php
@@ -5,8 +5,11 @@ namespace Tests\Wallabag\ImportBundle\Import;
5use Wallabag\ImportBundle\Import\WallabagV1Import; 5use Wallabag\ImportBundle\Import\WallabagV1Import;
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 WallabagV1ImportTest extends \PHPUnit_Framework_TestCase 14class WallabagV1ImportTest extends \PHPUnit_Framework_TestCase
12{ 15{
@@ -152,7 +155,7 @@ class WallabagV1ImportTest extends \PHPUnit_Framework_TestCase
152 ->expects($this->exactly(4)) 155 ->expects($this->exactly(4))
153 ->method('publish'); 156 ->method('publish');
154 157
155 $wallabagV1Import->setRabbitmqProducer($producer); 158 $wallabagV1Import->setProducer($producer);
156 159
157 $res = $wallabagV1Import->setMarkAsRead(true)->import(); 160 $res = $wallabagV1Import->setMarkAsRead(true)->import();
158 161
@@ -160,6 +163,46 @@ class WallabagV1ImportTest extends \PHPUnit_Framework_TestCase
160 $this->assertEquals(['skipped' => 0, 'imported' => 4], $wallabagV1Import->getSummary()); 163 $this->assertEquals(['skipped' => 0, 'imported' => 4], $wallabagV1Import->getSummary());
161 } 164 }
162 165
166 public function testImportWithRedis()
167 {
168 $wallabagV1Import = $this->getWallabagV1Import();
169 $wallabagV1Import->setFilepath(__DIR__.'/../fixtures/wallabag-v1.json');
170
171 $entryRepo = $this->getMockBuilder('Wallabag\CoreBundle\Repository\EntryRepository')
172 ->disableOriginalConstructor()
173 ->getMock();
174
175 $entryRepo->expects($this->never())
176 ->method('findByUrlAndUserId');
177
178 $this->em
179 ->expects($this->never())
180 ->method('getRepository');
181
182 $entry = $this->getMockBuilder('Wallabag\CoreBundle\Entity\Entry')
183 ->disableOriginalConstructor()
184 ->getMock();
185
186 $this->contentProxy
187 ->expects($this->never())
188 ->method('updateEntry');
189
190 $factory = new RedisMockFactory();
191 $redisMock = $factory->getAdapter('Predis\Client', true);
192
193 $queue = new RedisQueue($redisMock, 'wallabag_v1');
194 $producer = new Producer($queue);
195
196 $wallabagV1Import->setProducer($producer);
197
198 $res = $wallabagV1Import->setMarkAsRead(true)->import();
199
200 $this->assertTrue($res);
201 $this->assertEquals(['skipped' => 0, 'imported' => 4], $wallabagV1Import->getSummary());
202
203 $this->assertNotEmpty($redisMock->lpop('wallabag_v1'));
204 }
205
163 public function testImportBadFile() 206 public function testImportBadFile()
164 { 207 {
165 $wallabagV1Import = $this->getWallabagV1Import(); 208 $wallabagV1Import = $this->getWallabagV1Import();