mirror of
https://github.com/wallabag/wallabag.git
synced 2025-08-01 17:38:38 +00:00
Merge remote-tracking branch 'origin/master' into 2.1
This commit is contained in:
commit
79efca1e6f
45 changed files with 494 additions and 153 deletions
|
@ -28,16 +28,32 @@ class InstallCommandTest extends WallabagCoreTestCase
|
|||
*
|
||||
* http://stackoverflow.com/a/14374832/569101
|
||||
*/
|
||||
$this->markTestSkipped('PostgreSQL spotted: can find a good way to drop current database, skipping.');
|
||||
$this->markTestSkipped('PostgreSQL spotted: can\'t find a good way to drop current database, skipping.');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Ensure next tests will have a clean database
|
||||
*/
|
||||
public static function tearDownAfterClass()
|
||||
{
|
||||
$application = new Application(static::$kernel);
|
||||
$application->setAutoExit(false);
|
||||
|
||||
$code = $application->run(new ArrayInput([
|
||||
$application->run(new ArrayInput([
|
||||
'command' => 'doctrine:schema:drop',
|
||||
'--no-interaction' => true,
|
||||
'--force' => true,
|
||||
'--env' => 'test',
|
||||
]), new NullOutput());
|
||||
|
||||
$application->run(new ArrayInput([
|
||||
'command' => 'doctrine:schema:create',
|
||||
'--no-interaction' => true,
|
||||
'--env' => 'test',
|
||||
]), new NullOutput());
|
||||
|
||||
$application->run(new ArrayInput([
|
||||
'command' => 'doctrine:fixtures:load',
|
||||
'--no-interaction' => true,
|
||||
'--env' => 'test',
|
||||
|
|
|
@ -390,4 +390,55 @@ class PocketImportTest extends \PHPUnit_Framework_TestCase
|
|||
$this->assertContains('PocketImport: Failed to import', $records[0]['message']);
|
||||
$this->assertEquals('ERROR', $records[0]['level_name']);
|
||||
}
|
||||
|
||||
public function testImportWithExceptionFromGraby()
|
||||
{
|
||||
$client = new Client();
|
||||
|
||||
$mock = new Mock([
|
||||
new Response(200, ['Content-Type' => 'application/json'], Stream::factory(json_encode(['access_token' => 'wunderbar_token']))),
|
||||
new Response(200, ['Content-Type' => 'application/json'], Stream::factory('
|
||||
{
|
||||
"status": 1,
|
||||
"list": {
|
||||
"229279689": {
|
||||
"resolved_url": "http://www.grantland.com/blog/the-triangle/post/_/id/38347/ryder-cup-preview"
|
||||
}
|
||||
}
|
||||
}
|
||||
')),
|
||||
]);
|
||||
|
||||
$client->getEmitter()->attach($mock);
|
||||
|
||||
$pocketImport = $this->getPocketImport();
|
||||
|
||||
$entryRepo = $this->getMockBuilder('Wallabag\CoreBundle\Repository\EntryRepository')
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
|
||||
$entryRepo->expects($this->once())
|
||||
->method('findByUrlAndUserId')
|
||||
->will($this->onConsecutiveCalls(false, true));
|
||||
|
||||
$this->em
|
||||
->expects($this->once())
|
||||
->method('getRepository')
|
||||
->willReturn($entryRepo);
|
||||
|
||||
$entry = new Entry($this->user);
|
||||
|
||||
$this->contentProxy
|
||||
->expects($this->once())
|
||||
->method('updateEntry')
|
||||
->will($this->throwException(new \Exception()));
|
||||
|
||||
$pocketImport->setClient($client);
|
||||
$pocketImport->authorize('wunderbar_code');
|
||||
|
||||
$res = $pocketImport->import();
|
||||
|
||||
$this->assertTrue($res);
|
||||
$this->assertEquals(['skipped' => 1, 'imported' => 0], $pocketImport->getSummary());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -143,4 +143,44 @@ class WallabagV2ImportTest extends \PHPUnit_Framework_TestCase
|
|||
$this->assertContains('WallabagImport: user is not defined', $records[0]['message']);
|
||||
$this->assertEquals('ERROR', $records[0]['level_name']);
|
||||
}
|
||||
|
||||
public function testImportEmptyFile()
|
||||
{
|
||||
$wallabagV2Import = $this->getWallabagV2Import();
|
||||
$wallabagV2Import->setFilepath(__DIR__.'/../fixtures/wallabag-v2-empty.json');
|
||||
|
||||
$res = $wallabagV2Import->import();
|
||||
|
||||
$this->assertFalse($res);
|
||||
$this->assertEquals(['skipped' => 0, 'imported' => 0], $wallabagV2Import->getSummary());
|
||||
}
|
||||
|
||||
public function testImportWithExceptionFromGraby()
|
||||
{
|
||||
$wallabagV2Import = $this->getWallabagV2Import();
|
||||
$wallabagV2Import->setFilepath(__DIR__.'/../fixtures/wallabag-v2.json');
|
||||
|
||||
$entryRepo = $this->getMockBuilder('Wallabag\CoreBundle\Repository\EntryRepository')
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
|
||||
$entryRepo->expects($this->exactly(24))
|
||||
->method('findByUrlAndUserId')
|
||||
->will($this->onConsecutiveCalls(false, true, false));
|
||||
|
||||
$this->em
|
||||
->expects($this->any())
|
||||
->method('getRepository')
|
||||
->willReturn($entryRepo);
|
||||
|
||||
$this->contentProxy
|
||||
->expects($this->exactly(2))
|
||||
->method('updateEntry')
|
||||
->will($this->throwException(new \Exception()));
|
||||
|
||||
$res = $wallabagV2Import->import();
|
||||
|
||||
$this->assertTrue($res);
|
||||
$this->assertEquals(['skipped' => 24, 'imported' => 0], $wallabagV2Import->getSummary());
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue