diff options
author | Jérémy Benoist <j0k3r@users.noreply.github.com> | 2019-05-29 11:14:00 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-05-29 11:14:00 +0200 |
commit | 73ec68b1ffafb792265a3805833e5cd84c966aed (patch) | |
tree | 33c6040c050f85c537f8dbf5e91d8c281db092cd /tests/Wallabag/ImportBundle | |
parent | 2ba365c7c49556cd23b444dc3bb8d4a8cf08809d (diff) | |
parent | 2cbee36a0184786644470a84fdd8c720cfcac58e (diff) | |
download | wallabag-73ec68b1ffafb792265a3805833e5cd84c966aed.tar.gz wallabag-73ec68b1ffafb792265a3805833e5cd84c966aed.tar.zst wallabag-73ec68b1ffafb792265a3805833e5cd84c966aed.zip |
Merge pull request #3984 from wallabag/2.4
Merge 2.4 into master
Diffstat (limited to 'tests/Wallabag/ImportBundle')
11 files changed, 196 insertions, 236 deletions
diff --git a/tests/Wallabag/ImportBundle/Command/ImportCommandTest.php b/tests/Wallabag/ImportBundle/Command/ImportCommandTest.php index f95320a4..8e1c528d 100644 --- a/tests/Wallabag/ImportBundle/Command/ImportCommandTest.php +++ b/tests/Wallabag/ImportBundle/Command/ImportCommandTest.php | |||
@@ -84,6 +84,8 @@ class ImportCommandTest extends WallabagCoreTestCase | |||
84 | 84 | ||
85 | public function testRunImportCommandWithUserId() | 85 | public function testRunImportCommandWithUserId() |
86 | { | 86 | { |
87 | $this->logInAs('admin'); | ||
88 | |||
87 | $application = new Application($this->getClient()->getKernel()); | 89 | $application = new Application($this->getClient()->getKernel()); |
88 | $application->add(new ImportCommand()); | 90 | $application->add(new ImportCommand()); |
89 | 91 | ||
@@ -92,7 +94,7 @@ class ImportCommandTest extends WallabagCoreTestCase | |||
92 | $tester = new CommandTester($command); | 94 | $tester = new CommandTester($command); |
93 | $tester->execute([ | 95 | $tester->execute([ |
94 | 'command' => $command->getName(), | 96 | 'command' => $command->getName(), |
95 | 'username' => 1, | 97 | 'username' => $this->getLoggedInUserId(), |
96 | 'filepath' => $application->getKernel()->getContainer()->getParameter('kernel.project_dir') . '/tests/Wallabag/ImportBundle/fixtures/wallabag-v2-read.json', | 98 | 'filepath' => $application->getKernel()->getContainer()->getParameter('kernel.project_dir') . '/tests/Wallabag/ImportBundle/fixtures/wallabag-v2-read.json', |
97 | '--useUserId' => true, | 99 | '--useUserId' => true, |
98 | '--importer' => 'v2', | 100 | '--importer' => 'v2', |
diff --git a/tests/Wallabag/ImportBundle/Consumer/AMQPEntryConsumerTest.php b/tests/Wallabag/ImportBundle/Consumer/AMQPEntryConsumerTest.php index b2141c04..b7f6192d 100644 --- a/tests/Wallabag/ImportBundle/Consumer/AMQPEntryConsumerTest.php +++ b/tests/Wallabag/ImportBundle/Consumer/AMQPEntryConsumerTest.php | |||
@@ -1,6 +1,6 @@ | |||
1 | <?php | 1 | <?php |
2 | 2 | ||
3 | namespace Tests\Wallabag\ImportBundle\Consumer\AMQP; | 3 | namespace Tests\Wallabag\ImportBundle\Consumer; |
4 | 4 | ||
5 | use PhpAmqpLib\Message\AMQPMessage; | 5 | use PhpAmqpLib\Message\AMQPMessage; |
6 | use PHPUnit\Framework\TestCase; | 6 | use PHPUnit\Framework\TestCase; |
diff --git a/tests/Wallabag/ImportBundle/Consumer/RedisEntryConsumerTest.php b/tests/Wallabag/ImportBundle/Consumer/RedisEntryConsumerTest.php index 61337e47..e1bd8827 100644 --- a/tests/Wallabag/ImportBundle/Consumer/RedisEntryConsumerTest.php +++ b/tests/Wallabag/ImportBundle/Consumer/RedisEntryConsumerTest.php | |||
@@ -1,6 +1,6 @@ | |||
1 | <?php | 1 | <?php |
2 | 2 | ||
3 | namespace Tests\Wallabag\ImportBundle\Consumer\AMQP; | 3 | namespace Tests\Wallabag\ImportBundle\Consumer; |
4 | 4 | ||
5 | use PHPUnit\Framework\TestCase; | 5 | use PHPUnit\Framework\TestCase; |
6 | use Wallabag\CoreBundle\Entity\Entry; | 6 | use Wallabag\CoreBundle\Entity\Entry; |
diff --git a/tests/Wallabag/ImportBundle/Controller/ChromeControllerTest.php b/tests/Wallabag/ImportBundle/Controller/ChromeControllerTest.php index cd3e41e9..d3ffbb6d 100644 --- a/tests/Wallabag/ImportBundle/Controller/ChromeControllerTest.php +++ b/tests/Wallabag/ImportBundle/Controller/ChromeControllerTest.php | |||
@@ -121,7 +121,7 @@ class ChromeControllerTest extends WallabagCoreTestCase | |||
121 | $this->assertInstanceOf('Wallabag\CoreBundle\Entity\Entry', $content); | 121 | $this->assertInstanceOf('Wallabag\CoreBundle\Entity\Entry', $content); |
122 | $this->assertNotEmpty($content->getPreviewPicture(), 'Preview picture for http://www.usinenouvelle.com is ok'); | 122 | $this->assertNotEmpty($content->getPreviewPicture(), 'Preview picture for http://www.usinenouvelle.com is ok'); |
123 | $this->assertNotEmpty($content->getLanguage(), 'Language for http://www.usinenouvelle.com is ok'); | 123 | $this->assertNotEmpty($content->getLanguage(), 'Language for http://www.usinenouvelle.com is ok'); |
124 | $this->assertSame(1, \count($content->getTags())); | 124 | $this->assertCount(1, $content->getTags()); |
125 | 125 | ||
126 | $createdAt = $content->getCreatedAt(); | 126 | $createdAt = $content->getCreatedAt(); |
127 | $this->assertSame('2011', $createdAt->format('Y')); | 127 | $this->assertSame('2011', $createdAt->format('Y')); |
diff --git a/tests/Wallabag/ImportBundle/Controller/FirefoxControllerTest.php b/tests/Wallabag/ImportBundle/Controller/FirefoxControllerTest.php index dc5ed6d0..3e64f2e5 100644 --- a/tests/Wallabag/ImportBundle/Controller/FirefoxControllerTest.php +++ b/tests/Wallabag/ImportBundle/Controller/FirefoxControllerTest.php | |||
@@ -122,7 +122,7 @@ class FirefoxControllerTest extends WallabagCoreTestCase | |||
122 | $this->assertNotEmpty($content->getMimetype(), 'Mimetype for http://lexpansion.lexpress.fr is ok'); | 122 | $this->assertNotEmpty($content->getMimetype(), 'Mimetype for http://lexpansion.lexpress.fr is ok'); |
123 | $this->assertNotEmpty($content->getPreviewPicture(), 'Preview picture for http://lexpansion.lexpress.fr is ok'); | 123 | $this->assertNotEmpty($content->getPreviewPicture(), 'Preview picture for http://lexpansion.lexpress.fr is ok'); |
124 | $this->assertNotEmpty($content->getLanguage(), 'Language for http://lexpansion.lexpress.fr is ok'); | 124 | $this->assertNotEmpty($content->getLanguage(), 'Language for http://lexpansion.lexpress.fr is ok'); |
125 | $this->assertSame(3, \count($content->getTags())); | 125 | $this->assertCount(3, $content->getTags()); |
126 | 126 | ||
127 | $content = $client->getContainer() | 127 | $content = $client->getContainer() |
128 | ->get('doctrine.orm.entity_manager') | 128 | ->get('doctrine.orm.entity_manager') |
diff --git a/tests/Wallabag/ImportBundle/Controller/InstapaperControllerTest.php b/tests/Wallabag/ImportBundle/Controller/InstapaperControllerTest.php index 7390fa88..05347767 100644 --- a/tests/Wallabag/ImportBundle/Controller/InstapaperControllerTest.php +++ b/tests/Wallabag/ImportBundle/Controller/InstapaperControllerTest.php | |||
@@ -124,7 +124,7 @@ class InstapaperControllerTest extends WallabagCoreTestCase | |||
124 | $this->assertNotEmpty($content->getPreviewPicture(), 'Preview picture for https://www.liberation.fr is ok'); | 124 | $this->assertNotEmpty($content->getPreviewPicture(), 'Preview picture for https://www.liberation.fr is ok'); |
125 | $this->assertNotEmpty($content->getLanguage(), 'Language for https://www.liberation.fr is ok'); | 125 | $this->assertNotEmpty($content->getLanguage(), 'Language for https://www.liberation.fr is ok'); |
126 | $this->assertContains('foot', $content->getTags(), 'It includes the "foot" tag'); | 126 | $this->assertContains('foot', $content->getTags(), 'It includes the "foot" tag'); |
127 | $this->assertSame(1, \count($content->getTags())); | 127 | $this->assertCount(1, $content->getTags()); |
128 | $this->assertInstanceOf(\DateTime::class, $content->getCreatedAt()); | 128 | $this->assertInstanceOf(\DateTime::class, $content->getCreatedAt()); |
129 | 129 | ||
130 | $content = $client->getContainer() | 130 | $content = $client->getContainer() |
@@ -138,7 +138,7 @@ class InstapaperControllerTest extends WallabagCoreTestCase | |||
138 | $this->assertContains('foot', $content->getTags()); | 138 | $this->assertContains('foot', $content->getTags()); |
139 | $this->assertContains('test_tag', $content->getTags()); | 139 | $this->assertContains('test_tag', $content->getTags()); |
140 | 140 | ||
141 | $this->assertSame(2, \count($content->getTags())); | 141 | $this->assertCount(2, $content->getTags()); |
142 | } | 142 | } |
143 | 143 | ||
144 | public function testImportInstapaperWithFileAndMarkAllAsRead() | 144 | public function testImportInstapaperWithFileAndMarkAllAsRead() |
diff --git a/tests/Wallabag/ImportBundle/Controller/PinboardControllerTest.php b/tests/Wallabag/ImportBundle/Controller/PinboardControllerTest.php index 80819f45..15646d55 100644 --- a/tests/Wallabag/ImportBundle/Controller/PinboardControllerTest.php +++ b/tests/Wallabag/ImportBundle/Controller/PinboardControllerTest.php | |||
@@ -127,7 +127,7 @@ class PinboardControllerTest extends WallabagCoreTestCase | |||
127 | $this->assertContains('foot', $tags, 'It includes the "foot" tag'); | 127 | $this->assertContains('foot', $tags, 'It includes the "foot" tag'); |
128 | $this->assertContains('varnish', $tags, 'It includes the "varnish" tag'); | 128 | $this->assertContains('varnish', $tags, 'It includes the "varnish" tag'); |
129 | $this->assertContains('php', $tags, 'It includes the "php" tag'); | 129 | $this->assertContains('php', $tags, 'It includes the "php" tag'); |
130 | $this->assertSame(3, \count($tags)); | 130 | $this->assertCount(3, $tags); |
131 | 131 | ||
132 | $this->assertInstanceOf(\DateTime::class, $content->getCreatedAt()); | 132 | $this->assertInstanceOf(\DateTime::class, $content->getCreatedAt()); |
133 | $this->assertSame('2016-10-26', $content->getCreatedAt()->format('Y-m-d')); | 133 | $this->assertSame('2016-10-26', $content->getCreatedAt()->format('Y-m-d')); |
diff --git a/tests/Wallabag/ImportBundle/Controller/ReadabilityControllerTest.php b/tests/Wallabag/ImportBundle/Controller/ReadabilityControllerTest.php index 5619659a..4f2f4053 100644 --- a/tests/Wallabag/ImportBundle/Controller/ReadabilityControllerTest.php +++ b/tests/Wallabag/ImportBundle/Controller/ReadabilityControllerTest.php | |||
@@ -125,7 +125,7 @@ class ReadabilityControllerTest extends WallabagCoreTestCase | |||
125 | 125 | ||
126 | $tags = $content->getTags(); | 126 | $tags = $content->getTags(); |
127 | $this->assertContains('foot', $tags, 'It includes the "foot" tag'); | 127 | $this->assertContains('foot', $tags, 'It includes the "foot" tag'); |
128 | $this->assertSame(1, \count($tags)); | 128 | $this->assertCount(1, $tags); |
129 | 129 | ||
130 | $this->assertInstanceOf(\DateTime::class, $content->getCreatedAt()); | 130 | $this->assertInstanceOf(\DateTime::class, $content->getCreatedAt()); |
131 | $this->assertSame('2016-09-08', $content->getCreatedAt()->format('Y-m-d')); | 131 | $this->assertSame('2016-09-08', $content->getCreatedAt()->format('Y-m-d')); |
diff --git a/tests/Wallabag/ImportBundle/Controller/WallabagV1ControllerTest.php b/tests/Wallabag/ImportBundle/Controller/WallabagV1ControllerTest.php index c67941a7..2a8e7c89 100644 --- a/tests/Wallabag/ImportBundle/Controller/WallabagV1ControllerTest.php +++ b/tests/Wallabag/ImportBundle/Controller/WallabagV1ControllerTest.php | |||
@@ -121,13 +121,13 @@ class WallabagV1ControllerTest extends WallabagCoreTestCase | |||
121 | 121 | ||
122 | $this->assertInstanceOf('Wallabag\CoreBundle\Entity\Entry', $content); | 122 | $this->assertInstanceOf('Wallabag\CoreBundle\Entity\Entry', $content); |
123 | $this->assertEmpty($content->getMimetype(), 'Mimetype for http://www.framablog.org is empty'); | 123 | $this->assertEmpty($content->getMimetype(), 'Mimetype for http://www.framablog.org is empty'); |
124 | $this->assertEmpty($content->getPreviewPicture(), 'Preview picture for http://www.framablog.org is empty'); | 124 | $this->assertSame($content->getPreviewPicture(), 'http://www.framablog.org/public/_img/framablog/wallaby_baby.jpg'); |
125 | $this->assertEmpty($content->getLanguage(), 'Language for http://www.framablog.org is empty'); | 125 | $this->assertEmpty($content->getLanguage(), 'Language for http://www.framablog.org is empty'); |
126 | 126 | ||
127 | $tags = $content->getTags(); | 127 | $tags = $content->getTags(); |
128 | $this->assertContains('foot', $tags, 'It includes the "foot" tag'); | 128 | $this->assertContains('foot', $tags, 'It includes the "foot" tag'); |
129 | $this->assertContains('framabag', $tags, 'It includes the "framabag" tag'); | 129 | $this->assertContains('framabag', $tags, 'It includes the "framabag" tag'); |
130 | $this->assertSame(2, \count($tags)); | 130 | $this->assertCount(2, $tags); |
131 | 131 | ||
132 | $this->assertInstanceOf(\DateTime::class, $content->getCreatedAt()); | 132 | $this->assertInstanceOf(\DateTime::class, $content->getCreatedAt()); |
133 | } | 133 | } |
diff --git a/tests/Wallabag/ImportBundle/Controller/WallabagV2ControllerTest.php b/tests/Wallabag/ImportBundle/Controller/WallabagV2ControllerTest.php index 822656ba..b606e26a 100644 --- a/tests/Wallabag/ImportBundle/Controller/WallabagV2ControllerTest.php +++ b/tests/Wallabag/ImportBundle/Controller/WallabagV2ControllerTest.php | |||
@@ -128,7 +128,7 @@ class WallabagV2ControllerTest extends WallabagCoreTestCase | |||
128 | 128 | ||
129 | $tags = $content->getTags(); | 129 | $tags = $content->getTags(); |
130 | $this->assertContains('foot', $tags, 'It includes the "foot" tag'); | 130 | $this->assertContains('foot', $tags, 'It includes the "foot" tag'); |
131 | $this->assertSame(1, \count($tags)); | 131 | $this->assertCount(1, $tags); |
132 | 132 | ||
133 | $content = $client->getContainer() | 133 | $content = $client->getContainer() |
134 | ->get('doctrine.orm.entity_manager') | 134 | ->get('doctrine.orm.entity_manager') |
@@ -147,7 +147,7 @@ class WallabagV2ControllerTest extends WallabagCoreTestCase | |||
147 | $this->assertContains('foot', $tags, 'It includes the "foot" tag'); | 147 | $this->assertContains('foot', $tags, 'It includes the "foot" tag'); |
148 | $this->assertContains('mediapart', $tags, 'It includes the "mediapart" tag'); | 148 | $this->assertContains('mediapart', $tags, 'It includes the "mediapart" tag'); |
149 | $this->assertContains('blog', $tags, 'It includes the "blog" tag'); | 149 | $this->assertContains('blog', $tags, 'It includes the "blog" tag'); |
150 | $this->assertSame(3, \count($tags)); | 150 | $this->assertCount(3, $tags); |
151 | 151 | ||
152 | $this->assertInstanceOf(\DateTime::class, $content->getCreatedAt()); | 152 | $this->assertInstanceOf(\DateTime::class, $content->getCreatedAt()); |
153 | $this->assertSame('2016-09-08', $content->getCreatedAt()->format('Y-m-d')); | 153 | $this->assertSame('2016-09-08', $content->getCreatedAt()->format('Y-m-d')); |
diff --git a/tests/Wallabag/ImportBundle/Import/PocketImportTest.php b/tests/Wallabag/ImportBundle/Import/PocketImportTest.php index 8083f1a8..40e1626b 100644 --- a/tests/Wallabag/ImportBundle/Import/PocketImportTest.php +++ b/tests/Wallabag/ImportBundle/Import/PocketImportTest.php | |||
@@ -2,10 +2,8 @@ | |||
2 | 2 | ||
3 | namespace Tests\Wallabag\ImportBundle\Import; | 3 | namespace Tests\Wallabag\ImportBundle\Import; |
4 | 4 | ||
5 | use GuzzleHttp\Client; | 5 | use GuzzleHttp\Psr7\Response; |
6 | use GuzzleHttp\Message\Response; | 6 | use Http\Mock\Client as HttpMockClient; |
7 | use GuzzleHttp\Stream\Stream; | ||
8 | use GuzzleHttp\Subscriber\Mock; | ||
9 | use M6Web\Component\RedisMock\RedisMockFactory; | 7 | use M6Web\Component\RedisMock\RedisMockFactory; |
10 | use Monolog\Handler\TestHandler; | 8 | use Monolog\Handler\TestHandler; |
11 | use Monolog\Logger; | 9 | use Monolog\Logger; |
@@ -38,16 +36,11 @@ class PocketImportTest extends TestCase | |||
38 | 36 | ||
39 | public function testOAuthRequest() | 37 | public function testOAuthRequest() |
40 | { | 38 | { |
41 | $client = new Client(); | 39 | $httpMockClient = new HttpMockClient(); |
42 | 40 | $httpMockClient->addResponse(new Response(200, ['Content-Type' => 'application/json'], json_encode(['code' => 'wunderbar_code']))); | |
43 | $mock = new Mock([ | ||
44 | new Response(200, ['Content-Type' => 'application/json'], Stream::factory(json_encode(['code' => 'wunderbar_code']))), | ||
45 | ]); | ||
46 | |||
47 | $client->getEmitter()->attach($mock); | ||
48 | 41 | ||
49 | $pocketImport = $this->getPocketImport(); | 42 | $pocketImport = $this->getPocketImport(); |
50 | $pocketImport->setClient($client); | 43 | $pocketImport->setClient($httpMockClient); |
51 | 44 | ||
52 | $code = $pocketImport->getRequestToken('http://0.0.0.0/redirect'); | 45 | $code = $pocketImport->getRequestToken('http://0.0.0.0/redirect'); |
53 | 46 | ||
@@ -56,16 +49,11 @@ class PocketImportTest extends TestCase | |||
56 | 49 | ||
57 | public function testOAuthRequestBadResponse() | 50 | public function testOAuthRequestBadResponse() |
58 | { | 51 | { |
59 | $client = new Client(); | 52 | $httpMockClient = new HttpMockClient(); |
60 | 53 | $httpMockClient->addResponse(new Response(403)); | |
61 | $mock = new Mock([ | ||
62 | new Response(403), | ||
63 | ]); | ||
64 | |||
65 | $client->getEmitter()->attach($mock); | ||
66 | 54 | ||
67 | $pocketImport = $this->getPocketImport(); | 55 | $pocketImport = $this->getPocketImport(); |
68 | $pocketImport->setClient($client); | 56 | $pocketImport->setClient($httpMockClient); |
69 | 57 | ||
70 | $code = $pocketImport->getRequestToken('http://0.0.0.0/redirect'); | 58 | $code = $pocketImport->getRequestToken('http://0.0.0.0/redirect'); |
71 | 59 | ||
@@ -78,16 +66,11 @@ class PocketImportTest extends TestCase | |||
78 | 66 | ||
79 | public function testOAuthAuthorize() | 67 | public function testOAuthAuthorize() |
80 | { | 68 | { |
81 | $client = new Client(); | 69 | $httpMockClient = new HttpMockClient(); |
82 | 70 | $httpMockClient->addResponse(new Response(200, ['Content-Type' => 'application/json'], json_encode(['access_token' => 'wunderbar_token']))); | |
83 | $mock = new Mock([ | ||
84 | new Response(200, ['Content-Type' => 'application/json'], Stream::factory(json_encode(['access_token' => 'wunderbar_token']))), | ||
85 | ]); | ||
86 | |||
87 | $client->getEmitter()->attach($mock); | ||
88 | 71 | ||
89 | $pocketImport = $this->getPocketImport(); | 72 | $pocketImport = $this->getPocketImport(); |
90 | $pocketImport->setClient($client); | 73 | $pocketImport->setClient($httpMockClient); |
91 | 74 | ||
92 | $res = $pocketImport->authorize('wunderbar_code'); | 75 | $res = $pocketImport->authorize('wunderbar_code'); |
93 | 76 | ||
@@ -97,16 +80,11 @@ class PocketImportTest extends TestCase | |||
97 | 80 | ||
98 | public function testOAuthAuthorizeBadResponse() | 81 | public function testOAuthAuthorizeBadResponse() |
99 | { | 82 | { |
100 | $client = new Client(); | 83 | $httpMockClient = new HttpMockClient(); |
101 | 84 | $httpMockClient->addResponse(new Response(403)); | |
102 | $mock = new Mock([ | ||
103 | new Response(403), | ||
104 | ]); | ||
105 | |||
106 | $client->getEmitter()->attach($mock); | ||
107 | 85 | ||
108 | $pocketImport = $this->getPocketImport(); | 86 | $pocketImport = $this->getPocketImport(); |
109 | $pocketImport->setClient($client); | 87 | $pocketImport->setClient($httpMockClient); |
110 | 88 | ||
111 | $res = $pocketImport->authorize('wunderbar_code'); | 89 | $res = $pocketImport->authorize('wunderbar_code'); |
112 | 90 | ||
@@ -122,94 +100,90 @@ class PocketImportTest extends TestCase | |||
122 | */ | 100 | */ |
123 | public function testImport() | 101 | public function testImport() |
124 | { | 102 | { |
125 | $client = new Client(); | 103 | $httpMockClient = new HttpMockClient(); |
126 | 104 | $httpMockClient->addResponse(new Response(200, ['Content-Type' => 'application/json'], json_encode(['access_token' => 'wunderbar_token']))); | |
127 | $mock = new Mock([ | 105 | $httpMockClient->addResponse(new Response(200, ['Content-Type' => 'application/json'], <<<'JSON' |
128 | new Response(200, ['Content-Type' => 'application/json'], Stream::factory(json_encode(['access_token' => 'wunderbar_token']))), | 106 | { |
129 | new Response(200, ['Content-Type' => 'application/json'], Stream::factory(' | 107 | "status": 1, |
130 | { | 108 | "list": { |
131 | "status": 1, | 109 | "229279689": { |
132 | "list": { | 110 | "item_id": "229279689", |
133 | "229279689": { | 111 | "resolved_id": "229279689", |
134 | "item_id": "229279689", | 112 | "given_url": "http://www.grantland.com/blog/the-triangle/post/_/id/38347/ryder-cup-preview", |
135 | "resolved_id": "229279689", | 113 | "given_title": "The Massive Ryder Cup Preview - The Triangle Blog - Grantland", |
136 | "given_url": "http://www.grantland.com/blog/the-triangle/post/_/id/38347/ryder-cup-preview", | 114 | "favorite": "1", |
137 | "given_title": "The Massive Ryder Cup Preview - The Triangle Blog - Grantland", | 115 | "status": "1", |
138 | "favorite": "1", | 116 | "time_added": "1473020899", |
139 | "status": "1", | 117 | "time_updated": "1473020899", |
140 | "time_added": "1473020899", | 118 | "time_read": "0", |
141 | "time_updated": "1473020899", | 119 | "time_favorited": "0", |
142 | "time_read": "0", | 120 | "sort_id": 0, |
143 | "time_favorited": "0", | 121 | "resolved_title": "The Massive Ryder Cup Preview", |
144 | "sort_id": 0, | 122 | "resolved_url": "http://www.grantland.com/blog/the-triangle/post/_/id/38347/ryder-cup-preview", |
145 | "resolved_title": "The Massive Ryder Cup Preview", | 123 | "excerpt": "The list of things I love about the Ryder Cup is so long that it could fill a (tedious) novel, and golf fans can probably guess most of them.", |
146 | "resolved_url": "http://www.grantland.com/blog/the-triangle/post/_/id/38347/ryder-cup-preview", | 124 | "is_article": "1", |
147 | "excerpt": "The list of things I love about the Ryder Cup is so long that it could fill a (tedious) novel, and golf fans can probably guess most of them.", | 125 | "is_index": "0", |
148 | "is_article": "1", | 126 | "has_video": "1", |
149 | "is_index": "0", | 127 | "has_image": "1", |
150 | "has_video": "1", | 128 | "word_count": "3197", |
151 | "has_image": "1", | 129 | "images": { |
152 | "word_count": "3197", | 130 | "1": { |
153 | "images": { | 131 | "item_id": "229279689", |
154 | "1": { | 132 | "image_id": "1", |
155 | "item_id": "229279689", | 133 | "src": "http://a.espncdn.com/combiner/i?img=/photo/2012/0927/grant_g_ryder_cr_640.jpg&w=640&h=360", |
156 | "image_id": "1", | 134 | "width": "0", |
157 | "src": "http://a.espncdn.com/combiner/i?img=/photo/2012/0927/grant_g_ryder_cr_640.jpg&w=640&h=360", | 135 | "height": "0", |
158 | "width": "0", | 136 | "credit": "Jamie Squire/Getty Images", |
159 | "height": "0", | 137 | "caption": "" |
160 | "credit": "Jamie Squire/Getty Images", | ||
161 | "caption": "" | ||
162 | } | ||
163 | }, | ||
164 | "videos": { | ||
165 | "1": { | ||
166 | "item_id": "229279689", | ||
167 | "video_id": "1", | ||
168 | "src": "http://www.youtube.com/v/Er34PbFkVGk?version=3&hl=en_US&rel=0", | ||
169 | "width": "420", | ||
170 | "height": "315", | ||
171 | "type": "1", | ||
172 | "vid": "Er34PbFkVGk" | ||
173 | } | ||
174 | }, | ||
175 | "tags": { | ||
176 | "grantland": { | ||
177 | "item_id": "1147652870", | ||
178 | "tag": "grantland" | ||
179 | }, | ||
180 | "Ryder Cup": { | ||
181 | "item_id": "1147652870", | ||
182 | "tag": "Ryder Cup" | ||
183 | } | ||
184 | } | 138 | } |
185 | }, | 139 | }, |
186 | "229279690": { | 140 | "videos": { |
187 | "item_id": "229279689", | 141 | "1": { |
188 | "resolved_id": "229279689", | 142 | "item_id": "229279689", |
189 | "given_url": "http://www.grantland.com/blog/the-triangle/post/_/id/38347/ryder-cup-preview", | 143 | "video_id": "1", |
190 | "given_title": "The Massive Ryder Cup Preview - The Triangle Blog - Grantland", | 144 | "src": "http://www.youtube.com/v/Er34PbFkVGk?version=3&hl=en_US&rel=0", |
191 | "favorite": "1", | 145 | "width": "420", |
192 | "status": "1", | 146 | "height": "315", |
193 | "time_added": "1473020899", | 147 | "type": "1", |
194 | "time_updated": "1473020899", | 148 | "vid": "Er34PbFkVGk" |
195 | "time_read": "0", | 149 | } |
196 | "time_favorited": "0", | 150 | }, |
197 | "sort_id": 1, | 151 | "tags": { |
198 | "resolved_title": "The Massive Ryder Cup Preview", | 152 | "grantland": { |
199 | "resolved_url": "http://www.grantland.com/blog/the-triangle/post/_/id/38347/ryder-cup-preview", | 153 | "item_id": "1147652870", |
200 | "excerpt": "The list of things I love about the Ryder Cup is so long that it could fill a (tedious) novel, and golf fans can probably guess most of them.", | 154 | "tag": "grantland" |
201 | "is_article": "1", | 155 | }, |
202 | "is_index": "0", | 156 | "Ryder Cup": { |
203 | "has_video": "0", | 157 | "item_id": "1147652870", |
204 | "has_image": "0", | 158 | "tag": "Ryder Cup" |
205 | "word_count": "3197" | 159 | } |
206 | } | 160 | } |
161 | }, | ||
162 | "229279690": { | ||
163 | "item_id": "229279689", | ||
164 | "resolved_id": "229279689", | ||
165 | "given_url": "http://www.grantland.com/blog/the-triangle/post/_/id/38347/ryder-cup-preview", | ||
166 | "given_title": "The Massive Ryder Cup Preview - The Triangle Blog - Grantland", | ||
167 | "favorite": "1", | ||
168 | "status": "1", | ||
169 | "time_added": "1473020899", | ||
170 | "time_updated": "1473020899", | ||
171 | "time_read": "0", | ||
172 | "time_favorited": "0", | ||
173 | "sort_id": 1, | ||
174 | "resolved_title": "The Massive Ryder Cup Preview", | ||
175 | "resolved_url": "http://www.grantland.com/blog/the-triangle/post/_/id/38347/ryder-cup-preview", | ||
176 | "excerpt": "The list of things I love about the Ryder Cup is so long that it could fill a (tedious) novel, and golf fans can probably guess most of them.", | ||
177 | "is_article": "1", | ||
178 | "is_index": "0", | ||
179 | "has_video": "0", | ||
180 | "has_image": "0", | ||
181 | "word_count": "3197" | ||
207 | } | 182 | } |
208 | } | 183 | } |
209 | ')), | 184 | } |
210 | ]); | 185 | JSON |
211 | 186 | )); | |
212 | $client->getEmitter()->attach($mock); | ||
213 | 187 | ||
214 | $pocketImport = $this->getPocketImport('ConsumerKey', 1); | 188 | $pocketImport = $this->getPocketImport('ConsumerKey', 1); |
215 | 189 | ||
@@ -240,7 +214,7 @@ class PocketImportTest extends TestCase | |||
240 | ->method('updateEntry') | 214 | ->method('updateEntry') |
241 | ->willReturn($entry); | 215 | ->willReturn($entry); |
242 | 216 | ||
243 | $pocketImport->setClient($client); | 217 | $pocketImport->setClient($httpMockClient); |
244 | $pocketImport->authorize('wunderbar_code'); | 218 | $pocketImport->authorize('wunderbar_code'); |
245 | 219 | ||
246 | $res = $pocketImport->import(); | 220 | $res = $pocketImport->import(); |
@@ -254,56 +228,52 @@ class PocketImportTest extends TestCase | |||
254 | */ | 228 | */ |
255 | public function testImportAndMarkAllAsRead() | 229 | public function testImportAndMarkAllAsRead() |
256 | { | 230 | { |
257 | $client = new Client(); | 231 | $httpMockClient = new HttpMockClient(); |
258 | 232 | $httpMockClient->addResponse(new Response(200, ['Content-Type' => 'application/json'], json_encode(['access_token' => 'wunderbar_token']))); | |
259 | $mock = new Mock([ | 233 | $httpMockClient->addResponse(new Response(200, ['Content-Type' => 'application/json'], <<<'JSON' |
260 | new Response(200, ['Content-Type' => 'application/json'], Stream::factory(json_encode(['access_token' => 'wunderbar_token']))), | 234 | { |
261 | new Response(200, ['Content-Type' => 'application/json'], Stream::factory(' | 235 | "status": 1, |
262 | { | 236 | "list": { |
263 | "status": 1, | 237 | "229279689": { |
264 | "list": { | 238 | "item_id": "229279689", |
265 | "229279689": { | 239 | "resolved_id": "229279689", |
266 | "item_id": "229279689", | 240 | "given_url": "http://www.grantland.com/blog/the-triangle/post/_/id/38347/ryder-cup-preview", |
267 | "resolved_id": "229279689", | 241 | "given_title": "The Massive Ryder Cup Preview - The Triangle Blog - Grantland", |
268 | "given_url": "http://www.grantland.com/blog/the-triangle/post/_/id/38347/ryder-cup-preview", | 242 | "favorite": "1", |
269 | "given_title": "The Massive Ryder Cup Preview - The Triangle Blog - Grantland", | 243 | "status": "1", |
270 | "favorite": "1", | 244 | "time_added": "1473020899", |
271 | "status": "1", | 245 | "time_updated": "1473020899", |
272 | "time_added": "1473020899", | 246 | "time_read": "0", |
273 | "time_updated": "1473020899", | 247 | "time_favorited": "0", |
274 | "time_read": "0", | 248 | "sort_id": 0, |
275 | "time_favorited": "0", | 249 | "excerpt": "The list of things I love about the Ryder Cup is so long that it could fill a (tedious) novel, and golf fans can probably guess most of them.", |
276 | "sort_id": 0, | 250 | "is_article": "1", |
277 | "excerpt": "The list of things I love about the Ryder Cup is so long that it could fill a (tedious) novel, and golf fans can probably guess most of them.", | 251 | "has_video": "1", |
278 | "is_article": "1", | 252 | "has_image": "1", |
279 | "has_video": "1", | 253 | "word_count": "3197" |
280 | "has_image": "1", | 254 | }, |
281 | "word_count": "3197" | 255 | "229279690": { |
282 | }, | 256 | "item_id": "229279689", |
283 | "229279690": { | 257 | "resolved_id": "229279689", |
284 | "item_id": "229279689", | 258 | "given_url": "http://www.grantland.com/blog/the-triangle/post/_/id/38347/ryder-cup-preview/2", |
285 | "resolved_id": "229279689", | 259 | "given_title": "The Massive Ryder Cup Preview - The Triangle Blog - Grantland", |
286 | "given_url": "http://www.grantland.com/blog/the-triangle/post/_/id/38347/ryder-cup-preview/2", | 260 | "favorite": "1", |
287 | "given_title": "The Massive Ryder Cup Preview - The Triangle Blog - Grantland", | 261 | "status": "0", |
288 | "favorite": "1", | 262 | "time_added": "1473020899", |
289 | "status": "0", | 263 | "time_updated": "1473020899", |
290 | "time_added": "1473020899", | 264 | "time_read": "0", |
291 | "time_updated": "1473020899", | 265 | "time_favorited": "0", |
292 | "time_read": "0", | 266 | "sort_id": 1, |
293 | "time_favorited": "0", | 267 | "excerpt": "The list of things I love about the Ryder Cup is so long that it could fill a (tedious) novel, and golf fans can probably guess most of them.", |
294 | "sort_id": 1, | 268 | "is_article": "1", |
295 | "excerpt": "The list of things I love about the Ryder Cup is so long that it could fill a (tedious) novel, and golf fans can probably guess most of them.", | 269 | "has_video": "0", |
296 | "is_article": "1", | 270 | "has_image": "0", |
297 | "has_video": "0", | 271 | "word_count": "3197" |
298 | "has_image": "0", | ||
299 | "word_count": "3197" | ||
300 | } | ||
301 | } | 272 | } |
302 | } | 273 | } |
303 | ')), | 274 | } |
304 | ]); | 275 | JSON |
305 | 276 | )); | |
306 | $client->getEmitter()->attach($mock); | ||
307 | 277 | ||
308 | $pocketImport = $this->getPocketImport('ConsumerKey', 2); | 278 | $pocketImport = $this->getPocketImport('ConsumerKey', 2); |
309 | 279 | ||
@@ -335,7 +305,7 @@ class PocketImportTest extends TestCase | |||
335 | ->method('updateEntry') | 305 | ->method('updateEntry') |
336 | ->willReturn($entry); | 306 | ->willReturn($entry); |
337 | 307 | ||
338 | $pocketImport->setClient($client); | 308 | $pocketImport->setClient($httpMockClient); |
339 | $pocketImport->authorize('wunderbar_code'); | 309 | $pocketImport->authorize('wunderbar_code'); |
340 | 310 | ||
341 | $res = $pocketImport->setMarkAsRead(true)->import(); | 311 | $res = $pocketImport->setMarkAsRead(true)->import(); |
@@ -349,7 +319,7 @@ class PocketImportTest extends TestCase | |||
349 | */ | 319 | */ |
350 | public function testImportWithRabbit() | 320 | public function testImportWithRabbit() |
351 | { | 321 | { |
352 | $client = new Client(); | 322 | $httpMockClient = new HttpMockClient(); |
353 | 323 | ||
354 | $body = <<<'JSON' | 324 | $body = <<<'JSON' |
355 | { | 325 | { |
@@ -374,19 +344,16 @@ class PocketImportTest extends TestCase | |||
374 | } | 344 | } |
375 | JSON; | 345 | JSON; |
376 | 346 | ||
377 | $mock = new Mock([ | 347 | $httpMockClient->addResponse(new Response(200, ['Content-Type' => 'application/json'], json_encode(['access_token' => 'wunderbar_token']))); |
378 | new Response(200, ['Content-Type' => 'application/json'], Stream::factory(json_encode(['access_token' => 'wunderbar_token']))), | 348 | $httpMockClient->addResponse(new Response(200, ['Content-Type' => 'application/json'], <<<JSON |
379 | new Response(200, ['Content-Type' => 'application/json'], Stream::factory(' | 349 | { |
380 | { | 350 | "status": 1, |
381 | "status": 1, | 351 | "list": { |
382 | "list": { | 352 | "229279690": $body |
383 | "229279690": ' . $body . ' | ||
384 | } | ||
385 | } | 353 | } |
386 | ')), | 354 | } |
387 | ]); | 355 | JSON |
388 | 356 | )); | |
389 | $client->getEmitter()->attach($mock); | ||
390 | 357 | ||
391 | $pocketImport = $this->getPocketImport(); | 358 | $pocketImport = $this->getPocketImport(); |
392 | 359 | ||
@@ -420,7 +387,7 @@ JSON; | |||
420 | ->method('publish') | 387 | ->method('publish') |
421 | ->with(json_encode($bodyAsArray)); | 388 | ->with(json_encode($bodyAsArray)); |
422 | 389 | ||
423 | $pocketImport->setClient($client); | 390 | $pocketImport->setClient($httpMockClient); |
424 | $pocketImport->setProducer($producer); | 391 | $pocketImport->setProducer($producer); |
425 | $pocketImport->authorize('wunderbar_code'); | 392 | $pocketImport->authorize('wunderbar_code'); |
426 | 393 | ||
@@ -435,7 +402,7 @@ JSON; | |||
435 | */ | 402 | */ |
436 | public function testImportWithRedis() | 403 | public function testImportWithRedis() |
437 | { | 404 | { |
438 | $client = new Client(); | 405 | $httpMockClient = new HttpMockClient(); |
439 | 406 | ||
440 | $body = <<<'JSON' | 407 | $body = <<<'JSON' |
441 | { | 408 | { |
@@ -460,19 +427,16 @@ JSON; | |||
460 | } | 427 | } |
461 | JSON; | 428 | JSON; |
462 | 429 | ||
463 | $mock = new Mock([ | 430 | $httpMockClient->addResponse(new Response(200, ['Content-Type' => 'application/json'], json_encode(['access_token' => 'wunderbar_token']))); |
464 | new Response(200, ['Content-Type' => 'application/json'], Stream::factory(json_encode(['access_token' => 'wunderbar_token']))), | 431 | $httpMockClient->addResponse(new Response(200, ['Content-Type' => 'application/json'], <<<JSON |
465 | new Response(200, ['Content-Type' => 'application/json'], Stream::factory(' | 432 | { |
466 | { | 433 | "status": 1, |
467 | "status": 1, | 434 | "list": { |
468 | "list": { | 435 | "229279690": $body |
469 | "229279690": ' . $body . ' | ||
470 | } | ||
471 | } | 436 | } |
472 | ')), | 437 | } |
473 | ]); | 438 | JSON |
474 | 439 | )); | |
475 | $client->getEmitter()->attach($mock); | ||
476 | 440 | ||
477 | $pocketImport = $this->getPocketImport(); | 441 | $pocketImport = $this->getPocketImport(); |
478 | 442 | ||
@@ -499,7 +463,7 @@ JSON; | |||
499 | $queue = new RedisQueue($redisMock, 'pocket'); | 463 | $queue = new RedisQueue($redisMock, 'pocket'); |
500 | $producer = new Producer($queue); | 464 | $producer = new Producer($queue); |
501 | 465 | ||
502 | $pocketImport->setClient($client); | 466 | $pocketImport->setClient($httpMockClient); |
503 | $pocketImport->setProducer($producer); | 467 | $pocketImport->setProducer($producer); |
504 | $pocketImport->authorize('wunderbar_code'); | 468 | $pocketImport->authorize('wunderbar_code'); |
505 | 469 | ||
@@ -513,17 +477,13 @@ JSON; | |||
513 | 477 | ||
514 | public function testImportBadResponse() | 478 | public function testImportBadResponse() |
515 | { | 479 | { |
516 | $client = new Client(); | 480 | $httpMockClient = new HttpMockClient(); |
517 | 481 | ||
518 | $mock = new Mock([ | 482 | $httpMockClient->addResponse(new Response(200, ['Content-Type' => 'application/json'], json_encode(['access_token' => 'wunderbar_token']))); |
519 | new Response(200, ['Content-Type' => 'application/json'], Stream::factory(json_encode(['access_token' => 'wunderbar_token']))), | 483 | $httpMockClient->addResponse(new Response(403)); |
520 | new Response(403), | ||
521 | ]); | ||
522 | |||
523 | $client->getEmitter()->attach($mock); | ||
524 | 484 | ||
525 | $pocketImport = $this->getPocketImport(); | 485 | $pocketImport = $this->getPocketImport(); |
526 | $pocketImport->setClient($client); | 486 | $pocketImport->setClient($httpMockClient); |
527 | $pocketImport->authorize('wunderbar_code'); | 487 | $pocketImport->authorize('wunderbar_code'); |
528 | 488 | ||
529 | $res = $pocketImport->import(); | 489 | $res = $pocketImport->import(); |
@@ -537,25 +497,23 @@ JSON; | |||
537 | 497 | ||
538 | public function testImportWithExceptionFromGraby() | 498 | public function testImportWithExceptionFromGraby() |
539 | { | 499 | { |
540 | $client = new Client(); | 500 | $httpMockClient = new HttpMockClient(); |
541 | 501 | ||
542 | $mock = new Mock([ | 502 | $httpMockClient->addResponse(new Response(200, ['Content-Type' => 'application/json'], json_encode(['access_token' => 'wunderbar_token']))); |
543 | new Response(200, ['Content-Type' => 'application/json'], Stream::factory(json_encode(['access_token' => 'wunderbar_token']))), | 503 | $httpMockClient->addResponse(new Response(200, ['Content-Type' => 'application/json'], <<<'JSON' |
544 | new Response(200, ['Content-Type' => 'application/json'], Stream::factory(' | 504 | { |
545 | { | 505 | "status": 1, |
546 | "status": 1, | 506 | "list": { |
547 | "list": { | 507 | "229279689": { |
548 | "229279689": { | 508 | "status": "1", |
549 | "status": "1", | 509 | "favorite": "1", |
550 | "favorite": "1", | 510 | "resolved_url": "http://www.grantland.com/blog/the-triangle/post/_/id/38347/ryder-cup-preview" |
551 | "resolved_url": "http://www.grantland.com/blog/the-triangle/post/_/id/38347/ryder-cup-preview" | ||
552 | } | ||
553 | } | 511 | } |
554 | } | 512 | } |
555 | ')), | 513 | } |
556 | ]); | 514 | |
557 | 515 | JSON | |
558 | $client->getEmitter()->attach($mock); | 516 | )); |
559 | 517 | ||
560 | $pocketImport = $this->getPocketImport('ConsumerKey', 1); | 518 | $pocketImport = $this->getPocketImport('ConsumerKey', 1); |
561 | 519 | ||
@@ -579,7 +537,7 @@ JSON; | |||
579 | ->method('updateEntry') | 537 | ->method('updateEntry') |
580 | ->will($this->throwException(new \Exception())); | 538 | ->will($this->throwException(new \Exception())); |
581 | 539 | ||
582 | $pocketImport->setClient($client); | 540 | $pocketImport->setClient($httpMockClient); |
583 | $pocketImport->authorize('wunderbar_code'); | 541 | $pocketImport->authorize('wunderbar_code'); |
584 | 542 | ||
585 | $res = $pocketImport->import(); | 543 | $res = $pocketImport->import(); |