diff options
author | Jeremy Benoist <jeremy.benoist@gmail.com> | 2016-09-09 21:02:03 +0200 |
---|---|---|
committer | Jeremy Benoist <jeremy.benoist@gmail.com> | 2016-09-11 21:58:56 +0200 |
commit | b3437d58ae224121375c99e9288d8b808524e624 (patch) | |
tree | 94ce3446aed4396ba9304b8c97e421eba35e4edf /tests/Wallabag/ImportBundle/Import/ReadabilityImportTest.php | |
parent | 7f7531171f6e49110b5842f869e37c766a682473 (diff) | |
download | wallabag-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/ReadabilityImportTest.php')
-rw-r--r-- | tests/Wallabag/ImportBundle/Import/ReadabilityImportTest.php | 45 |
1 files changed, 44 insertions, 1 deletions
diff --git a/tests/Wallabag/ImportBundle/Import/ReadabilityImportTest.php b/tests/Wallabag/ImportBundle/Import/ReadabilityImportTest.php index 69a66d6a..0981eedb 100644 --- a/tests/Wallabag/ImportBundle/Import/ReadabilityImportTest.php +++ b/tests/Wallabag/ImportBundle/Import/ReadabilityImportTest.php | |||
@@ -5,8 +5,11 @@ namespace Tests\Wallabag\ImportBundle\Import; | |||
5 | use Wallabag\ImportBundle\Import\ReadabilityImport; | 5 | use Wallabag\ImportBundle\Import\ReadabilityImport; |
6 | use Wallabag\UserBundle\Entity\User; | 6 | use Wallabag\UserBundle\Entity\User; |
7 | use Wallabag\CoreBundle\Entity\Entry; | 7 | use Wallabag\CoreBundle\Entity\Entry; |
8 | use Wallabag\ImportBundle\Redis\Producer; | ||
8 | use Monolog\Logger; | 9 | use Monolog\Logger; |
9 | use Monolog\Handler\TestHandler; | 10 | use Monolog\Handler\TestHandler; |
11 | use Simpleue\Queue\RedisQueue; | ||
12 | use M6Web\Component\RedisMock\RedisMockFactory; | ||
10 | 13 | ||
11 | class ReadabilityImportTest extends \PHPUnit_Framework_TestCase | 14 | class ReadabilityImportTest extends \PHPUnit_Framework_TestCase |
12 | { | 15 | { |
@@ -152,7 +155,7 @@ class ReadabilityImportTest extends \PHPUnit_Framework_TestCase | |||
152 | ->expects($this->exactly(2)) | 155 | ->expects($this->exactly(2)) |
153 | ->method('publish'); | 156 | ->method('publish'); |
154 | 157 | ||
155 | $readabilityImport->setRabbitmqProducer($producer); | 158 | $readabilityImport->setProducer($producer); |
156 | 159 | ||
157 | $res = $readabilityImport->setMarkAsRead(true)->import(); | 160 | $res = $readabilityImport->setMarkAsRead(true)->import(); |
158 | 161 | ||
@@ -160,6 +163,46 @@ class ReadabilityImportTest extends \PHPUnit_Framework_TestCase | |||
160 | $this->assertEquals(['skipped' => 0, 'imported' => 2], $readabilityImport->getSummary()); | 163 | $this->assertEquals(['skipped' => 0, 'imported' => 2], $readabilityImport->getSummary()); |
161 | } | 164 | } |
162 | 165 | ||
166 | public function testImportWithRedis() | ||
167 | { | ||
168 | $readabilityImport = $this->getReadabilityImport(); | ||
169 | $readabilityImport->setFilepath(__DIR__.'/../fixtures/readability.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, 'readability'); | ||
194 | $producer = new Producer($queue); | ||
195 | |||
196 | $readabilityImport->setProducer($producer); | ||
197 | |||
198 | $res = $readabilityImport->setMarkAsRead(true)->import(); | ||
199 | |||
200 | $this->assertTrue($res); | ||
201 | $this->assertEquals(['skipped' => 0, 'imported' => 2], $readabilityImport->getSummary()); | ||
202 | |||
203 | $this->assertNotEmpty($redisMock->lpop('readability')); | ||
204 | } | ||
205 | |||
163 | public function testImportBadFile() | 206 | public function testImportBadFile() |
164 | { | 207 | { |
165 | $readabilityImport = $this->getReadabilityImport(); | 208 | $readabilityImport = $this->getReadabilityImport(); |