diff options
author | Thomas Citharel <tcit@tcit.fr> | 2016-08-20 14:31:32 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-08-20 14:31:32 +0200 |
commit | 8642f14220a834a434225d812e2ea07680b04cb2 (patch) | |
tree | 325d2724ae5e5988b2ab77a33cf3f4cfe88c3647 /tests/Wallabag/ImportBundle/Import/PocketImportTest.php | |
parent | e408d7e895e784271a55c3a200666034db0af80a (diff) | |
parent | 19d9efab32b5c6403e9ee95fb70a2ce56a27f14b (diff) | |
download | wallabag-8642f14220a834a434225d812e2ea07680b04cb2.tar.gz wallabag-8642f14220a834a434225d812e2ea07680b04cb2.tar.zst wallabag-8642f14220a834a434225d812e2ea07680b04cb2.zip |
Merge pull request #2224 from wallabag/avoid-exception-import
Avoid breaking import when fetching fail
Diffstat (limited to 'tests/Wallabag/ImportBundle/Import/PocketImportTest.php')
-rw-r--r-- | tests/Wallabag/ImportBundle/Import/PocketImportTest.php | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/tests/Wallabag/ImportBundle/Import/PocketImportTest.php b/tests/Wallabag/ImportBundle/Import/PocketImportTest.php index 41f9b51f..8534e1c8 100644 --- a/tests/Wallabag/ImportBundle/Import/PocketImportTest.php +++ b/tests/Wallabag/ImportBundle/Import/PocketImportTest.php | |||
@@ -390,4 +390,55 @@ class PocketImportTest extends \PHPUnit_Framework_TestCase | |||
390 | $this->assertContains('PocketImport: Failed to import', $records[0]['message']); | 390 | $this->assertContains('PocketImport: Failed to import', $records[0]['message']); |
391 | $this->assertEquals('ERROR', $records[0]['level_name']); | 391 | $this->assertEquals('ERROR', $records[0]['level_name']); |
392 | } | 392 | } |
393 | |||
394 | public function testImportWithExceptionFromGraby() | ||
395 | { | ||
396 | $client = new Client(); | ||
397 | |||
398 | $mock = new Mock([ | ||
399 | new Response(200, ['Content-Type' => 'application/json'], Stream::factory(json_encode(['access_token' => 'wunderbar_token']))), | ||
400 | new Response(200, ['Content-Type' => 'application/json'], Stream::factory(' | ||
401 | { | ||
402 | "status": 1, | ||
403 | "list": { | ||
404 | "229279689": { | ||
405 | "resolved_url": "http://www.grantland.com/blog/the-triangle/post/_/id/38347/ryder-cup-preview" | ||
406 | } | ||
407 | } | ||
408 | } | ||
409 | ')), | ||
410 | ]); | ||
411 | |||
412 | $client->getEmitter()->attach($mock); | ||
413 | |||
414 | $pocketImport = $this->getPocketImport(); | ||
415 | |||
416 | $entryRepo = $this->getMockBuilder('Wallabag\CoreBundle\Repository\EntryRepository') | ||
417 | ->disableOriginalConstructor() | ||
418 | ->getMock(); | ||
419 | |||
420 | $entryRepo->expects($this->once()) | ||
421 | ->method('findByUrlAndUserId') | ||
422 | ->will($this->onConsecutiveCalls(false, true)); | ||
423 | |||
424 | $this->em | ||
425 | ->expects($this->once()) | ||
426 | ->method('getRepository') | ||
427 | ->willReturn($entryRepo); | ||
428 | |||
429 | $entry = new Entry($this->user); | ||
430 | |||
431 | $this->contentProxy | ||
432 | ->expects($this->once()) | ||
433 | ->method('updateEntry') | ||
434 | ->will($this->throwException(new \Exception())); | ||
435 | |||
436 | $pocketImport->setClient($client); | ||
437 | $pocketImport->authorize('wunderbar_code'); | ||
438 | |||
439 | $res = $pocketImport->import(); | ||
440 | |||
441 | $this->assertTrue($res); | ||
442 | $this->assertEquals(['skipped' => 1, 'imported' => 0], $pocketImport->getSummary()); | ||
443 | } | ||
393 | } | 444 | } |