mirror of
https://github.com/wallabag/wallabag.git
synced 2025-09-15 18:57:05 +00:00
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` -
This commit is contained in:
parent
7f7531171f
commit
b3437d58ae
28 changed files with 846 additions and 68 deletions
|
@ -5,8 +5,11 @@ namespace Tests\Wallabag\ImportBundle\Import;
|
|||
use Wallabag\ImportBundle\Import\ReadabilityImport;
|
||||
use Wallabag\UserBundle\Entity\User;
|
||||
use Wallabag\CoreBundle\Entity\Entry;
|
||||
use Wallabag\ImportBundle\Redis\Producer;
|
||||
use Monolog\Logger;
|
||||
use Monolog\Handler\TestHandler;
|
||||
use Simpleue\Queue\RedisQueue;
|
||||
use M6Web\Component\RedisMock\RedisMockFactory;
|
||||
|
||||
class ReadabilityImportTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
|
@ -152,7 +155,7 @@ class ReadabilityImportTest extends \PHPUnit_Framework_TestCase
|
|||
->expects($this->exactly(2))
|
||||
->method('publish');
|
||||
|
||||
$readabilityImport->setRabbitmqProducer($producer);
|
||||
$readabilityImport->setProducer($producer);
|
||||
|
||||
$res = $readabilityImport->setMarkAsRead(true)->import();
|
||||
|
||||
|
@ -160,6 +163,46 @@ class ReadabilityImportTest extends \PHPUnit_Framework_TestCase
|
|||
$this->assertEquals(['skipped' => 0, 'imported' => 2], $readabilityImport->getSummary());
|
||||
}
|
||||
|
||||
public function testImportWithRedis()
|
||||
{
|
||||
$readabilityImport = $this->getReadabilityImport();
|
||||
$readabilityImport->setFilepath(__DIR__.'/../fixtures/readability.json');
|
||||
|
||||
$entryRepo = $this->getMockBuilder('Wallabag\CoreBundle\Repository\EntryRepository')
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
|
||||
$entryRepo->expects($this->never())
|
||||
->method('findByUrlAndUserId');
|
||||
|
||||
$this->em
|
||||
->expects($this->never())
|
||||
->method('getRepository');
|
||||
|
||||
$entry = $this->getMockBuilder('Wallabag\CoreBundle\Entity\Entry')
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
|
||||
$this->contentProxy
|
||||
->expects($this->never())
|
||||
->method('updateEntry');
|
||||
|
||||
$factory = new RedisMockFactory();
|
||||
$redisMock = $factory->getAdapter('Predis\Client', true);
|
||||
|
||||
$queue = new RedisQueue($redisMock, 'readability');
|
||||
$producer = new Producer($queue);
|
||||
|
||||
$readabilityImport->setProducer($producer);
|
||||
|
||||
$res = $readabilityImport->setMarkAsRead(true)->import();
|
||||
|
||||
$this->assertTrue($res);
|
||||
$this->assertEquals(['skipped' => 0, 'imported' => 2], $readabilityImport->getSummary());
|
||||
|
||||
$this->assertNotEmpty($redisMock->lpop('readability'));
|
||||
}
|
||||
|
||||
public function testImportBadFile()
|
||||
{
|
||||
$readabilityImport = $this->getReadabilityImport();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue