1
0
Fork 0
mirror of https://github.com/wallabag/wallabag.git synced 2025-09-15 18:57:05 +00:00

Add entry.saved event to import & rest

This commit is contained in:
Jeremy Benoist 2016-11-02 07:10:23 +01:00
parent e0597476d1
commit 7816eb622d
No known key found for this signature in database
GPG key ID: BCA73962457ACC3C
17 changed files with 222 additions and 49 deletions

View file

@ -112,10 +112,19 @@ JSON;
->with(json_decode($body, true))
->willReturn($entry);
$dispatcher = $this->getMockBuilder('Symfony\Component\EventDispatcher\EventDispatcher')
->disableOriginalConstructor()
->getMock();
$dispatcher
->expects($this->once())
->method('dispatch');
$consumer = new AMQPEntryConsumer(
$em,
$userRepository,
$import
$import,
$dispatcher
);
$message = new AMQPMessage($body);
@ -157,10 +166,19 @@ JSON;
->disableOriginalConstructor()
->getMock();
$dispatcher = $this->getMockBuilder('Symfony\Component\EventDispatcher\EventDispatcher')
->disableOriginalConstructor()
->getMock();
$dispatcher
->expects($this->never())
->method('dispatch');
$consumer = new AMQPEntryConsumer(
$em,
$userRepository,
$import
$import,
$dispatcher
);
$message = new AMQPMessage($body);
@ -212,10 +230,19 @@ JSON;
->with(json_decode($body, true))
->willReturn(null);
$dispatcher = $this->getMockBuilder('Symfony\Component\EventDispatcher\EventDispatcher')
->disableOriginalConstructor()
->getMock();
$dispatcher
->expects($this->never())
->method('dispatch');
$consumer = new AMQPEntryConsumer(
$em,
$userRepository,
$import
$import,
$dispatcher
);
$message = new AMQPMessage($body);

View file

@ -111,10 +111,19 @@ JSON;
->with(json_decode($body, true))
->willReturn($entry);
$dispatcher = $this->getMockBuilder('Symfony\Component\EventDispatcher\EventDispatcher')
->disableOriginalConstructor()
->getMock();
$dispatcher
->expects($this->once())
->method('dispatch');
$consumer = new RedisEntryConsumer(
$em,
$userRepository,
$import
$import,
$dispatcher
);
$res = $consumer->manage($body);
@ -156,10 +165,19 @@ JSON;
->disableOriginalConstructor()
->getMock();
$dispatcher = $this->getMockBuilder('Symfony\Component\EventDispatcher\EventDispatcher')
->disableOriginalConstructor()
->getMock();
$dispatcher
->expects($this->never())
->method('dispatch');
$consumer = new RedisEntryConsumer(
$em,
$userRepository,
$import
$import,
$dispatcher
);
$res = $consumer->manage($body);
@ -211,10 +229,19 @@ JSON;
->with(json_decode($body, true))
->willReturn(null);
$dispatcher = $this->getMockBuilder('Symfony\Component\EventDispatcher\EventDispatcher')
->disableOriginalConstructor()
->getMock();
$dispatcher
->expects($this->never())
->method('dispatch');
$consumer = new RedisEntryConsumer(
$em,
$userRepository,
$import
$import,
$dispatcher
);
$res = $consumer->manage($body);

View file

@ -18,7 +18,7 @@ class ChromeImportTest extends \PHPUnit_Framework_TestCase
protected $logHandler;
protected $contentProxy;
private function getChromeImport($unsetUser = false)
private function getChromeImport($unsetUser = false, $dispatched = 0)
{
$this->user = new User();
@ -30,7 +30,15 @@ class ChromeImportTest extends \PHPUnit_Framework_TestCase
->disableOriginalConstructor()
->getMock();
$wallabag = new ChromeImport($this->em, $this->contentProxy);
$dispatcher = $this->getMockBuilder('Symfony\Component\EventDispatcher\EventDispatcher')
->disableOriginalConstructor()
->getMock();
$dispatcher
->expects($this->exactly($dispatched))
->method('dispatch');
$wallabag = new ChromeImport($this->em, $this->contentProxy, $dispatcher);
$this->logHandler = new TestHandler();
$logger = new Logger('test', [$this->logHandler]);
@ -54,7 +62,7 @@ class ChromeImportTest extends \PHPUnit_Framework_TestCase
public function testImport()
{
$chromeImport = $this->getChromeImport();
$chromeImport = $this->getChromeImport(false, 1);
$chromeImport->setFilepath(__DIR__.'/../fixtures/chrome-bookmarks');
$entryRepo = $this->getMockBuilder('Wallabag\CoreBundle\Repository\EntryRepository')
@ -87,7 +95,7 @@ class ChromeImportTest extends \PHPUnit_Framework_TestCase
public function testImportAndMarkAllAsRead()
{
$chromeImport = $this->getChromeImport();
$chromeImport = $this->getChromeImport(false, 1);
$chromeImport->setFilepath(__DIR__.'/../fixtures/chrome-bookmarks');
$entryRepo = $this->getMockBuilder('Wallabag\CoreBundle\Repository\EntryRepository')

View file

@ -18,7 +18,7 @@ class FirefoxImportTest extends \PHPUnit_Framework_TestCase
protected $logHandler;
protected $contentProxy;
private function getFirefoxImport($unsetUser = false)
private function getFirefoxImport($unsetUser = false, $dispatched = 0)
{
$this->user = new User();
@ -30,7 +30,15 @@ class FirefoxImportTest extends \PHPUnit_Framework_TestCase
->disableOriginalConstructor()
->getMock();
$wallabag = new FirefoxImport($this->em, $this->contentProxy);
$dispatcher = $this->getMockBuilder('Symfony\Component\EventDispatcher\EventDispatcher')
->disableOriginalConstructor()
->getMock();
$dispatcher
->expects($this->exactly($dispatched))
->method('dispatch');
$wallabag = new FirefoxImport($this->em, $this->contentProxy, $dispatcher);
$this->logHandler = new TestHandler();
$logger = new Logger('test', [$this->logHandler]);
@ -54,7 +62,7 @@ class FirefoxImportTest extends \PHPUnit_Framework_TestCase
public function testImport()
{
$firefoxImport = $this->getFirefoxImport();
$firefoxImport = $this->getFirefoxImport(false, 2);
$firefoxImport->setFilepath(__DIR__.'/../fixtures/firefox-bookmarks.json');
$entryRepo = $this->getMockBuilder('Wallabag\CoreBundle\Repository\EntryRepository')
@ -87,7 +95,7 @@ class FirefoxImportTest extends \PHPUnit_Framework_TestCase
public function testImportAndMarkAllAsRead()
{
$firefoxImport = $this->getFirefoxImport();
$firefoxImport = $this->getFirefoxImport(false, 1);
$firefoxImport->setFilepath(__DIR__.'/../fixtures/firefox-bookmarks.json');
$entryRepo = $this->getMockBuilder('Wallabag\CoreBundle\Repository\EntryRepository')

View file

@ -18,7 +18,7 @@ class InstapaperImportTest extends \PHPUnit_Framework_TestCase
protected $logHandler;
protected $contentProxy;
private function getInstapaperImport($unsetUser = false)
private function getInstapaperImport($unsetUser = false, $dispatched = 0)
{
$this->user = new User();
@ -30,7 +30,15 @@ class InstapaperImportTest extends \PHPUnit_Framework_TestCase
->disableOriginalConstructor()
->getMock();
$import = new InstapaperImport($this->em, $this->contentProxy);
$dispatcher = $this->getMockBuilder('Symfony\Component\EventDispatcher\EventDispatcher')
->disableOriginalConstructor()
->getMock();
$dispatcher
->expects($this->exactly($dispatched))
->method('dispatch');
$import = new InstapaperImport($this->em, $this->contentProxy, $dispatcher);
$this->logHandler = new TestHandler();
$logger = new Logger('test', [$this->logHandler]);
@ -54,7 +62,7 @@ class InstapaperImportTest extends \PHPUnit_Framework_TestCase
public function testImport()
{
$instapaperImport = $this->getInstapaperImport();
$instapaperImport = $this->getInstapaperImport(false, 3);
$instapaperImport->setFilepath(__DIR__.'/../fixtures/instapaper-export.csv');
$entryRepo = $this->getMockBuilder('Wallabag\CoreBundle\Repository\EntryRepository')
@ -87,7 +95,7 @@ class InstapaperImportTest extends \PHPUnit_Framework_TestCase
public function testImportAndMarkAllAsRead()
{
$instapaperImport = $this->getInstapaperImport();
$instapaperImport = $this->getInstapaperImport(false, 1);
$instapaperImport->setFilepath(__DIR__.'/../fixtures/instapaper-export.csv');
$entryRepo = $this->getMockBuilder('Wallabag\CoreBundle\Repository\EntryRepository')

View file

@ -24,7 +24,7 @@ class PocketImportTest extends \PHPUnit_Framework_TestCase
protected $contentProxy;
protected $logHandler;
private function getPocketImport($consumerKey = 'ConsumerKey')
private function getPocketImport($consumerKey = 'ConsumerKey', $dispatched = 0)
{
$this->user = new User();
@ -55,10 +55,15 @@ class PocketImportTest extends \PHPUnit_Framework_TestCase
->method('getScheduledEntityInsertions')
->willReturn([]);
$pocket = new PocketImport(
$this->em,
$this->contentProxy
);
$dispatcher = $this->getMockBuilder('Symfony\Component\EventDispatcher\EventDispatcher')
->disableOriginalConstructor()
->getMock();
$dispatcher
->expects($this->exactly($dispatched))
->method('dispatch');
$pocket = new PocketImport($this->em, $this->contentProxy, $dispatcher);
$pocket->setUser($this->user);
$this->logHandler = new TestHandler();
@ -252,7 +257,7 @@ class PocketImportTest extends \PHPUnit_Framework_TestCase
$client->getEmitter()->attach($mock);
$pocketImport = $this->getPocketImport();
$pocketImport = $this->getPocketImport('ConsumerKey', 1);
$entryRepo = $this->getMockBuilder('Wallabag\CoreBundle\Repository\EntryRepository')
->disableOriginalConstructor()
@ -339,7 +344,7 @@ class PocketImportTest extends \PHPUnit_Framework_TestCase
$client->getEmitter()->attach($mock);
$pocketImport = $this->getPocketImport();
$pocketImport = $this->getPocketImport('ConsumerKey', 2);
$entryRepo = $this->getMockBuilder('Wallabag\CoreBundle\Repository\EntryRepository')
->disableOriginalConstructor()
@ -591,7 +596,7 @@ JSON;
$client->getEmitter()->attach($mock);
$pocketImport = $this->getPocketImport();
$pocketImport = $this->getPocketImport('ConsumerKey', 1);
$entryRepo = $this->getMockBuilder('Wallabag\CoreBundle\Repository\EntryRepository')
->disableOriginalConstructor()

View file

@ -18,7 +18,7 @@ class ReadabilityImportTest extends \PHPUnit_Framework_TestCase
protected $logHandler;
protected $contentProxy;
private function getReadabilityImport($unsetUser = false)
private function getReadabilityImport($unsetUser = false, $dispatched = 0)
{
$this->user = new User();
@ -30,7 +30,15 @@ class ReadabilityImportTest extends \PHPUnit_Framework_TestCase
->disableOriginalConstructor()
->getMock();
$wallabag = new ReadabilityImport($this->em, $this->contentProxy);
$dispatcher = $this->getMockBuilder('Symfony\Component\EventDispatcher\EventDispatcher')
->disableOriginalConstructor()
->getMock();
$dispatcher
->expects($this->exactly($dispatched))
->method('dispatch');
$wallabag = new ReadabilityImport($this->em, $this->contentProxy, $dispatcher);
$this->logHandler = new TestHandler();
$logger = new Logger('test', [$this->logHandler]);
@ -54,7 +62,7 @@ class ReadabilityImportTest extends \PHPUnit_Framework_TestCase
public function testImport()
{
$readabilityImport = $this->getReadabilityImport();
$readabilityImport = $this->getReadabilityImport(false, 24);
$readabilityImport->setFilepath(__DIR__.'/../fixtures/readability.json');
$entryRepo = $this->getMockBuilder('Wallabag\CoreBundle\Repository\EntryRepository')
@ -87,7 +95,7 @@ class ReadabilityImportTest extends \PHPUnit_Framework_TestCase
public function testImportAndMarkAllAsRead()
{
$readabilityImport = $this->getReadabilityImport();
$readabilityImport = $this->getReadabilityImport(false, 1);
$readabilityImport->setFilepath(__DIR__.'/../fixtures/readability-read.json');
$entryRepo = $this->getMockBuilder('Wallabag\CoreBundle\Repository\EntryRepository')

View file

@ -18,7 +18,7 @@ class WallabagV1ImportTest extends \PHPUnit_Framework_TestCase
protected $logHandler;
protected $contentProxy;
private function getWallabagV1Import($unsetUser = false)
private function getWallabagV1Import($unsetUser = false, $dispatched = 0)
{
$this->user = new User();
@ -44,7 +44,15 @@ class WallabagV1ImportTest extends \PHPUnit_Framework_TestCase
->disableOriginalConstructor()
->getMock();
$wallabag = new WallabagV1Import($this->em, $this->contentProxy);
$dispatcher = $this->getMockBuilder('Symfony\Component\EventDispatcher\EventDispatcher')
->disableOriginalConstructor()
->getMock();
$dispatcher
->expects($this->exactly($dispatched))
->method('dispatch');
$wallabag = new WallabagV1Import($this->em, $this->contentProxy, $dispatcher);
$this->logHandler = new TestHandler();
$logger = new Logger('test', [$this->logHandler]);
@ -68,7 +76,7 @@ class WallabagV1ImportTest extends \PHPUnit_Framework_TestCase
public function testImport()
{
$wallabagV1Import = $this->getWallabagV1Import();
$wallabagV1Import = $this->getWallabagV1Import(false, 3);
$wallabagV1Import->setFilepath(__DIR__.'/../fixtures/wallabag-v1.json');
$entryRepo = $this->getMockBuilder('Wallabag\CoreBundle\Repository\EntryRepository')
@ -101,7 +109,7 @@ class WallabagV1ImportTest extends \PHPUnit_Framework_TestCase
public function testImportAndMarkAllAsRead()
{
$wallabagV1Import = $this->getWallabagV1Import();
$wallabagV1Import = $this->getWallabagV1Import(false, 3);
$wallabagV1Import->setFilepath(__DIR__.'/../fixtures/wallabag-v1-read.json');
$entryRepo = $this->getMockBuilder('Wallabag\CoreBundle\Repository\EntryRepository')

View file

@ -18,7 +18,7 @@ class WallabagV2ImportTest extends \PHPUnit_Framework_TestCase
protected $logHandler;
protected $contentProxy;
private function getWallabagV2Import($unsetUser = false)
private function getWallabagV2Import($unsetUser = false, $dispatched = 0)
{
$this->user = new User();
@ -44,7 +44,15 @@ class WallabagV2ImportTest extends \PHPUnit_Framework_TestCase
->disableOriginalConstructor()
->getMock();
$wallabag = new WallabagV2Import($this->em, $this->contentProxy);
$dispatcher = $this->getMockBuilder('Symfony\Component\EventDispatcher\EventDispatcher')
->disableOriginalConstructor()
->getMock();
$dispatcher
->expects($this->exactly($dispatched))
->method('dispatch');
$wallabag = new WallabagV2Import($this->em, $this->contentProxy, $dispatcher);
$this->logHandler = new TestHandler();
$logger = new Logger('test', [$this->logHandler]);
@ -68,7 +76,7 @@ class WallabagV2ImportTest extends \PHPUnit_Framework_TestCase
public function testImport()
{
$wallabagV2Import = $this->getWallabagV2Import();
$wallabagV2Import = $this->getWallabagV2Import(false, 2);
$wallabagV2Import->setFilepath(__DIR__.'/../fixtures/wallabag-v2.json');
$entryRepo = $this->getMockBuilder('Wallabag\CoreBundle\Repository\EntryRepository')
@ -97,7 +105,7 @@ class WallabagV2ImportTest extends \PHPUnit_Framework_TestCase
public function testImportAndMarkAllAsRead()
{
$wallabagV2Import = $this->getWallabagV2Import();
$wallabagV2Import = $this->getWallabagV2Import(false, 2);
$wallabagV2Import->setFilepath(__DIR__.'/../fixtures/wallabag-v2-read.json');
$entryRepo = $this->getMockBuilder('Wallabag\CoreBundle\Repository\EntryRepository')
@ -246,7 +254,7 @@ class WallabagV2ImportTest extends \PHPUnit_Framework_TestCase
public function testImportWithExceptionFromGraby()
{
$wallabagV2Import = $this->getWallabagV2Import();
$wallabagV2Import = $this->getWallabagV2Import(false, 2);
$wallabagV2Import->setFilepath(__DIR__.'/../fixtures/wallabag-v2.json');
$entryRepo = $this->getMockBuilder('Wallabag\CoreBundle\Repository\EntryRepository')