diff options
Diffstat (limited to 'tests/Wallabag/ImportBundle')
13 files changed, 1479 insertions, 62 deletions
diff --git a/tests/Wallabag/ImportBundle/Command/ImportCommandTest.php b/tests/Wallabag/ImportBundle/Command/ImportCommandTest.php new file mode 100644 index 00000000..eb7fce79 --- /dev/null +++ b/tests/Wallabag/ImportBundle/Command/ImportCommandTest.php | |||
@@ -0,0 +1,86 @@ | |||
1 | <?php | ||
2 | |||
3 | namespace Tests\Wallabag\ImportBundle\Command; | ||
4 | |||
5 | use Symfony\Bundle\FrameworkBundle\Console\Application; | ||
6 | use Symfony\Component\Console\Tester\CommandTester; | ||
7 | use Wallabag\ImportBundle\Command\ImportCommand; | ||
8 | use Tests\Wallabag\CoreBundle\WallabagCoreTestCase; | ||
9 | use M6Web\Component\RedisMock\RedisMockFactory; | ||
10 | |||
11 | class ImportCommandTest extends WallabagCoreTestCase | ||
12 | { | ||
13 | /** | ||
14 | * @expectedException Symfony\Component\Console\Exception\RuntimeException | ||
15 | * @expectedExceptionMessage Not enough arguments | ||
16 | */ | ||
17 | public function testRunImportCommandWithoutArguments() | ||
18 | { | ||
19 | $application = new Application($this->getClient()->getKernel()); | ||
20 | $application->add(new ImportCommand()); | ||
21 | |||
22 | $command = $application->find('wallabag:import'); | ||
23 | |||
24 | $tester = new CommandTester($command); | ||
25 | $tester->execute([ | ||
26 | 'command' => $command->getName(), | ||
27 | ]); | ||
28 | } | ||
29 | |||
30 | /** | ||
31 | * @expectedException Symfony\Component\Config\Definition\Exception\Exception | ||
32 | * @expectedExceptionMessage not found | ||
33 | */ | ||
34 | public function testRunImportCommandWithoutFilepath() | ||
35 | { | ||
36 | $application = new Application($this->getClient()->getKernel()); | ||
37 | $application->add(new ImportCommand()); | ||
38 | |||
39 | $command = $application->find('wallabag:import'); | ||
40 | |||
41 | $tester = new CommandTester($command); | ||
42 | $tester->execute([ | ||
43 | 'command' => $command->getName(), | ||
44 | 'userId' => 1, | ||
45 | 'filepath' => 1, | ||
46 | ]); | ||
47 | } | ||
48 | |||
49 | /** | ||
50 | * @expectedException Symfony\Component\Config\Definition\Exception\Exception | ||
51 | * @expectedExceptionMessage User with id | ||
52 | */ | ||
53 | public function testRunImportCommandWithoutUserId() | ||
54 | { | ||
55 | $application = new Application($this->getClient()->getKernel()); | ||
56 | $application->add(new ImportCommand()); | ||
57 | |||
58 | $command = $application->find('wallabag:import'); | ||
59 | |||
60 | $tester = new CommandTester($command); | ||
61 | $tester->execute([ | ||
62 | 'command' => $command->getName(), | ||
63 | 'userId' => 0, | ||
64 | 'filepath' => './', | ||
65 | ]); | ||
66 | } | ||
67 | |||
68 | public function testRunImportCommand() | ||
69 | { | ||
70 | $application = new Application($this->getClient()->getKernel()); | ||
71 | $application->add(new ImportCommand()); | ||
72 | |||
73 | $command = $application->find('wallabag:import'); | ||
74 | |||
75 | $tester = new CommandTester($command); | ||
76 | $tester->execute([ | ||
77 | 'command' => $command->getName(), | ||
78 | 'userId' => 1, | ||
79 | 'filepath' => $application->getKernel()->getContainer()->getParameter('kernel.root_dir').'/../tests/Wallabag/ImportBundle/fixtures/wallabag-v2-read.json', | ||
80 | '--importer' => 'v2', | ||
81 | ]); | ||
82 | |||
83 | $this->assertContains('imported', $tester->getDisplay()); | ||
84 | $this->assertContains('already saved', $tester->getDisplay()); | ||
85 | } | ||
86 | } | ||
diff --git a/tests/Wallabag/ImportBundle/Command/RedisWorkerCommandTest.php b/tests/Wallabag/ImportBundle/Command/RedisWorkerCommandTest.php new file mode 100644 index 00000000..74952847 --- /dev/null +++ b/tests/Wallabag/ImportBundle/Command/RedisWorkerCommandTest.php | |||
@@ -0,0 +1,74 @@ | |||
1 | <?php | ||
2 | |||
3 | namespace Tests\Wallabag\ImportBundle\Command; | ||
4 | |||
5 | use Symfony\Bundle\FrameworkBundle\Console\Application; | ||
6 | use Symfony\Component\Console\Tester\CommandTester; | ||
7 | use Wallabag\ImportBundle\Command\RedisWorkerCommand; | ||
8 | use Tests\Wallabag\CoreBundle\WallabagCoreTestCase; | ||
9 | use M6Web\Component\RedisMock\RedisMockFactory; | ||
10 | |||
11 | class RedisWorkerCommandTest extends WallabagCoreTestCase | ||
12 | { | ||
13 | /** | ||
14 | * @expectedException Symfony\Component\Console\Exception\RuntimeException | ||
15 | * @expectedExceptionMessage Not enough arguments (missing: "serviceName") | ||
16 | */ | ||
17 | public function testRunRedisWorkerCommandWithoutArguments() | ||
18 | { | ||
19 | $application = new Application($this->getClient()->getKernel()); | ||
20 | $application->add(new RedisWorkerCommand()); | ||
21 | |||
22 | $command = $application->find('wallabag:import:redis-worker'); | ||
23 | |||
24 | $tester = new CommandTester($command); | ||
25 | $tester->execute([ | ||
26 | 'command' => $command->getName(), | ||
27 | ]); | ||
28 | } | ||
29 | |||
30 | /** | ||
31 | * @expectedException Symfony\Component\Config\Definition\Exception\Exception | ||
32 | * @expectedExceptionMessage No queue or consumer found for service name | ||
33 | */ | ||
34 | public function testRunRedisWorkerCommandWithBadService() | ||
35 | { | ||
36 | $application = new Application($this->getClient()->getKernel()); | ||
37 | $application->add(new RedisWorkerCommand()); | ||
38 | |||
39 | $command = $application->find('wallabag:import:redis-worker'); | ||
40 | |||
41 | $tester = new CommandTester($command); | ||
42 | $tester->execute([ | ||
43 | 'command' => $command->getName(), | ||
44 | 'serviceName' => 'YOMONSERVICE', | ||
45 | ]); | ||
46 | } | ||
47 | |||
48 | public function testRunRedisWorkerCommand() | ||
49 | { | ||
50 | $application = new Application($this->getClient()->getKernel()); | ||
51 | $application->add(new RedisWorkerCommand()); | ||
52 | |||
53 | $factory = new RedisMockFactory(); | ||
54 | $redisMock = $factory->getAdapter('Predis\Client', true); | ||
55 | |||
56 | $application->getKernel()->getContainer()->set('wallabag_core.redis.client', $redisMock); | ||
57 | |||
58 | // put a fake message in the queue so the worker will stop after reading that message | ||
59 | // instead of waiting for others | ||
60 | $redisMock->lpush('wallabag.import.readability', '{}'); | ||
61 | |||
62 | $command = $application->find('wallabag:import:redis-worker'); | ||
63 | |||
64 | $tester = new CommandTester($command); | ||
65 | $tester->execute([ | ||
66 | 'command' => $command->getName(), | ||
67 | 'serviceName' => 'readability', | ||
68 | '--maxIterations' => 1, | ||
69 | ]); | ||
70 | |||
71 | $this->assertContains('Worker started at', $tester->getDisplay()); | ||
72 | $this->assertContains('Waiting for message', $tester->getDisplay()); | ||
73 | } | ||
74 | } | ||
diff --git a/tests/Wallabag/ImportBundle/Consumer/AMQPEntryConsumerTest.php b/tests/Wallabag/ImportBundle/Consumer/AMQPEntryConsumerTest.php new file mode 100644 index 00000000..a3263771 --- /dev/null +++ b/tests/Wallabag/ImportBundle/Consumer/AMQPEntryConsumerTest.php | |||
@@ -0,0 +1,225 @@ | |||
1 | <?php | ||
2 | |||
3 | namespace Tests\Wallabag\ImportBundle\Consumer\AMQP; | ||
4 | |||
5 | use Wallabag\ImportBundle\Consumer\AMQPEntryConsumer; | ||
6 | use PhpAmqpLib\Message\AMQPMessage; | ||
7 | use Wallabag\UserBundle\Entity\User; | ||
8 | use Wallabag\CoreBundle\Entity\Entry; | ||
9 | |||
10 | class AMQPEntryConsumerTest extends \PHPUnit_Framework_TestCase | ||
11 | { | ||
12 | public function testMessageOk() | ||
13 | { | ||
14 | $em = $this->getMockBuilder('Doctrine\ORM\EntityManager') | ||
15 | ->disableOriginalConstructor() | ||
16 | ->getMock(); | ||
17 | |||
18 | $em | ||
19 | ->expects($this->once()) | ||
20 | ->method('flush'); | ||
21 | |||
22 | $em | ||
23 | ->expects($this->exactly(2)) | ||
24 | ->method('clear'); | ||
25 | |||
26 | $body = <<<'JSON' | ||
27 | { | ||
28 | "item_id": "1402935436", | ||
29 | "resolved_id": "1402935436", | ||
30 | "given_url": "http://mashable.com/2016/09/04/leslie-jones-back-on-twitter-after-hack/?utm_campaign=Mash-Prod-RSS-Feedburner-All-Partial&utm_cid=Mash-Prod-RSS-Feedburner-All-Partial", | ||
31 | "given_title": "Leslie Jones is back on Twitter and her comeback tweet rules", | ||
32 | "favorite": "0", | ||
33 | "status": "0", | ||
34 | "time_added": "1473020899", | ||
35 | "time_updated": "1473020899", | ||
36 | "time_read": "0", | ||
37 | "time_favorited": "0", | ||
38 | "sort_id": 0, | ||
39 | "resolved_title": "Leslie Jones is back on Twitter and her comeback tweet rules", | ||
40 | "resolved_url": "http://mashable.com/2016/09/04/leslie-jones-back-on-twitter-after-hack/?utm_campaign=Mash-Prod-RSS-Feedburner-All-Partial&utm_cid=Mash-Prod-RSS-Feedburner-All-Partial", | ||
41 | "excerpt": "Leslie Jones is back to communicating with her adoring public on Twitter after cowardly hacker-trolls drove her away, probably to compensate for their own failings. It all started with a mic drop ...", | ||
42 | "is_article": "1", | ||
43 | "is_index": "0", | ||
44 | "has_video": "0", | ||
45 | "has_image": "1", | ||
46 | "word_count": "200", | ||
47 | "tags": { | ||
48 | "ifttt": { | ||
49 | "item_id": "1402935436", | ||
50 | "tag": "ifttt" | ||
51 | }, | ||
52 | "mashable": { | ||
53 | "item_id": "1402935436", | ||
54 | "tag": "mashable" | ||
55 | } | ||
56 | }, | ||
57 | "authors": { | ||
58 | "2484273": { | ||
59 | "item_id": "1402935436", | ||
60 | "author_id": "2484273", | ||
61 | "name": "Adam Rosenberg", | ||
62 | "url": "http://mashable.com/author/adam-rosenberg/" | ||
63 | } | ||
64 | }, | ||
65 | "image": { | ||
66 | "item_id": "1402935436", | ||
67 | "src": "http://i.amz.mshcdn.com/i-V5cS6_sDqFABaVR0hVSBJqG_w=/950x534/https%3A%2F%2Fblueprint-api-production.s3.amazonaws.com%2Fuploads%2Fcard%2Fimage%2F199899%2Fleslie_jones_war_dogs.jpg", | ||
68 | "width": "0", | ||
69 | "height": "0" | ||
70 | }, | ||
71 | "images": { | ||
72 | "1": { | ||
73 | "item_id": "1402935436", | ||
74 | "image_id": "1", | ||
75 | "src": "http://i.amz.mshcdn.com/i-V5cS6_sDqFABaVR0hVSBJqG_w=/950x534/https%3A%2F%2Fblueprint-api-production.s3.amazonaws.com%2Fuploads%2Fcard%2Fimage%2F199899%2Fleslie_jones_war_dogs.jpg", | ||
76 | "width": "0", | ||
77 | "height": "0", | ||
78 | "credit": "Image: Steve Eichner/NameFace/Sipa USA", | ||
79 | "caption": "" | ||
80 | } | ||
81 | }, | ||
82 | "userId": 1 | ||
83 | } | ||
84 | JSON; | ||
85 | |||
86 | $user = new User(); | ||
87 | $entry = new Entry($user); | ||
88 | |||
89 | $userRepository = $this->getMockBuilder('Wallabag\UserBundle\Repository\UserRepository') | ||
90 | ->disableOriginalConstructor() | ||
91 | ->getMock(); | ||
92 | |||
93 | $userRepository | ||
94 | ->expects($this->once()) | ||
95 | ->method('find') | ||
96 | // userId from the body json above | ||
97 | ->with(1) | ||
98 | ->willReturn($user); | ||
99 | |||
100 | $import = $this->getMockBuilder('Wallabag\ImportBundle\Import\AbstractImport') | ||
101 | ->disableOriginalConstructor() | ||
102 | ->getMock(); | ||
103 | |||
104 | $import | ||
105 | ->expects($this->once()) | ||
106 | ->method('setUser') | ||
107 | ->with($user); | ||
108 | |||
109 | $import | ||
110 | ->expects($this->once()) | ||
111 | ->method('parseEntry') | ||
112 | ->with(json_decode($body, true)) | ||
113 | ->willReturn($entry); | ||
114 | |||
115 | $consumer = new AMQPEntryConsumer( | ||
116 | $em, | ||
117 | $userRepository, | ||
118 | $import | ||
119 | ); | ||
120 | |||
121 | $message = new AMQPMessage($body); | ||
122 | |||
123 | $consumer->execute($message); | ||
124 | } | ||
125 | |||
126 | public function testMessageWithBadUser() | ||
127 | { | ||
128 | $em = $this->getMockBuilder('Doctrine\ORM\EntityManager') | ||
129 | ->disableOriginalConstructor() | ||
130 | ->getMock(); | ||
131 | |||
132 | $em | ||
133 | ->expects($this->never()) | ||
134 | ->method('flush'); | ||
135 | |||
136 | $em | ||
137 | ->expects($this->never()) | ||
138 | ->method('clear'); | ||
139 | |||
140 | $body = '{ "userId": 123 }'; | ||
141 | |||
142 | $user = new User(); | ||
143 | $entry = new Entry($user); | ||
144 | |||
145 | $userRepository = $this->getMockBuilder('Wallabag\UserBundle\Repository\UserRepository') | ||
146 | ->disableOriginalConstructor() | ||
147 | ->getMock(); | ||
148 | |||
149 | $userRepository | ||
150 | ->expects($this->once()) | ||
151 | ->method('find') | ||
152 | // userId from the body json above | ||
153 | ->with(123) | ||
154 | ->willReturn(null); | ||
155 | |||
156 | $import = $this->getMockBuilder('Wallabag\ImportBundle\Import\AbstractImport') | ||
157 | ->disableOriginalConstructor() | ||
158 | ->getMock(); | ||
159 | |||
160 | $consumer = new AMQPEntryConsumer( | ||
161 | $em, | ||
162 | $userRepository, | ||
163 | $import | ||
164 | ); | ||
165 | |||
166 | $message = new AMQPMessage($body); | ||
167 | |||
168 | $consumer->execute($message); | ||
169 | } | ||
170 | |||
171 | public function testMessageWithEntryProcessed() | ||
172 | { | ||
173 | $em = $this->getMockBuilder('Doctrine\ORM\EntityManager') | ||
174 | ->disableOriginalConstructor() | ||
175 | ->getMock(); | ||
176 | |||
177 | $em | ||
178 | ->expects($this->never()) | ||
179 | ->method('flush'); | ||
180 | |||
181 | $em | ||
182 | ->expects($this->never()) | ||
183 | ->method('clear'); | ||
184 | |||
185 | $body = '{ "userId": 123 }'; | ||
186 | |||
187 | $user = new User(); | ||
188 | |||
189 | $userRepository = $this->getMockBuilder('Wallabag\UserBundle\Repository\UserRepository') | ||
190 | ->disableOriginalConstructor() | ||
191 | ->getMock(); | ||
192 | |||
193 | $userRepository | ||
194 | ->expects($this->once()) | ||
195 | ->method('find') | ||
196 | // userId from the body json above | ||
197 | ->with(123) | ||
198 | ->willReturn($user); | ||
199 | |||
200 | $import = $this->getMockBuilder('Wallabag\ImportBundle\Import\AbstractImport') | ||
201 | ->disableOriginalConstructor() | ||
202 | ->getMock(); | ||
203 | |||
204 | $import | ||
205 | ->expects($this->once()) | ||
206 | ->method('setUser') | ||
207 | ->with($user); | ||
208 | |||
209 | $import | ||
210 | ->expects($this->once()) | ||
211 | ->method('parseEntry') | ||
212 | ->with(json_decode($body, true)) | ||
213 | ->willReturn(null); | ||
214 | |||
215 | $consumer = new AMQPEntryConsumer( | ||
216 | $em, | ||
217 | $userRepository, | ||
218 | $import | ||
219 | ); | ||
220 | |||
221 | $message = new AMQPMessage($body); | ||
222 | |||
223 | $consumer->execute($message); | ||
224 | } | ||
225 | } | ||
diff --git a/tests/Wallabag/ImportBundle/Consumer/RedisEntryConsumerTest.php b/tests/Wallabag/ImportBundle/Consumer/RedisEntryConsumerTest.php new file mode 100644 index 00000000..5e8ee41d --- /dev/null +++ b/tests/Wallabag/ImportBundle/Consumer/RedisEntryConsumerTest.php | |||
@@ -0,0 +1,225 @@ | |||
1 | <?php | ||
2 | |||
3 | namespace Tests\Wallabag\ImportBundle\Consumer\AMQP; | ||
4 | |||
5 | use Wallabag\ImportBundle\Consumer\RedisEntryConsumer; | ||
6 | use Wallabag\UserBundle\Entity\User; | ||
7 | use Wallabag\CoreBundle\Entity\Entry; | ||
8 | |||
9 | class RedisEntryConsumerTest extends \PHPUnit_Framework_TestCase | ||
10 | { | ||
11 | public function testMessageOk() | ||
12 | { | ||
13 | $em = $this->getMockBuilder('Doctrine\ORM\EntityManager') | ||
14 | ->disableOriginalConstructor() | ||
15 | ->getMock(); | ||
16 | |||
17 | $em | ||
18 | ->expects($this->once()) | ||
19 | ->method('flush'); | ||
20 | |||
21 | $em | ||
22 | ->expects($this->exactly(2)) | ||
23 | ->method('clear'); | ||
24 | |||
25 | $body = <<<'JSON' | ||
26 | { | ||
27 | "item_id": "1402935436", | ||
28 | "resolved_id": "1402935436", | ||
29 | "given_url": "http://mashable.com/2016/09/04/leslie-jones-back-on-twitter-after-hack/?utm_campaign=Mash-Prod-RSS-Feedburner-All-Partial&utm_cid=Mash-Prod-RSS-Feedburner-All-Partial", | ||
30 | "given_title": "Leslie Jones is back on Twitter and her comeback tweet rules", | ||
31 | "favorite": "0", | ||
32 | "status": "0", | ||
33 | "time_added": "1473020899", | ||
34 | "time_updated": "1473020899", | ||
35 | "time_read": "0", | ||
36 | "time_favorited": "0", | ||
37 | "sort_id": 0, | ||
38 | "resolved_title": "Leslie Jones is back on Twitter and her comeback tweet rules", | ||
39 | "resolved_url": "http://mashable.com/2016/09/04/leslie-jones-back-on-twitter-after-hack/?utm_campaign=Mash-Prod-RSS-Feedburner-All-Partial&utm_cid=Mash-Prod-RSS-Feedburner-All-Partial", | ||
40 | "excerpt": "Leslie Jones is back to communicating with her adoring public on Twitter after cowardly hacker-trolls drove her away, probably to compensate for their own failings. It all started with a mic drop ...", | ||
41 | "is_article": "1", | ||
42 | "is_index": "0", | ||
43 | "has_video": "0", | ||
44 | "has_image": "1", | ||
45 | "word_count": "200", | ||
46 | "tags": { | ||
47 | "ifttt": { | ||
48 | "item_id": "1402935436", | ||
49 | "tag": "ifttt" | ||
50 | }, | ||
51 | "mashable": { | ||
52 | "item_id": "1402935436", | ||
53 | "tag": "mashable" | ||
54 | } | ||
55 | }, | ||
56 | "authors": { | ||
57 | "2484273": { | ||
58 | "item_id": "1402935436", | ||
59 | "author_id": "2484273", | ||
60 | "name": "Adam Rosenberg", | ||
61 | "url": "http://mashable.com/author/adam-rosenberg/" | ||
62 | } | ||
63 | }, | ||
64 | "image": { | ||
65 | "item_id": "1402935436", | ||
66 | "src": "http://i.amz.mshcdn.com/i-V5cS6_sDqFABaVR0hVSBJqG_w=/950x534/https%3A%2F%2Fblueprint-api-production.s3.amazonaws.com%2Fuploads%2Fcard%2Fimage%2F199899%2Fleslie_jones_war_dogs.jpg", | ||
67 | "width": "0", | ||
68 | "height": "0" | ||
69 | }, | ||
70 | "images": { | ||
71 | "1": { | ||
72 | "item_id": "1402935436", | ||
73 | "image_id": "1", | ||
74 | "src": "http://i.amz.mshcdn.com/i-V5cS6_sDqFABaVR0hVSBJqG_w=/950x534/https%3A%2F%2Fblueprint-api-production.s3.amazonaws.com%2Fuploads%2Fcard%2Fimage%2F199899%2Fleslie_jones_war_dogs.jpg", | ||
75 | "width": "0", | ||
76 | "height": "0", | ||
77 | "credit": "Image: Steve Eichner/NameFace/Sipa USA", | ||
78 | "caption": "" | ||
79 | } | ||
80 | }, | ||
81 | "userId": 1 | ||
82 | } | ||
83 | JSON; | ||
84 | |||
85 | $user = new User(); | ||
86 | $entry = new Entry($user); | ||
87 | |||
88 | $userRepository = $this->getMockBuilder('Wallabag\UserBundle\Repository\UserRepository') | ||
89 | ->disableOriginalConstructor() | ||
90 | ->getMock(); | ||
91 | |||
92 | $userRepository | ||
93 | ->expects($this->once()) | ||
94 | ->method('find') | ||
95 | // userId from the body json above | ||
96 | ->with(1) | ||
97 | ->willReturn($user); | ||
98 | |||
99 | $import = $this->getMockBuilder('Wallabag\ImportBundle\Import\AbstractImport') | ||
100 | ->disableOriginalConstructor() | ||
101 | ->getMock(); | ||
102 | |||
103 | $import | ||
104 | ->expects($this->once()) | ||
105 | ->method('setUser') | ||
106 | ->with($user); | ||
107 | |||
108 | $import | ||
109 | ->expects($this->once()) | ||
110 | ->method('parseEntry') | ||
111 | ->with(json_decode($body, true)) | ||
112 | ->willReturn($entry); | ||
113 | |||
114 | $consumer = new RedisEntryConsumer( | ||
115 | $em, | ||
116 | $userRepository, | ||
117 | $import | ||
118 | ); | ||
119 | |||
120 | $res = $consumer->manage($body); | ||
121 | |||
122 | $this->assertTrue($res); | ||
123 | } | ||
124 | |||
125 | public function testMessageWithBadUser() | ||
126 | { | ||
127 | $em = $this->getMockBuilder('Doctrine\ORM\EntityManager') | ||
128 | ->disableOriginalConstructor() | ||
129 | ->getMock(); | ||
130 | |||
131 | $em | ||
132 | ->expects($this->never()) | ||
133 | ->method('flush'); | ||
134 | |||
135 | $em | ||
136 | ->expects($this->never()) | ||
137 | ->method('clear'); | ||
138 | |||
139 | $body = '{ "userId": 123 }'; | ||
140 | |||
141 | $user = new User(); | ||
142 | $entry = new Entry($user); | ||
143 | |||
144 | $userRepository = $this->getMockBuilder('Wallabag\UserBundle\Repository\UserRepository') | ||
145 | ->disableOriginalConstructor() | ||
146 | ->getMock(); | ||
147 | |||
148 | $userRepository | ||
149 | ->expects($this->once()) | ||
150 | ->method('find') | ||
151 | // userId from the body json above | ||
152 | ->with(123) | ||
153 | ->willReturn(null); | ||
154 | |||
155 | $import = $this->getMockBuilder('Wallabag\ImportBundle\Import\AbstractImport') | ||
156 | ->disableOriginalConstructor() | ||
157 | ->getMock(); | ||
158 | |||
159 | $consumer = new RedisEntryConsumer( | ||
160 | $em, | ||
161 | $userRepository, | ||
162 | $import | ||
163 | ); | ||
164 | |||
165 | $res = $consumer->manage($body); | ||
166 | |||
167 | $this->assertFalse($res); | ||
168 | } | ||
169 | |||
170 | public function testMessageWithEntryProcessed() | ||
171 | { | ||
172 | $em = $this->getMockBuilder('Doctrine\ORM\EntityManager') | ||
173 | ->disableOriginalConstructor() | ||
174 | ->getMock(); | ||
175 | |||
176 | $em | ||
177 | ->expects($this->never()) | ||
178 | ->method('flush'); | ||
179 | |||
180 | $em | ||
181 | ->expects($this->never()) | ||
182 | ->method('clear'); | ||
183 | |||
184 | $body = '{ "userId": 123 }'; | ||
185 | |||
186 | $user = new User(); | ||
187 | |||
188 | $userRepository = $this->getMockBuilder('Wallabag\UserBundle\Repository\UserRepository') | ||
189 | ->disableOriginalConstructor() | ||
190 | ->getMock(); | ||
191 | |||
192 | $userRepository | ||
193 | ->expects($this->once()) | ||
194 | ->method('find') | ||
195 | // userId from the body json above | ||
196 | ->with(123) | ||
197 | ->willReturn($user); | ||
198 | |||
199 | $import = $this->getMockBuilder('Wallabag\ImportBundle\Import\AbstractImport') | ||
200 | ->disableOriginalConstructor() | ||
201 | ->getMock(); | ||
202 | |||
203 | $import | ||
204 | ->expects($this->once()) | ||
205 | ->method('setUser') | ||
206 | ->with($user); | ||
207 | |||
208 | $import | ||
209 | ->expects($this->once()) | ||
210 | ->method('parseEntry') | ||
211 | ->with(json_decode($body, true)) | ||
212 | ->willReturn(null); | ||
213 | |||
214 | $consumer = new RedisEntryConsumer( | ||
215 | $em, | ||
216 | $userRepository, | ||
217 | $import | ||
218 | ); | ||
219 | |||
220 | $res = $consumer->manage($body); | ||
221 | |||
222 | $this->assertFalse($res); | ||
223 | $this->assertFalse($consumer->isStopJob($body)); | ||
224 | } | ||
225 | } | ||
diff --git a/tests/Wallabag/ImportBundle/Controller/PocketControllerTest.php b/tests/Wallabag/ImportBundle/Controller/PocketControllerTest.php index e0e61df8..35673261 100644 --- a/tests/Wallabag/ImportBundle/Controller/PocketControllerTest.php +++ b/tests/Wallabag/ImportBundle/Controller/PocketControllerTest.php | |||
@@ -17,6 +17,36 @@ class PocketControllerTest extends WallabagCoreTestCase | |||
17 | $this->assertEquals(1, $crawler->filter('button[type=submit]')->count()); | 17 | $this->assertEquals(1, $crawler->filter('button[type=submit]')->count()); |
18 | } | 18 | } |
19 | 19 | ||
20 | public function testImportPocketWithRabbitEnabled() | ||
21 | { | ||
22 | $this->logInAs('admin'); | ||
23 | $client = $this->getClient(); | ||
24 | |||
25 | $client->getContainer()->get('craue_config')->set('import_with_rabbitmq', 1); | ||
26 | |||
27 | $crawler = $client->request('GET', '/import/pocket'); | ||
28 | |||
29 | $this->assertEquals(200, $client->getResponse()->getStatusCode()); | ||
30 | $this->assertEquals(1, $crawler->filter('button[type=submit]')->count()); | ||
31 | |||
32 | $client->getContainer()->get('craue_config')->set('import_with_rabbitmq', 0); | ||
33 | } | ||
34 | |||
35 | public function testImportPocketWithRedisEnabled() | ||
36 | { | ||
37 | $this->logInAs('admin'); | ||
38 | $client = $this->getClient(); | ||
39 | |||
40 | $client->getContainer()->get('craue_config')->set('import_with_redis', 1); | ||
41 | |||
42 | $crawler = $client->request('GET', '/import/pocket'); | ||
43 | |||
44 | $this->assertEquals(200, $client->getResponse()->getStatusCode()); | ||
45 | $this->assertEquals(1, $crawler->filter('button[type=submit]')->count()); | ||
46 | |||
47 | $client->getContainer()->get('craue_config')->set('import_with_redis', 0); | ||
48 | } | ||
49 | |||
20 | public function testImportPocketAuthBadToken() | 50 | public function testImportPocketAuthBadToken() |
21 | { | 51 | { |
22 | $this->logInAs('admin'); | 52 | $this->logInAs('admin'); |
diff --git a/tests/Wallabag/ImportBundle/Controller/ReadabilityControllerTest.php b/tests/Wallabag/ImportBundle/Controller/ReadabilityControllerTest.php index 92cf4bfc..7b88d891 100644 --- a/tests/Wallabag/ImportBundle/Controller/ReadabilityControllerTest.php +++ b/tests/Wallabag/ImportBundle/Controller/ReadabilityControllerTest.php | |||
@@ -19,6 +19,74 @@ class ReadabilityControllerTest extends WallabagCoreTestCase | |||
19 | $this->assertEquals(1, $crawler->filter('input[type=file]')->count()); | 19 | $this->assertEquals(1, $crawler->filter('input[type=file]')->count()); |
20 | } | 20 | } |
21 | 21 | ||
22 | public function testImportReadabilityWithRabbitEnabled() | ||
23 | { | ||
24 | $this->logInAs('admin'); | ||
25 | $client = $this->getClient(); | ||
26 | |||
27 | $client->getContainer()->get('craue_config')->set('import_with_rabbitmq', 1); | ||
28 | |||
29 | $crawler = $client->request('GET', '/import/readability'); | ||
30 | |||
31 | $this->assertEquals(200, $client->getResponse()->getStatusCode()); | ||
32 | $this->assertEquals(1, $crawler->filter('form[name=upload_import_file] > button[type=submit]')->count()); | ||
33 | $this->assertEquals(1, $crawler->filter('input[type=file]')->count()); | ||
34 | |||
35 | $client->getContainer()->get('craue_config')->set('import_with_rabbitmq', 0); | ||
36 | } | ||
37 | |||
38 | public function testImportReadabilityBadFile() | ||
39 | { | ||
40 | $this->logInAs('admin'); | ||
41 | $client = $this->getClient(); | ||
42 | |||
43 | $crawler = $client->request('GET', '/import/readability'); | ||
44 | $form = $crawler->filter('form[name=upload_import_file] > button[type=submit]')->form(); | ||
45 | |||
46 | $data = [ | ||
47 | 'upload_import_file[file]' => '', | ||
48 | ]; | ||
49 | |||
50 | $client->submit($form, $data); | ||
51 | |||
52 | $this->assertEquals(200, $client->getResponse()->getStatusCode()); | ||
53 | } | ||
54 | |||
55 | public function testImportReadabilityWithRedisEnabled() | ||
56 | { | ||
57 | $this->logInAs('admin'); | ||
58 | $client = $this->getClient(); | ||
59 | |||
60 | $client->getContainer()->get('craue_config')->set('import_with_redis', 1); | ||
61 | |||
62 | $crawler = $client->request('GET', '/import/readability'); | ||
63 | |||
64 | $this->assertEquals(200, $client->getResponse()->getStatusCode()); | ||
65 | $this->assertEquals(1, $crawler->filter('form[name=upload_import_file] > button[type=submit]')->count()); | ||
66 | $this->assertEquals(1, $crawler->filter('input[type=file]')->count()); | ||
67 | |||
68 | $form = $crawler->filter('form[name=upload_import_file] > button[type=submit]')->form(); | ||
69 | |||
70 | $file = new UploadedFile(__DIR__.'/../fixtures/readability.json', 'readability.json'); | ||
71 | |||
72 | $data = [ | ||
73 | 'upload_import_file[file]' => $file, | ||
74 | ]; | ||
75 | |||
76 | $client->submit($form, $data); | ||
77 | |||
78 | $this->assertEquals(302, $client->getResponse()->getStatusCode()); | ||
79 | |||
80 | $crawler = $client->followRedirect(); | ||
81 | |||
82 | $this->assertGreaterThan(1, $body = $crawler->filter('body')->extract(['_text'])); | ||
83 | $this->assertContains('flashes.import.notice.summary', $body[0]); | ||
84 | |||
85 | $this->assertNotEmpty($client->getContainer()->get('wallabag_core.redis.client')->lpop('wallabag.import.readability')); | ||
86 | |||
87 | $client->getContainer()->get('craue_config')->set('import_with_redis', 0); | ||
88 | } | ||
89 | |||
22 | public function testImportReadabilityWithFile() | 90 | public function testImportReadabilityWithFile() |
23 | { | 91 | { |
24 | $this->logInAs('admin'); | 92 | $this->logInAs('admin'); |
@@ -49,6 +117,13 @@ class ReadabilityControllerTest extends WallabagCoreTestCase | |||
49 | 117 | ||
50 | $this->assertGreaterThan(1, $body = $crawler->filter('body')->extract(['_text'])); | 118 | $this->assertGreaterThan(1, $body = $crawler->filter('body')->extract(['_text'])); |
51 | $this->assertContains('flashes.import.notice.summary', $body[0]); | 119 | $this->assertContains('flashes.import.notice.summary', $body[0]); |
120 | |||
121 | $this->assertNotEmpty($content->getMimetype()); | ||
122 | $this->assertNotEmpty($content->getPreviewPicture()); | ||
123 | $this->assertNotEmpty($content->getLanguage()); | ||
124 | $this->assertEquals(0, count($content->getTags())); | ||
125 | $this->assertInstanceOf(\DateTime::class, $content->getCreatedAt()); | ||
126 | $this->assertEquals('2016-08-25', $content->getCreatedAt()->format('Y-m-d')); | ||
52 | } | 127 | } |
53 | 128 | ||
54 | public function testImportReadabilityWithFileAndMarkAllAsRead() | 129 | public function testImportReadabilityWithFileAndMarkAllAsRead() |
diff --git a/tests/Wallabag/ImportBundle/Controller/WallabagV1ControllerTest.php b/tests/Wallabag/ImportBundle/Controller/WallabagV1ControllerTest.php index c1025b41..98e85d45 100644 --- a/tests/Wallabag/ImportBundle/Controller/WallabagV1ControllerTest.php +++ b/tests/Wallabag/ImportBundle/Controller/WallabagV1ControllerTest.php | |||
@@ -19,6 +19,74 @@ class WallabagV1ControllerTest extends WallabagCoreTestCase | |||
19 | $this->assertEquals(1, $crawler->filter('input[type=file]')->count()); | 19 | $this->assertEquals(1, $crawler->filter('input[type=file]')->count()); |
20 | } | 20 | } |
21 | 21 | ||
22 | public function testImportWallabagWithRabbitEnabled() | ||
23 | { | ||
24 | $this->logInAs('admin'); | ||
25 | $client = $this->getClient(); | ||
26 | |||
27 | $client->getContainer()->get('craue_config')->set('import_with_rabbitmq', 1); | ||
28 | |||
29 | $crawler = $client->request('GET', '/import/wallabag-v1'); | ||
30 | |||
31 | $this->assertEquals(200, $client->getResponse()->getStatusCode()); | ||
32 | $this->assertEquals(1, $crawler->filter('form[name=upload_import_file] > button[type=submit]')->count()); | ||
33 | $this->assertEquals(1, $crawler->filter('input[type=file]')->count()); | ||
34 | |||
35 | $client->getContainer()->get('craue_config')->set('import_with_rabbitmq', 0); | ||
36 | } | ||
37 | |||
38 | public function testImportWallabagBadFile() | ||
39 | { | ||
40 | $this->logInAs('admin'); | ||
41 | $client = $this->getClient(); | ||
42 | |||
43 | $crawler = $client->request('GET', '/import/wallabag-v1'); | ||
44 | $form = $crawler->filter('form[name=upload_import_file] > button[type=submit]')->form(); | ||
45 | |||
46 | $data = [ | ||
47 | 'upload_import_file[file]' => '', | ||
48 | ]; | ||
49 | |||
50 | $client->submit($form, $data); | ||
51 | |||
52 | $this->assertEquals(200, $client->getResponse()->getStatusCode()); | ||
53 | } | ||
54 | |||
55 | public function testImportWallabagWithRedisEnabled() | ||
56 | { | ||
57 | $this->logInAs('admin'); | ||
58 | $client = $this->getClient(); | ||
59 | |||
60 | $client->getContainer()->get('craue_config')->set('import_with_redis', 1); | ||
61 | |||
62 | $crawler = $client->request('GET', '/import/wallabag-v1'); | ||
63 | |||
64 | $this->assertEquals(200, $client->getResponse()->getStatusCode()); | ||
65 | $this->assertEquals(1, $crawler->filter('form[name=upload_import_file] > button[type=submit]')->count()); | ||
66 | $this->assertEquals(1, $crawler->filter('input[type=file]')->count()); | ||
67 | |||
68 | $form = $crawler->filter('form[name=upload_import_file] > button[type=submit]')->form(); | ||
69 | |||
70 | $file = new UploadedFile(__DIR__.'/../fixtures/wallabag-v1.json', 'wallabag-v1.json'); | ||
71 | |||
72 | $data = [ | ||
73 | 'upload_import_file[file]' => $file, | ||
74 | ]; | ||
75 | |||
76 | $client->submit($form, $data); | ||
77 | |||
78 | $this->assertEquals(302, $client->getResponse()->getStatusCode()); | ||
79 | |||
80 | $crawler = $client->followRedirect(); | ||
81 | |||
82 | $this->assertGreaterThan(1, $body = $crawler->filter('body')->extract(['_text'])); | ||
83 | $this->assertContains('flashes.import.notice.summary', $body[0]); | ||
84 | |||
85 | $this->assertNotEmpty($client->getContainer()->get('wallabag_core.redis.client')->lpop('wallabag.import.wallabag_v1')); | ||
86 | |||
87 | $client->getContainer()->get('craue_config')->set('import_with_redis', 0); | ||
88 | } | ||
89 | |||
22 | public function testImportWallabagWithFile() | 90 | public function testImportWallabagWithFile() |
23 | { | 91 | { |
24 | $this->logInAs('admin'); | 92 | $this->logInAs('admin'); |
@@ -56,6 +124,12 @@ class WallabagV1ControllerTest extends WallabagCoreTestCase | |||
56 | 124 | ||
57 | $this->assertGreaterThan(1, $body = $crawler->filter('body')->extract(['_text'])); | 125 | $this->assertGreaterThan(1, $body = $crawler->filter('body')->extract(['_text'])); |
58 | $this->assertContains('flashes.import.notice.summary', $body[0]); | 126 | $this->assertContains('flashes.import.notice.summary', $body[0]); |
127 | |||
128 | $this->assertEmpty($content->getMimetype()); | ||
129 | $this->assertEmpty($content->getPreviewPicture()); | ||
130 | $this->assertEmpty($content->getLanguage()); | ||
131 | $this->assertEquals(1, count($content->getTags())); | ||
132 | $this->assertInstanceOf(\DateTime::class, $content->getCreatedAt()); | ||
59 | } | 133 | } |
60 | 134 | ||
61 | public function testImportWallabagWithFileAndMarkAllAsRead() | 135 | public function testImportWallabagWithFileAndMarkAllAsRead() |
diff --git a/tests/Wallabag/ImportBundle/Controller/WallabagV2ControllerTest.php b/tests/Wallabag/ImportBundle/Controller/WallabagV2ControllerTest.php index d8d2c8bf..74d61f9a 100644 --- a/tests/Wallabag/ImportBundle/Controller/WallabagV2ControllerTest.php +++ b/tests/Wallabag/ImportBundle/Controller/WallabagV2ControllerTest.php | |||
@@ -19,6 +19,74 @@ class WallabagV2ControllerTest extends WallabagCoreTestCase | |||
19 | $this->assertEquals(1, $crawler->filter('input[type=file]')->count()); | 19 | $this->assertEquals(1, $crawler->filter('input[type=file]')->count()); |
20 | } | 20 | } |
21 | 21 | ||
22 | public function testImportWallabagWithRabbitEnabled() | ||
23 | { | ||
24 | $this->logInAs('admin'); | ||
25 | $client = $this->getClient(); | ||
26 | |||
27 | $client->getContainer()->get('craue_config')->set('import_with_rabbitmq', 1); | ||
28 | |||
29 | $crawler = $client->request('GET', '/import/wallabag-v2'); | ||
30 | |||
31 | $this->assertEquals(200, $client->getResponse()->getStatusCode()); | ||
32 | $this->assertEquals(1, $crawler->filter('form[name=upload_import_file] > button[type=submit]')->count()); | ||
33 | $this->assertEquals(1, $crawler->filter('input[type=file]')->count()); | ||
34 | |||
35 | $client->getContainer()->get('craue_config')->set('import_with_rabbitmq', 0); | ||
36 | } | ||
37 | |||
38 | public function testImportWallabagBadFile() | ||
39 | { | ||
40 | $this->logInAs('admin'); | ||
41 | $client = $this->getClient(); | ||
42 | |||
43 | $crawler = $client->request('GET', '/import/wallabag-v2'); | ||
44 | $form = $crawler->filter('form[name=upload_import_file] > button[type=submit]')->form(); | ||
45 | |||
46 | $data = [ | ||
47 | 'upload_import_file[file]' => '', | ||
48 | ]; | ||
49 | |||
50 | $client->submit($form, $data); | ||
51 | |||
52 | $this->assertEquals(200, $client->getResponse()->getStatusCode()); | ||
53 | } | ||
54 | |||
55 | public function testImportWallabagWithRedisEnabled() | ||
56 | { | ||
57 | $this->logInAs('admin'); | ||
58 | $client = $this->getClient(); | ||
59 | |||
60 | $client->getContainer()->get('craue_config')->set('import_with_redis', 1); | ||
61 | |||
62 | $crawler = $client->request('GET', '/import/wallabag-v2'); | ||
63 | |||
64 | $this->assertEquals(200, $client->getResponse()->getStatusCode()); | ||
65 | $this->assertEquals(1, $crawler->filter('form[name=upload_import_file] > button[type=submit]')->count()); | ||
66 | $this->assertEquals(1, $crawler->filter('input[type=file]')->count()); | ||
67 | |||
68 | $form = $crawler->filter('form[name=upload_import_file] > button[type=submit]')->form(); | ||
69 | |||
70 | $file = new UploadedFile(__DIR__.'/../fixtures/wallabag-v2.json', 'wallabag-v2.json'); | ||
71 | |||
72 | $data = [ | ||
73 | 'upload_import_file[file]' => $file, | ||
74 | ]; | ||
75 | |||
76 | $client->submit($form, $data); | ||
77 | |||
78 | $this->assertEquals(302, $client->getResponse()->getStatusCode()); | ||
79 | |||
80 | $crawler = $client->followRedirect(); | ||
81 | |||
82 | $this->assertGreaterThan(1, $body = $crawler->filter('body')->extract(['_text'])); | ||
83 | $this->assertContains('flashes.import.notice.summary', $body[0]); | ||
84 | |||
85 | $this->assertNotEmpty($client->getContainer()->get('wallabag_core.redis.client')->lpop('wallabag.import.wallabag_v2')); | ||
86 | |||
87 | $client->getContainer()->get('craue_config')->set('import_with_redis', 0); | ||
88 | } | ||
89 | |||
22 | public function testImportWallabagWithFile() | 90 | public function testImportWallabagWithFile() |
23 | { | 91 | { |
24 | $this->logInAs('admin'); | 92 | $this->logInAs('admin'); |
@@ -50,9 +118,9 @@ class WallabagV2ControllerTest extends WallabagCoreTestCase | |||
50 | $this->getLoggedInUserId() | 118 | $this->getLoggedInUserId() |
51 | ); | 119 | ); |
52 | 120 | ||
53 | $this->assertEmpty($content->getMimetype()); | 121 | $this->assertNotEmpty($content->getMimetype()); |
54 | $this->assertEmpty($content->getPreviewPicture()); | 122 | $this->assertNotEmpty($content->getPreviewPicture()); |
55 | $this->assertEmpty($content->getLanguage()); | 123 | $this->assertNotEmpty($content->getLanguage()); |
56 | $this->assertEquals(0, count($content->getTags())); | 124 | $this->assertEquals(0, count($content->getTags())); |
57 | 125 | ||
58 | $content = $client->getContainer() | 126 | $content = $client->getContainer() |
@@ -67,6 +135,8 @@ class WallabagV2ControllerTest extends WallabagCoreTestCase | |||
67 | $this->assertNotEmpty($content->getPreviewPicture()); | 135 | $this->assertNotEmpty($content->getPreviewPicture()); |
68 | $this->assertNotEmpty($content->getLanguage()); | 136 | $this->assertNotEmpty($content->getLanguage()); |
69 | $this->assertEquals(2, count($content->getTags())); | 137 | $this->assertEquals(2, count($content->getTags())); |
138 | $this->assertInstanceOf(\DateTime::class, $content->getCreatedAt()); | ||
139 | $this->assertEquals('2016-09-08', $content->getCreatedAt()->format('Y-m-d')); | ||
70 | } | 140 | } |
71 | 141 | ||
72 | public function testImportWallabagWithEmptyFile() | 142 | public function testImportWallabagWithEmptyFile() |
diff --git a/tests/Wallabag/ImportBundle/Import/PocketImportTest.php b/tests/Wallabag/ImportBundle/Import/PocketImportTest.php index 8534e1c8..952521a2 100644 --- a/tests/Wallabag/ImportBundle/Import/PocketImportTest.php +++ b/tests/Wallabag/ImportBundle/Import/PocketImportTest.php | |||
@@ -4,21 +4,17 @@ namespace Tests\Wallabag\ImportBundle\Import; | |||
4 | 4 | ||
5 | use Wallabag\UserBundle\Entity\User; | 5 | use Wallabag\UserBundle\Entity\User; |
6 | use Wallabag\CoreBundle\Entity\Entry; | 6 | use Wallabag\CoreBundle\Entity\Entry; |
7 | use Wallabag\CoreBundle\Entity\Config; | ||
7 | use Wallabag\ImportBundle\Import\PocketImport; | 8 | use Wallabag\ImportBundle\Import\PocketImport; |
8 | use GuzzleHttp\Client; | 9 | use GuzzleHttp\Client; |
9 | use GuzzleHttp\Subscriber\Mock; | 10 | use GuzzleHttp\Subscriber\Mock; |
10 | use GuzzleHttp\Message\Response; | 11 | use GuzzleHttp\Message\Response; |
11 | use GuzzleHttp\Stream\Stream; | 12 | use GuzzleHttp\Stream\Stream; |
13 | use Wallabag\ImportBundle\Redis\Producer; | ||
12 | use Monolog\Logger; | 14 | use Monolog\Logger; |
13 | use Monolog\Handler\TestHandler; | 15 | use Monolog\Handler\TestHandler; |
14 | 16 | use Simpleue\Queue\RedisQueue; | |
15 | class PocketImportMock extends PocketImport | 17 | use M6Web\Component\RedisMock\RedisMockFactory; |
16 | { | ||
17 | public function getAccessToken() | ||
18 | { | ||
19 | return $this->accessToken; | ||
20 | } | ||
21 | } | ||
22 | 18 | ||
23 | class PocketImportTest extends \PHPUnit_Framework_TestCase | 19 | class PocketImportTest extends \PHPUnit_Framework_TestCase |
24 | { | 20 | { |
@@ -32,45 +28,24 @@ class PocketImportTest extends \PHPUnit_Framework_TestCase | |||
32 | { | 28 | { |
33 | $this->user = new User(); | 29 | $this->user = new User(); |
34 | 30 | ||
35 | $this->tokenStorage = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface') | 31 | $config = new Config($this->user); |
36 | ->disableOriginalConstructor() | 32 | $config->setPocketConsumerKey('xxx'); |
37 | ->getMock(); | ||
38 | 33 | ||
39 | $token = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface') | 34 | $this->user->setConfig($config); |
40 | ->disableOriginalConstructor() | ||
41 | ->getMock(); | ||
42 | 35 | ||
43 | $this->contentProxy = $this->getMockBuilder('Wallabag\CoreBundle\Helper\ContentProxy') | 36 | $this->contentProxy = $this->getMockBuilder('Wallabag\CoreBundle\Helper\ContentProxy') |
44 | ->disableOriginalConstructor() | 37 | ->disableOriginalConstructor() |
45 | ->getMock(); | 38 | ->getMock(); |
46 | 39 | ||
47 | $token->expects($this->once()) | ||
48 | ->method('getUser') | ||
49 | ->willReturn($this->user); | ||
50 | |||
51 | $this->tokenStorage->expects($this->once()) | ||
52 | ->method('getToken') | ||
53 | ->willReturn($token); | ||
54 | |||
55 | $this->em = $this->getMockBuilder('Doctrine\ORM\EntityManager') | 40 | $this->em = $this->getMockBuilder('Doctrine\ORM\EntityManager') |
56 | ->disableOriginalConstructor() | 41 | ->disableOriginalConstructor() |
57 | ->getMock(); | 42 | ->getMock(); |
58 | 43 | ||
59 | $config = $this->getMockBuilder('Craue\ConfigBundle\Util\Config') | 44 | $pocket = new PocketImport( |
60 | ->disableOriginalConstructor() | ||
61 | ->getMock(); | ||
62 | |||
63 | $config->expects($this->any()) | ||
64 | ->method('get') | ||
65 | ->with('pocket_consumer_key') | ||
66 | ->willReturn($consumerKey); | ||
67 | |||
68 | $pocket = new PocketImportMock( | ||
69 | $this->tokenStorage, | ||
70 | $this->em, | 45 | $this->em, |
71 | $this->contentProxy, | 46 | $this->contentProxy |
72 | $config | ||
73 | ); | 47 | ); |
48 | $pocket->setUser($this->user); | ||
74 | 49 | ||
75 | $this->logHandler = new TestHandler(); | 50 | $this->logHandler = new TestHandler(); |
76 | $logger = new Logger('test', [$this->logHandler]); | 51 | $logger = new Logger('test', [$this->logHandler]); |
@@ -189,10 +164,16 @@ class PocketImportTest extends \PHPUnit_Framework_TestCase | |||
189 | "given_title": "The Massive Ryder Cup Preview - The Triangle Blog - Grantland", | 164 | "given_title": "The Massive Ryder Cup Preview - The Triangle Blog - Grantland", |
190 | "favorite": "1", | 165 | "favorite": "1", |
191 | "status": "1", | 166 | "status": "1", |
167 | "time_added": "1473020899", | ||
168 | "time_updated": "1473020899", | ||
169 | "time_read": "0", | ||
170 | "time_favorited": "0", | ||
171 | "sort_id": 0, | ||
192 | "resolved_title": "The Massive Ryder Cup Preview", | 172 | "resolved_title": "The Massive Ryder Cup Preview", |
193 | "resolved_url": "http://www.grantland.com/blog/the-triangle/post/_/id/38347/ryder-cup-preview", | 173 | "resolved_url": "http://www.grantland.com/blog/the-triangle/post/_/id/38347/ryder-cup-preview", |
194 | "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.", | 174 | "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.", |
195 | "is_article": "1", | 175 | "is_article": "1", |
176 | "is_index": "0", | ||
196 | "has_video": "1", | 177 | "has_video": "1", |
197 | "has_image": "1", | 178 | "has_image": "1", |
198 | "word_count": "3197", | 179 | "word_count": "3197", |
@@ -236,10 +217,16 @@ class PocketImportTest extends \PHPUnit_Framework_TestCase | |||
236 | "given_title": "The Massive Ryder Cup Preview - The Triangle Blog - Grantland", | 217 | "given_title": "The Massive Ryder Cup Preview - The Triangle Blog - Grantland", |
237 | "favorite": "1", | 218 | "favorite": "1", |
238 | "status": "1", | 219 | "status": "1", |
220 | "time_added": "1473020899", | ||
221 | "time_updated": "1473020899", | ||
222 | "time_read": "0", | ||
223 | "time_favorited": "0", | ||
224 | "sort_id": 1, | ||
239 | "resolved_title": "The Massive Ryder Cup Preview", | 225 | "resolved_title": "The Massive Ryder Cup Preview", |
240 | "resolved_url": "http://www.grantland.com/blog/the-triangle/post/_/id/38347/ryder-cup-preview", | 226 | "resolved_url": "http://www.grantland.com/blog/the-triangle/post/_/id/38347/ryder-cup-preview", |
241 | "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.", | 227 | "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.", |
242 | "is_article": "1", | 228 | "is_article": "1", |
229 | "is_index": "0", | ||
243 | "has_video": "0", | 230 | "has_video": "0", |
244 | "has_image": "0", | 231 | "has_image": "0", |
245 | "word_count": "3197" | 232 | "word_count": "3197" |
@@ -279,7 +266,7 @@ class PocketImportTest extends \PHPUnit_Framework_TestCase | |||
279 | $res = $pocketImport->import(); | 266 | $res = $pocketImport->import(); |
280 | 267 | ||
281 | $this->assertTrue($res); | 268 | $this->assertTrue($res); |
282 | $this->assertEquals(['skipped' => 1, 'imported' => 1], $pocketImport->getSummary()); | 269 | $this->assertEquals(['skipped' => 1, 'imported' => 1, 'queued' => 0], $pocketImport->getSummary()); |
283 | } | 270 | } |
284 | 271 | ||
285 | /** | 272 | /** |
@@ -302,6 +289,11 @@ class PocketImportTest extends \PHPUnit_Framework_TestCase | |||
302 | "given_title": "The Massive Ryder Cup Preview - The Triangle Blog - Grantland", | 289 | "given_title": "The Massive Ryder Cup Preview - The Triangle Blog - Grantland", |
303 | "favorite": "1", | 290 | "favorite": "1", |
304 | "status": "1", | 291 | "status": "1", |
292 | "time_added": "1473020899", | ||
293 | "time_updated": "1473020899", | ||
294 | "time_read": "0", | ||
295 | "time_favorited": "0", | ||
296 | "sort_id": 0, | ||
305 | "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.", | 297 | "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.", |
306 | "is_article": "1", | 298 | "is_article": "1", |
307 | "has_video": "1", | 299 | "has_video": "1", |
@@ -315,6 +307,11 @@ class PocketImportTest extends \PHPUnit_Framework_TestCase | |||
315 | "given_title": "The Massive Ryder Cup Preview - The Triangle Blog - Grantland", | 307 | "given_title": "The Massive Ryder Cup Preview - The Triangle Blog - Grantland", |
316 | "favorite": "1", | 308 | "favorite": "1", |
317 | "status": "0", | 309 | "status": "0", |
310 | "time_added": "1473020899", | ||
311 | "time_updated": "1473020899", | ||
312 | "time_read": "0", | ||
313 | "time_favorited": "0", | ||
314 | "sort_id": 1, | ||
318 | "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.", | 315 | "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.", |
319 | "is_article": "1", | 316 | "is_article": "1", |
320 | "has_video": "0", | 317 | "has_video": "0", |
@@ -364,7 +361,174 @@ class PocketImportTest extends \PHPUnit_Framework_TestCase | |||
364 | $res = $pocketImport->setMarkAsRead(true)->import(); | 361 | $res = $pocketImport->setMarkAsRead(true)->import(); |
365 | 362 | ||
366 | $this->assertTrue($res); | 363 | $this->assertTrue($res); |
367 | $this->assertEquals(['skipped' => 0, 'imported' => 2], $pocketImport->getSummary()); | 364 | $this->assertEquals(['skipped' => 0, 'imported' => 2, 'queued' => 0], $pocketImport->getSummary()); |
365 | } | ||
366 | |||
367 | /** | ||
368 | * Will sample results from https://getpocket.com/developer/docs/v3/retrieve. | ||
369 | */ | ||
370 | public function testImportWithRabbit() | ||
371 | { | ||
372 | $client = new Client(); | ||
373 | |||
374 | $body = <<<'JSON' | ||
375 | { | ||
376 | "item_id": "229279689", | ||
377 | "resolved_id": "229279689", | ||
378 | "given_url": "http://www.grantland.com/blog/the-triangle/post/_/id/38347/ryder-cup-preview", | ||
379 | "given_title": "The Massive Ryder Cup Preview - The Triangle Blog - Grantland", | ||
380 | "favorite": "1", | ||
381 | "status": "1", | ||
382 | "time_added": "1473020899", | ||
383 | "time_updated": "1473020899", | ||
384 | "time_read": "0", | ||
385 | "time_favorited": "0", | ||
386 | "sort_id": 0, | ||
387 | "resolved_title": "The Massive Ryder Cup Preview", | ||
388 | "resolved_url": "http://www.grantland.com/blog/the-triangle/post/_/id/38347/ryder-cup-preview", | ||
389 | "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.", | ||
390 | "is_article": "1", | ||
391 | "has_video": "0", | ||
392 | "has_image": "0", | ||
393 | "word_count": "3197" | ||
394 | } | ||
395 | JSON; | ||
396 | |||
397 | $mock = new Mock([ | ||
398 | new Response(200, ['Content-Type' => 'application/json'], Stream::factory(json_encode(['access_token' => 'wunderbar_token']))), | ||
399 | new Response(200, ['Content-Type' => 'application/json'], Stream::factory(' | ||
400 | { | ||
401 | "status": 1, | ||
402 | "list": { | ||
403 | "229279690": '.$body.' | ||
404 | } | ||
405 | } | ||
406 | ')), | ||
407 | ]); | ||
408 | |||
409 | $client->getEmitter()->attach($mock); | ||
410 | |||
411 | $pocketImport = $this->getPocketImport(); | ||
412 | |||
413 | $entryRepo = $this->getMockBuilder('Wallabag\CoreBundle\Repository\EntryRepository') | ||
414 | ->disableOriginalConstructor() | ||
415 | ->getMock(); | ||
416 | |||
417 | $entryRepo->expects($this->never()) | ||
418 | ->method('findByUrlAndUserId'); | ||
419 | |||
420 | $this->em | ||
421 | ->expects($this->never()) | ||
422 | ->method('getRepository'); | ||
423 | |||
424 | $entry = new Entry($this->user); | ||
425 | |||
426 | $this->contentProxy | ||
427 | ->expects($this->never()) | ||
428 | ->method('updateEntry'); | ||
429 | |||
430 | $producer = $this->getMockBuilder('OldSound\RabbitMqBundle\RabbitMq\Producer') | ||
431 | ->disableOriginalConstructor() | ||
432 | ->getMock(); | ||
433 | |||
434 | $bodyAsArray = json_decode($body, true); | ||
435 | // because with just use `new User()` so it doesn't have an id | ||
436 | $bodyAsArray['userId'] = null; | ||
437 | |||
438 | $producer | ||
439 | ->expects($this->once()) | ||
440 | ->method('publish') | ||
441 | ->with(json_encode($bodyAsArray)); | ||
442 | |||
443 | $pocketImport->setClient($client); | ||
444 | $pocketImport->setProducer($producer); | ||
445 | $pocketImport->authorize('wunderbar_code'); | ||
446 | |||
447 | $res = $pocketImport->setMarkAsRead(true)->import(); | ||
448 | |||
449 | $this->assertTrue($res); | ||
450 | $this->assertEquals(['skipped' => 0, 'imported' => 0, 'queued' => 1], $pocketImport->getSummary()); | ||
451 | } | ||
452 | |||
453 | /** | ||
454 | * Will sample results from https://getpocket.com/developer/docs/v3/retrieve. | ||
455 | */ | ||
456 | public function testImportWithRedis() | ||
457 | { | ||
458 | $client = new Client(); | ||
459 | |||
460 | $body = <<<'JSON' | ||
461 | { | ||
462 | "item_id": "229279689", | ||
463 | "resolved_id": "229279689", | ||
464 | "given_url": "http://www.grantland.com/blog/the-triangle/post/_/id/38347/ryder-cup-preview", | ||
465 | "given_title": "The Massive Ryder Cup Preview - The Triangle Blog - Grantland", | ||
466 | "favorite": "1", | ||
467 | "status": "1", | ||
468 | "time_added": "1473020899", | ||
469 | "time_updated": "1473020899", | ||
470 | "time_read": "0", | ||
471 | "time_favorited": "0", | ||
472 | "sort_id": 0, | ||
473 | "resolved_title": "The Massive Ryder Cup Preview", | ||
474 | "resolved_url": "http://www.grantland.com/blog/the-triangle/post/_/id/38347/ryder-cup-preview", | ||
475 | "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.", | ||
476 | "is_article": "1", | ||
477 | "has_video": "0", | ||
478 | "has_image": "0", | ||
479 | "word_count": "3197" | ||
480 | } | ||
481 | JSON; | ||
482 | |||
483 | $mock = new Mock([ | ||
484 | new Response(200, ['Content-Type' => 'application/json'], Stream::factory(json_encode(['access_token' => 'wunderbar_token']))), | ||
485 | new Response(200, ['Content-Type' => 'application/json'], Stream::factory(' | ||
486 | { | ||
487 | "status": 1, | ||
488 | "list": { | ||
489 | "229279690": '.$body.' | ||
490 | } | ||
491 | } | ||
492 | ')), | ||
493 | ]); | ||
494 | |||
495 | $client->getEmitter()->attach($mock); | ||
496 | |||
497 | $pocketImport = $this->getPocketImport(); | ||
498 | |||
499 | $entryRepo = $this->getMockBuilder('Wallabag\CoreBundle\Repository\EntryRepository') | ||
500 | ->disableOriginalConstructor() | ||
501 | ->getMock(); | ||
502 | |||
503 | $entryRepo->expects($this->never()) | ||
504 | ->method('findByUrlAndUserId'); | ||
505 | |||
506 | $this->em | ||
507 | ->expects($this->never()) | ||
508 | ->method('getRepository'); | ||
509 | |||
510 | $entry = new Entry($this->user); | ||
511 | |||
512 | $this->contentProxy | ||
513 | ->expects($this->never()) | ||
514 | ->method('updateEntry'); | ||
515 | |||
516 | $factory = new RedisMockFactory(); | ||
517 | $redisMock = $factory->getAdapter('Predis\Client', true); | ||
518 | |||
519 | $queue = new RedisQueue($redisMock, 'pocket'); | ||
520 | $producer = new Producer($queue); | ||
521 | |||
522 | $pocketImport->setClient($client); | ||
523 | $pocketImport->setProducer($producer); | ||
524 | $pocketImport->authorize('wunderbar_code'); | ||
525 | |||
526 | $res = $pocketImport->setMarkAsRead(true)->import(); | ||
527 | |||
528 | $this->assertTrue($res); | ||
529 | $this->assertEquals(['skipped' => 0, 'imported' => 0, 'queued' => 1], $pocketImport->getSummary()); | ||
530 | |||
531 | $this->assertNotEmpty($redisMock->lpop('pocket')); | ||
368 | } | 532 | } |
369 | 533 | ||
370 | public function testImportBadResponse() | 534 | public function testImportBadResponse() |
@@ -402,6 +566,8 @@ class PocketImportTest extends \PHPUnit_Framework_TestCase | |||
402 | "status": 1, | 566 | "status": 1, |
403 | "list": { | 567 | "list": { |
404 | "229279689": { | 568 | "229279689": { |
569 | "status": "1", | ||
570 | "favorite": "1", | ||
405 | "resolved_url": "http://www.grantland.com/blog/the-triangle/post/_/id/38347/ryder-cup-preview" | 571 | "resolved_url": "http://www.grantland.com/blog/the-triangle/post/_/id/38347/ryder-cup-preview" |
406 | } | 572 | } |
407 | } | 573 | } |
@@ -439,6 +605,6 @@ class PocketImportTest extends \PHPUnit_Framework_TestCase | |||
439 | $res = $pocketImport->import(); | 605 | $res = $pocketImport->import(); |
440 | 606 | ||
441 | $this->assertTrue($res); | 607 | $this->assertTrue($res); |
442 | $this->assertEquals(['skipped' => 1, 'imported' => 0], $pocketImport->getSummary()); | 608 | $this->assertEquals(['skipped' => 0, 'imported' => 1, 'queued' => 0], $pocketImport->getSummary()); |
443 | } | 609 | } |
444 | } | 610 | } |
diff --git a/tests/Wallabag/ImportBundle/Import/ReadabilityImportTest.php b/tests/Wallabag/ImportBundle/Import/ReadabilityImportTest.php index 706d707b..d98cd486 100644 --- a/tests/Wallabag/ImportBundle/Import/ReadabilityImportTest.php +++ b/tests/Wallabag/ImportBundle/Import/ReadabilityImportTest.php | |||
@@ -5,8 +5,11 @@ namespace Tests\Wallabag\ImportBundle\Import; | |||
5 | use Wallabag\ImportBundle\Import\ReadabilityImport; | 5 | use Wallabag\ImportBundle\Import\ReadabilityImport; |
6 | use Wallabag\UserBundle\Entity\User; | 6 | use Wallabag\UserBundle\Entity\User; |
7 | use Wallabag\CoreBundle\Entity\Entry; | 7 | use Wallabag\CoreBundle\Entity\Entry; |
8 | use Wallabag\ImportBundle\Redis\Producer; | ||
8 | use Monolog\Logger; | 9 | use Monolog\Logger; |
9 | use Monolog\Handler\TestHandler; | 10 | use Monolog\Handler\TestHandler; |
11 | use Simpleue\Queue\RedisQueue; | ||
12 | use M6Web\Component\RedisMock\RedisMockFactory; | ||
10 | 13 | ||
11 | class ReadabilityImportTest extends \PHPUnit_Framework_TestCase | 14 | class ReadabilityImportTest extends \PHPUnit_Framework_TestCase |
12 | { | 15 | { |
@@ -58,9 +61,9 @@ class ReadabilityImportTest extends \PHPUnit_Framework_TestCase | |||
58 | ->disableOriginalConstructor() | 61 | ->disableOriginalConstructor() |
59 | ->getMock(); | 62 | ->getMock(); |
60 | 63 | ||
61 | $entryRepo->expects($this->exactly(2)) | 64 | $entryRepo->expects($this->exactly(24)) |
62 | ->method('findByUrlAndUserId') | 65 | ->method('findByUrlAndUserId') |
63 | ->will($this->onConsecutiveCalls(false, true)); | 66 | ->willReturn(false); |
64 | 67 | ||
65 | $this->em | 68 | $this->em |
66 | ->expects($this->any()) | 69 | ->expects($this->any()) |
@@ -72,14 +75,14 @@ class ReadabilityImportTest extends \PHPUnit_Framework_TestCase | |||
72 | ->getMock(); | 75 | ->getMock(); |
73 | 76 | ||
74 | $this->contentProxy | 77 | $this->contentProxy |
75 | ->expects($this->exactly(1)) | 78 | ->expects($this->exactly(24)) |
76 | ->method('updateEntry') | 79 | ->method('updateEntry') |
77 | ->willReturn($entry); | 80 | ->willReturn($entry); |
78 | 81 | ||
79 | $res = $readabilityImport->import(); | 82 | $res = $readabilityImport->import(); |
80 | 83 | ||
81 | $this->assertTrue($res); | 84 | $this->assertTrue($res); |
82 | $this->assertEquals(['skipped' => 1, 'imported' => 1], $readabilityImport->getSummary()); | 85 | $this->assertEquals(['skipped' => 0, 'imported' => 24, 'queued' => 0], $readabilityImport->getSummary()); |
83 | } | 86 | } |
84 | 87 | ||
85 | public function testImportAndMarkAllAsRead() | 88 | public function testImportAndMarkAllAsRead() |
@@ -93,7 +96,7 @@ class ReadabilityImportTest extends \PHPUnit_Framework_TestCase | |||
93 | 96 | ||
94 | $entryRepo->expects($this->exactly(2)) | 97 | $entryRepo->expects($this->exactly(2)) |
95 | ->method('findByUrlAndUserId') | 98 | ->method('findByUrlAndUserId') |
96 | ->will($this->onConsecutiveCalls(false, false)); | 99 | ->will($this->onConsecutiveCalls(false, true)); |
97 | 100 | ||
98 | $this->em | 101 | $this->em |
99 | ->expects($this->any()) | 102 | ->expects($this->any()) |
@@ -101,7 +104,7 @@ class ReadabilityImportTest extends \PHPUnit_Framework_TestCase | |||
101 | ->willReturn($entryRepo); | 104 | ->willReturn($entryRepo); |
102 | 105 | ||
103 | $this->contentProxy | 106 | $this->contentProxy |
104 | ->expects($this->exactly(2)) | 107 | ->expects($this->exactly(1)) |
105 | ->method('updateEntry') | 108 | ->method('updateEntry') |
106 | ->willReturn(new Entry($this->user)); | 109 | ->willReturn(new Entry($this->user)); |
107 | 110 | ||
@@ -117,7 +120,87 @@ class ReadabilityImportTest extends \PHPUnit_Framework_TestCase | |||
117 | 120 | ||
118 | $this->assertTrue($res); | 121 | $this->assertTrue($res); |
119 | 122 | ||
120 | $this->assertEquals(['skipped' => 0, 'imported' => 2], $readabilityImport->getSummary()); | 123 | $this->assertEquals(['skipped' => 1, 'imported' => 1, 'queued' => 0], $readabilityImport->getSummary()); |
124 | } | ||
125 | |||
126 | public function testImportWithRabbit() | ||
127 | { | ||
128 | $readabilityImport = $this->getReadabilityImport(); | ||
129 | $readabilityImport->setFilepath(__DIR__.'/../fixtures/readability.json'); | ||
130 | |||
131 | $entryRepo = $this->getMockBuilder('Wallabag\CoreBundle\Repository\EntryRepository') | ||
132 | ->disableOriginalConstructor() | ||
133 | ->getMock(); | ||
134 | |||
135 | $entryRepo->expects($this->never()) | ||
136 | ->method('findByUrlAndUserId'); | ||
137 | |||
138 | $this->em | ||
139 | ->expects($this->never()) | ||
140 | ->method('getRepository'); | ||
141 | |||
142 | $entry = $this->getMockBuilder('Wallabag\CoreBundle\Entity\Entry') | ||
143 | ->disableOriginalConstructor() | ||
144 | ->getMock(); | ||
145 | |||
146 | $this->contentProxy | ||
147 | ->expects($this->never()) | ||
148 | ->method('updateEntry'); | ||
149 | |||
150 | $producer = $this->getMockBuilder('OldSound\RabbitMqBundle\RabbitMq\Producer') | ||
151 | ->disableOriginalConstructor() | ||
152 | ->getMock(); | ||
153 | |||
154 | $producer | ||
155 | ->expects($this->exactly(24)) | ||
156 | ->method('publish'); | ||
157 | |||
158 | $readabilityImport->setProducer($producer); | ||
159 | |||
160 | $res = $readabilityImport->setMarkAsRead(true)->import(); | ||
161 | |||
162 | $this->assertTrue($res); | ||
163 | $this->assertEquals(['skipped' => 0, 'imported' => 0, 'queued' => 24], $readabilityImport->getSummary()); | ||
164 | } | ||
165 | |||
166 | public function testImportWithRedis() | ||
167 | { | ||
168 | $readabilityImport = $this->getReadabilityImport(); | ||
169 | $readabilityImport->setFilepath(__DIR__.'/../fixtures/readability.json'); | ||
170 | |||
171 | $entryRepo = $this->getMockBuilder('Wallabag\CoreBundle\Repository\EntryRepository') | ||
172 | ->disableOriginalConstructor() | ||
173 | ->getMock(); | ||
174 | |||
175 | $entryRepo->expects($this->never()) | ||
176 | ->method('findByUrlAndUserId'); | ||
177 | |||
178 | $this->em | ||
179 | ->expects($this->never()) | ||
180 | ->method('getRepository'); | ||
181 | |||
182 | $entry = $this->getMockBuilder('Wallabag\CoreBundle\Entity\Entry') | ||
183 | ->disableOriginalConstructor() | ||
184 | ->getMock(); | ||
185 | |||
186 | $this->contentProxy | ||
187 | ->expects($this->never()) | ||
188 | ->method('updateEntry'); | ||
189 | |||
190 | $factory = new RedisMockFactory(); | ||
191 | $redisMock = $factory->getAdapter('Predis\Client', true); | ||
192 | |||
193 | $queue = new RedisQueue($redisMock, 'readability'); | ||
194 | $producer = new Producer($queue); | ||
195 | |||
196 | $readabilityImport->setProducer($producer); | ||
197 | |||
198 | $res = $readabilityImport->setMarkAsRead(true)->import(); | ||
199 | |||
200 | $this->assertTrue($res); | ||
201 | $this->assertEquals(['skipped' => 0, 'imported' => 0, 'queued' => 24], $readabilityImport->getSummary()); | ||
202 | |||
203 | $this->assertNotEmpty($redisMock->lpop('readability')); | ||
121 | } | 204 | } |
122 | 205 | ||
123 | public function testImportBadFile() | 206 | public function testImportBadFile() |
diff --git a/tests/Wallabag/ImportBundle/Import/WallabagV1ImportTest.php b/tests/Wallabag/ImportBundle/Import/WallabagV1ImportTest.php index bdc47dac..5ab4ad00 100644 --- a/tests/Wallabag/ImportBundle/Import/WallabagV1ImportTest.php +++ b/tests/Wallabag/ImportBundle/Import/WallabagV1ImportTest.php | |||
@@ -5,8 +5,11 @@ namespace Tests\Wallabag\ImportBundle\Import; | |||
5 | use Wallabag\ImportBundle\Import\WallabagV1Import; | 5 | use Wallabag\ImportBundle\Import\WallabagV1Import; |
6 | use Wallabag\UserBundle\Entity\User; | 6 | use Wallabag\UserBundle\Entity\User; |
7 | use Wallabag\CoreBundle\Entity\Entry; | 7 | use Wallabag\CoreBundle\Entity\Entry; |
8 | use Wallabag\ImportBundle\Redis\Producer; | ||
8 | use Monolog\Logger; | 9 | use Monolog\Logger; |
9 | use Monolog\Handler\TestHandler; | 10 | use Monolog\Handler\TestHandler; |
11 | use Simpleue\Queue\RedisQueue; | ||
12 | use M6Web\Component\RedisMock\RedisMockFactory; | ||
10 | 13 | ||
11 | class WallabagV1ImportTest extends \PHPUnit_Framework_TestCase | 14 | class WallabagV1ImportTest extends \PHPUnit_Framework_TestCase |
12 | { | 15 | { |
@@ -79,7 +82,7 @@ class WallabagV1ImportTest extends \PHPUnit_Framework_TestCase | |||
79 | $res = $wallabagV1Import->import(); | 82 | $res = $wallabagV1Import->import(); |
80 | 83 | ||
81 | $this->assertTrue($res); | 84 | $this->assertTrue($res); |
82 | $this->assertEquals(['skipped' => 1, 'imported' => 3], $wallabagV1Import->getSummary()); | 85 | $this->assertEquals(['skipped' => 1, 'imported' => 3, 'queued' => 0], $wallabagV1Import->getSummary()); |
83 | } | 86 | } |
84 | 87 | ||
85 | public function testImportAndMarkAllAsRead() | 88 | public function testImportAndMarkAllAsRead() |
@@ -117,7 +120,87 @@ class WallabagV1ImportTest extends \PHPUnit_Framework_TestCase | |||
117 | 120 | ||
118 | $this->assertTrue($res); | 121 | $this->assertTrue($res); |
119 | 122 | ||
120 | $this->assertEquals(['skipped' => 0, 'imported' => 3], $wallabagV1Import->getSummary()); | 123 | $this->assertEquals(['skipped' => 0, 'imported' => 3, 'queued' => 0], $wallabagV1Import->getSummary()); |
124 | } | ||
125 | |||
126 | public function testImportWithRabbit() | ||
127 | { | ||
128 | $wallabagV1Import = $this->getWallabagV1Import(); | ||
129 | $wallabagV1Import->setFilepath(__DIR__.'/../fixtures/wallabag-v1.json'); | ||
130 | |||
131 | $entryRepo = $this->getMockBuilder('Wallabag\CoreBundle\Repository\EntryRepository') | ||
132 | ->disableOriginalConstructor() | ||
133 | ->getMock(); | ||
134 | |||
135 | $entryRepo->expects($this->never()) | ||
136 | ->method('findByUrlAndUserId'); | ||
137 | |||
138 | $this->em | ||
139 | ->expects($this->never()) | ||
140 | ->method('getRepository'); | ||
141 | |||
142 | $entry = $this->getMockBuilder('Wallabag\CoreBundle\Entity\Entry') | ||
143 | ->disableOriginalConstructor() | ||
144 | ->getMock(); | ||
145 | |||
146 | $this->contentProxy | ||
147 | ->expects($this->never()) | ||
148 | ->method('updateEntry'); | ||
149 | |||
150 | $producer = $this->getMockBuilder('OldSound\RabbitMqBundle\RabbitMq\Producer') | ||
151 | ->disableOriginalConstructor() | ||
152 | ->getMock(); | ||
153 | |||
154 | $producer | ||
155 | ->expects($this->exactly(4)) | ||
156 | ->method('publish'); | ||
157 | |||
158 | $wallabagV1Import->setProducer($producer); | ||
159 | |||
160 | $res = $wallabagV1Import->setMarkAsRead(true)->import(); | ||
161 | |||
162 | $this->assertTrue($res); | ||
163 | $this->assertEquals(['skipped' => 0, 'imported' => 0, 'queued' => 4], $wallabagV1Import->getSummary()); | ||
164 | } | ||
165 | |||
166 | public function testImportWithRedis() | ||
167 | { | ||
168 | $wallabagV1Import = $this->getWallabagV1Import(); | ||
169 | $wallabagV1Import->setFilepath(__DIR__.'/../fixtures/wallabag-v1.json'); | ||
170 | |||
171 | $entryRepo = $this->getMockBuilder('Wallabag\CoreBundle\Repository\EntryRepository') | ||
172 | ->disableOriginalConstructor() | ||
173 | ->getMock(); | ||
174 | |||
175 | $entryRepo->expects($this->never()) | ||
176 | ->method('findByUrlAndUserId'); | ||
177 | |||
178 | $this->em | ||
179 | ->expects($this->never()) | ||
180 | ->method('getRepository'); | ||
181 | |||
182 | $entry = $this->getMockBuilder('Wallabag\CoreBundle\Entity\Entry') | ||
183 | ->disableOriginalConstructor() | ||
184 | ->getMock(); | ||
185 | |||
186 | $this->contentProxy | ||
187 | ->expects($this->never()) | ||
188 | ->method('updateEntry'); | ||
189 | |||
190 | $factory = new RedisMockFactory(); | ||
191 | $redisMock = $factory->getAdapter('Predis\Client', true); | ||
192 | |||
193 | $queue = new RedisQueue($redisMock, 'wallabag_v1'); | ||
194 | $producer = new Producer($queue); | ||
195 | |||
196 | $wallabagV1Import->setProducer($producer); | ||
197 | |||
198 | $res = $wallabagV1Import->setMarkAsRead(true)->import(); | ||
199 | |||
200 | $this->assertTrue($res); | ||
201 | $this->assertEquals(['skipped' => 0, 'imported' => 0, 'queued' => 4], $wallabagV1Import->getSummary()); | ||
202 | |||
203 | $this->assertNotEmpty($redisMock->lpop('wallabag_v1')); | ||
121 | } | 204 | } |
122 | 205 | ||
123 | public function testImportBadFile() | 206 | public function testImportBadFile() |
diff --git a/tests/Wallabag/ImportBundle/Import/WallabagV2ImportTest.php b/tests/Wallabag/ImportBundle/Import/WallabagV2ImportTest.php index 4a45e0f0..12bd6bdd 100644 --- a/tests/Wallabag/ImportBundle/Import/WallabagV2ImportTest.php +++ b/tests/Wallabag/ImportBundle/Import/WallabagV2ImportTest.php | |||
@@ -5,8 +5,11 @@ namespace Tests\Wallabag\ImportBundle\Import; | |||
5 | use Wallabag\ImportBundle\Import\WallabagV2Import; | 5 | use Wallabag\ImportBundle\Import\WallabagV2Import; |
6 | use Wallabag\UserBundle\Entity\User; | 6 | use Wallabag\UserBundle\Entity\User; |
7 | use Wallabag\CoreBundle\Entity\Entry; | 7 | use Wallabag\CoreBundle\Entity\Entry; |
8 | use Wallabag\ImportBundle\Redis\Producer; | ||
8 | use Monolog\Logger; | 9 | use Monolog\Logger; |
9 | use Monolog\Handler\TestHandler; | 10 | use Monolog\Handler\TestHandler; |
11 | use Simpleue\Queue\RedisQueue; | ||
12 | use M6Web\Component\RedisMock\RedisMockFactory; | ||
10 | 13 | ||
11 | class WallabagV2ImportTest extends \PHPUnit_Framework_TestCase | 14 | class WallabagV2ImportTest extends \PHPUnit_Framework_TestCase |
12 | { | 15 | { |
@@ -75,7 +78,7 @@ class WallabagV2ImportTest extends \PHPUnit_Framework_TestCase | |||
75 | $res = $wallabagV2Import->import(); | 78 | $res = $wallabagV2Import->import(); |
76 | 79 | ||
77 | $this->assertTrue($res); | 80 | $this->assertTrue($res); |
78 | $this->assertEquals(['skipped' => 22, 'imported' => 2], $wallabagV2Import->getSummary()); | 81 | $this->assertEquals(['skipped' => 22, 'imported' => 2, 'queued' => 0], $wallabagV2Import->getSummary()); |
79 | } | 82 | } |
80 | 83 | ||
81 | public function testImportAndMarkAllAsRead() | 84 | public function testImportAndMarkAllAsRead() |
@@ -113,7 +116,79 @@ class WallabagV2ImportTest extends \PHPUnit_Framework_TestCase | |||
113 | 116 | ||
114 | $this->assertTrue($res); | 117 | $this->assertTrue($res); |
115 | 118 | ||
116 | $this->assertEquals(['skipped' => 0, 'imported' => 2], $wallabagV2Import->getSummary()); | 119 | $this->assertEquals(['skipped' => 0, 'imported' => 2, 'queued' => 0], $wallabagV2Import->getSummary()); |
120 | } | ||
121 | |||
122 | public function testImportWithRabbit() | ||
123 | { | ||
124 | $wallabagV2Import = $this->getWallabagV2Import(); | ||
125 | $wallabagV2Import->setFilepath(__DIR__.'/../fixtures/wallabag-v2.json'); | ||
126 | |||
127 | $entryRepo = $this->getMockBuilder('Wallabag\CoreBundle\Repository\EntryRepository') | ||
128 | ->disableOriginalConstructor() | ||
129 | ->getMock(); | ||
130 | |||
131 | $entryRepo->expects($this->never()) | ||
132 | ->method('findByUrlAndUserId'); | ||
133 | |||
134 | $this->em | ||
135 | ->expects($this->never()) | ||
136 | ->method('getRepository'); | ||
137 | |||
138 | $this->contentProxy | ||
139 | ->expects($this->never()) | ||
140 | ->method('updateEntry'); | ||
141 | |||
142 | $producer = $this->getMockBuilder('OldSound\RabbitMqBundle\RabbitMq\Producer') | ||
143 | ->disableOriginalConstructor() | ||
144 | ->getMock(); | ||
145 | |||
146 | $producer | ||
147 | ->expects($this->exactly(24)) | ||
148 | ->method('publish'); | ||
149 | |||
150 | $wallabagV2Import->setProducer($producer); | ||
151 | |||
152 | $res = $wallabagV2Import->setMarkAsRead(true)->import(); | ||
153 | |||
154 | $this->assertTrue($res); | ||
155 | $this->assertEquals(['skipped' => 0, 'imported' => 0, 'queued' => 24], $wallabagV2Import->getSummary()); | ||
156 | } | ||
157 | |||
158 | public function testImportWithRedis() | ||
159 | { | ||
160 | $wallabagV2Import = $this->getWallabagV2Import(); | ||
161 | $wallabagV2Import->setFilepath(__DIR__.'/../fixtures/wallabag-v2.json'); | ||
162 | |||
163 | $entryRepo = $this->getMockBuilder('Wallabag\CoreBundle\Repository\EntryRepository') | ||
164 | ->disableOriginalConstructor() | ||
165 | ->getMock(); | ||
166 | |||
167 | $entryRepo->expects($this->never()) | ||
168 | ->method('findByUrlAndUserId'); | ||
169 | |||
170 | $this->em | ||
171 | ->expects($this->never()) | ||
172 | ->method('getRepository'); | ||
173 | |||
174 | $this->contentProxy | ||
175 | ->expects($this->never()) | ||
176 | ->method('updateEntry'); | ||
177 | |||
178 | $factory = new RedisMockFactory(); | ||
179 | $redisMock = $factory->getAdapter('Predis\Client', true); | ||
180 | |||
181 | $queue = new RedisQueue($redisMock, 'wallabag_v2'); | ||
182 | $producer = new Producer($queue); | ||
183 | |||
184 | $wallabagV2Import->setProducer($producer); | ||
185 | |||
186 | $res = $wallabagV2Import->setMarkAsRead(true)->import(); | ||
187 | |||
188 | $this->assertTrue($res); | ||
189 | $this->assertEquals(['skipped' => 0, 'imported' => 0, 'queued' => 24], $wallabagV2Import->getSummary()); | ||
190 | |||
191 | $this->assertNotEmpty($redisMock->lpop('wallabag_v2')); | ||
117 | } | 192 | } |
118 | 193 | ||
119 | public function testImportBadFile() | 194 | public function testImportBadFile() |
@@ -152,7 +227,7 @@ class WallabagV2ImportTest extends \PHPUnit_Framework_TestCase | |||
152 | $res = $wallabagV2Import->import(); | 227 | $res = $wallabagV2Import->import(); |
153 | 228 | ||
154 | $this->assertFalse($res); | 229 | $this->assertFalse($res); |
155 | $this->assertEquals(['skipped' => 0, 'imported' => 0], $wallabagV2Import->getSummary()); | 230 | $this->assertEquals(['skipped' => 0, 'imported' => 0, 'queued' => 0], $wallabagV2Import->getSummary()); |
156 | } | 231 | } |
157 | 232 | ||
158 | public function testImportWithExceptionFromGraby() | 233 | public function testImportWithExceptionFromGraby() |
@@ -181,6 +256,6 @@ class WallabagV2ImportTest extends \PHPUnit_Framework_TestCase | |||
181 | $res = $wallabagV2Import->import(); | 256 | $res = $wallabagV2Import->import(); |
182 | 257 | ||
183 | $this->assertTrue($res); | 258 | $this->assertTrue($res); |
184 | $this->assertEquals(['skipped' => 24, 'imported' => 0], $wallabagV2Import->getSummary()); | 259 | $this->assertEquals(['skipped' => 22, 'imported' => 2, 'queued' => 0], $wallabagV2Import->getSummary()); |
185 | } | 260 | } |
186 | } | 261 | } |
diff --git a/tests/Wallabag/ImportBundle/fixtures/readability.json b/tests/Wallabag/ImportBundle/fixtures/readability.json index 34379905..32f6fa53 100644 --- a/tests/Wallabag/ImportBundle/fixtures/readability.json +++ b/tests/Wallabag/ImportBundle/fixtures/readability.json | |||
@@ -11,14 +11,165 @@ | |||
11 | "archive": false | 11 | "archive": false |
12 | }, | 12 | }, |
13 | { | 13 | { |
14 | "article__excerpt": "TL;DR: Re-use your DOM elements and remove the ones that are far away from the viewport. Use placeholders to account for delayed data. Here’s a demo and the code for the infinite…", | 14 | "article__title": "Réfugiés: l'UE va créer 100 000 places d'accueil dans les Balkans", |
15 | "favorite": false, | 15 | "article__url": "http://www.liberation.fr/planete/2015/10/26/refugies-l-ue-va-creer-100-000-places-d-accueil-dans-les-balkans_1408867", |
16 | "date_archived": "2016-08-26T12:21:54", | 16 | "archive": false, |
17 | "article__url": "https://developers.google.com/web/updates/2016/07/infinite-scroller?imm_mid=0e6839&cmp=em-webops-na-na-newsltr_20160805", | 17 | "date_added": "2016-09-08T11:55:58+0200", |
18 | "date_added": "2016-08-06T05:35:26", | 18 | "favorite": false |
19 | "date_favorited": null, | 19 | }, |
20 | "article__title": "Complexities of an infinite scroller | Web Updates", | 20 | { |
21 | "archive": true | 21 | "article__title": "No title found", |
22 | "article__url": "http://news.nationalgeographic.com/2016/02/160211-albatrosses-mothers-babies-animals-science/&sf20739758=1", | ||
23 | "archive": false, | ||
24 | "date_added": "2016-09-08T11:55:58+0200", | ||
25 | "favorite": true | ||
26 | }, | ||
27 | { | ||
28 | "archive": 0, | ||
29 | "date_added": "2016-09-08T11:55:58+0200", | ||
30 | "favorite": 0, | ||
31 | "article__title": "Échecs", | ||
32 | "article__url": "https://fr.wikipedia.org/wiki/Échecs" | ||
33 | }, | ||
34 | { | ||
35 | "archive": 0, | ||
36 | "date_added": "2016-09-08T11:55:58+0200", | ||
37 | "favorite": 0, | ||
38 | "article__title": "90% des dossiers médicaux des Coréens du sud vendus à des entreprises privées - ZATAZ", | ||
39 | "article__url": "http://www.zataz.com/90-des-dossiers-medicaux-des-coreens-du-sud-vendus-a-des-entreprises-privees/" | ||
40 | }, | ||
41 | { | ||
42 | "archive": 0, | ||
43 | "date_added": "2016-09-08T11:55:58+0200", | ||
44 | "favorite": 0, | ||
45 | "article__title": "Mass Surveillance As Art", | ||
46 | "article__url": "https://www.nationaljournal.com/s/73311/mass-surveillance-art" | ||
47 | }, | ||
48 | { | ||
49 | "archive": 0, | ||
50 | "date_added": "2016-09-08T11:55:58+0200", | ||
51 | "favorite": 0, | ||
52 | "article__title": "What David Cameron did to the pig, his party is now doing to the country", | ||
53 | "article__url": "http://www.newstatesman.com/2015/09/what-david-cameron-did-pig-his-party-now-doing-country" | ||
54 | }, | ||
55 | { | ||
56 | "archive": 1, | ||
57 | "date_added": "2016-09-08T11:55:58+0200", | ||
58 | "favorite": 0, | ||
59 | "article__title": "CLICK HERE to support 2016 CES Winner, Revolutionary Auto-Tracking Robot", | ||
60 | "article__url": "https://www.indiegogo.com/projects/2016-ces-winner-revolutionary-auto-tracking-robot" | ||
61 | }, | ||
62 | { | ||
63 | "archive": 0, | ||
64 | "date_added": "2016-09-08T11:55:58+0200", | ||
65 | "favorite": 1, | ||
66 | "article__title": "No title found", | ||
67 | "article__url": "http://carnetdevol.shost.ca/wordpress/aide-memoire-sur-les-commandes-associees-a-systemd/" | ||
68 | }, | ||
69 | { | ||
70 | "archive": 1, | ||
71 | "date_added": "2016-09-08T11:55:58+0200", | ||
72 | "favorite": 0, | ||
73 | "article__title": "Présentation d'Arduino - Tuto Arduino - Le blog d'Eskimon", | ||
74 | "article__url": "http://eskimon.fr/73-arduino-101-presentation" | ||
75 | }, | ||
76 | { | ||
77 | "archive": 1, | ||
78 | "date_added": "2016-09-08T11:55:58+0200", | ||
79 | "favorite": 0, | ||
80 | "article__title": "Lenovo ThinkPad X1 Carbon Ultrabook Review", | ||
81 | "article__url": "http://www.notebookcheck.net/Lenovo-ThinkPad-X1-Carbon-Ultrabook-Review.138033.0.html" | ||
82 | }, | ||
83 | { | ||
84 | "archive": 0, | ||
85 | "date_added": "2016-09-08T11:55:58+0200", | ||
86 | "favorite": 0, | ||
87 | "article__title": "Visitons le Château de Landsberg !", | ||
88 | "article__url": "http://autour-du-mont-sainte-odile.overblog.com/2016/01/visitons-le-chateau-de-landsberg.html" | ||
89 | }, | ||
90 | { | ||
91 | "archive": 1, | ||
92 | "date_added": "2016-09-08T11:55:58+0200", | ||
93 | "favorite": 0, | ||
94 | "article__title": "Contrer les stéréotypes par les livres : “C'est dès l'enfance qu'ils se construisent”", | ||
95 | "article__url": "https://www.actualitte.com/article/monde-edition/contrer-les-stereotypes-par-les-livres-c-est-des-l-enfance-qu-ils-se-construisent/64058" | ||
96 | }, | ||
97 | { | ||
98 | "archive": 1, | ||
99 | "date_added": "2016-09-08T11:55:58+0200", | ||
100 | "favorite": 0, | ||
101 | "article__title": "[ROM][6.0.1][Layers][N5] TipsyOS official builds {UBER TCs}", | ||
102 | "article__url": "http://forum.xda-developers.com/google-nexus-5/development/rom-tipsyos-official-builds-uber-tcs-t3325989" | ||
103 | }, | ||
104 | { | ||
105 | "archive": 0, | ||
106 | "date_added": "2016-09-08T11:55:58+0200", | ||
107 | "favorite": 0, | ||
108 | "article__title": "Top 15 Podcasts All Web Developers Should Follow - Envato Tuts+ Code Article", | ||
109 | "article__url": "http://code.tutsplus.com/articles/top-15-podcasts-all-web-developers-should-follow--net-14461" | ||
110 | }, | ||
111 | { | ||
112 | "archive": 1, | ||
113 | "date_added": "2016-09-08T11:55:58+0200", | ||
114 | "favorite": 0, | ||
115 | "article__title": "University of Mississippi", | ||
116 | "article__url": "http://olemiss.edu" | ||
117 | }, | ||
118 | { | ||
119 | "archive": 1, | ||
120 | "date_added": "2016-09-08T11:55:58+0200", | ||
121 | "favorite": 0, | ||
122 | "article__title": "FinnChristiansen.de Jetzt Dank Let’s Encrypt Per HTTPS Erreichbar", | ||
123 | "article__url": "https://www.finnchristiansen.de/2015/12/06/finnchristiansen-de-jetzt-dank-lets-encrypt-per-https-erreichbar/" | ||
124 | }, | ||
125 | { | ||
126 | "archive": 1, | ||
127 | "date_added": "2016-09-08T11:55:58+0200", | ||
128 | "favorite": 0, | ||
129 | "article__title": "Le développeur et l'ingénierie logicielle", | ||
130 | "article__url": "http://wemucs.com/le-developpeur-et-lingenierie-logicielle/" | ||
131 | }, | ||
132 | { | ||
133 | "archive": 1, | ||
134 | "date_added": "2016-09-08T11:55:58+0200", | ||
135 | "favorite": 0, | ||
136 | "article__title": "The Role of Methylation in Gene Expression", | ||
137 | "article__url": "http://www.nature.com/scitable/topicpage/the-role-of-methylation-in-gene-expression-1070" | ||
138 | }, | ||
139 | { | ||
140 | "archive": 1, | ||
141 | "date_added": "2016-09-08T11:55:58+0200", | ||
142 | "favorite": 0, | ||
143 | "article__title": "E-Mail-Adresse kostenlos, FreeMail, De-Mail & Nachrichten", | ||
144 | "article__url": "http://web.de" | ||
145 | }, | ||
146 | { | ||
147 | "archive": 1, | ||
148 | "date_added": "2016-09-08T11:55:58+0200", | ||
149 | "favorite": 0, | ||
150 | "article__title": "OpenSSH Server on Arch Linux | DominicM test", | ||
151 | "article__url": "http://dominicm.com/openssh-server-arch-linux/" | ||
152 | }, | ||
153 | { | ||
154 | "archive": 1, | ||
155 | "date_added": "2016-09-08T11:55:58+0200", | ||
156 | "favorite": 0, | ||
157 | "article__title": "Site Moved | Site Help", | ||
158 | "article__url": "http://g1.com/help/sitemoved.asp" | ||
159 | }, | ||
160 | { | ||
161 | "archive": 1, | ||
162 | "date_added": "2016-09-08T11:55:58+0200", | ||
163 | "favorite": 0, | ||
164 | "article__title": "#Maroc : le stylo anti-pédophiles EAGLE d’AMESYS est moins bien configuré que les faux-lowers Twitter du roi Mohammed VI", | ||
165 | "article__url": "https://reflets.info/maroc-le-stylo-anti-pedophiles-eagle-damesys-est-moins-bien-configure-que-les-faux-lowers-twitter-du-roi-mohammed-vi/" | ||
166 | }, | ||
167 | { | ||
168 | "archive": 1, | ||
169 | "date_added": "2016-09-08T11:55:58+0200", | ||
170 | "favorite": 0, | ||
171 | "article__title": "Simple Cloud Infrastructure for Developers", | ||
172 | "article__url": "https://www.digitalocean.com/" | ||
22 | } | 173 | } |
23 | ], | 174 | ], |
24 | "recommendations": [] | 175 | "recommendations": [] |