diff options
11 files changed, 71 insertions, 101 deletions
diff --git a/src/Wallabag/CoreBundle/Helper/ContentProxy.php b/src/Wallabag/CoreBundle/Helper/ContentProxy.php index e6292744..3024fdc5 100644 --- a/src/Wallabag/CoreBundle/Helper/ContentProxy.php +++ b/src/Wallabag/CoreBundle/Helper/ContentProxy.php | |||
@@ -7,7 +7,6 @@ use Psr\Log\LoggerInterface; | |||
7 | use Wallabag\CoreBundle\Entity\Entry; | 7 | use Wallabag\CoreBundle\Entity\Entry; |
8 | use Wallabag\CoreBundle\Tools\Utils; | 8 | use Wallabag\CoreBundle\Tools\Utils; |
9 | use Symfony\Component\HttpFoundation\File\MimeType\MimeTypeExtensionGuesser; | 9 | use Symfony\Component\HttpFoundation\File\MimeType\MimeTypeExtensionGuesser; |
10 | use Symfony\Component\Config\Definition\Exception\Exception; | ||
11 | 10 | ||
12 | /** | 11 | /** |
13 | * This kind of proxy class take care of getting the content from an url | 12 | * This kind of proxy class take care of getting the content from an url |
@@ -32,57 +31,40 @@ class ContentProxy | |||
32 | } | 31 | } |
33 | 32 | ||
34 | /** | 33 | /** |
35 | * Update existing entry by fetching from URL using Graby. | 34 | * Update entry using either fetched or provided content. |
36 | * | 35 | * |
37 | * @param Entry $entry Entry to update | 36 | * @param Entry $entry Entry to update |
38 | * @param string $url Url to grab content for | 37 | * @param string $url Url of the content |
38 | * @param array $content Array with content provided for import with AT LEAST keys title, html, url to skip the fetchContent from the url | ||
39 | * @param bool $disableContentUpdate Whether to skip trying to fetch content using Graby | ||
39 | */ | 40 | */ |
40 | public function updateEntry(Entry $entry, $url) | 41 | public function updateEntry(Entry $entry, $url, array $content = [], $disableContentUpdate = false) |
41 | { | 42 | { |
42 | $content = $this->graby->fetchContent($url); | 43 | if (!empty($content['html'])) { |
43 | 44 | $content['html'] = $this->graby->cleanupHtml($content['html'], $url); | |
44 | // be sure to keep the url in case of error | ||
45 | // so we'll be able to refetch it in the future | ||
46 | $content['url'] = $content['url'] ?: $url; | ||
47 | |||
48 | $this->stockEntry($entry, $content); | ||
49 | } | ||
50 | |||
51 | /** | ||
52 | * Import entry using either fetched or provided content. | ||
53 | * | ||
54 | * @param Entry $entry Entry to update | ||
55 | * @param array $content Array with content provided for import with AT LEAST keys title, html, url to skip the fetchContent from the url | ||
56 | * @param bool $disableContentUpdate Whether to skip trying to fetch content using Graby | ||
57 | */ | ||
58 | public function importEntry(Entry $entry, array $content, $disableContentUpdate = false) | ||
59 | { | ||
60 | try { | ||
61 | $this->validateContent($content); | ||
62 | } catch (\Exception $e) { | ||
63 | // validation failed but do we want to disable updating content? | ||
64 | if (true === $disableContentUpdate) { | ||
65 | throw $e; | ||
66 | } | ||
67 | } | 45 | } |
68 | 46 | ||
69 | if (false === $disableContentUpdate) { | 47 | if ((empty($content) || false === $this->validateContent($content)) && false === $disableContentUpdate) { |
70 | try { | 48 | try { |
71 | $fetchedContent = $this->graby->fetchContent($content['url']); | 49 | $fetchedContent = $this->graby->fetchContent($url); |
72 | } catch (\Exception $e) { | 50 | } catch (\Exception $e) { |
73 | $this->logger->error('Error while trying to fetch content from URL.', [ | 51 | $this->logger->error('Error while trying to fetch content from URL.', [ |
74 | 'entry_url' => $content['url'], | 52 | 'entry_url' => $url, |
75 | 'error_msg' => $e->getMessage(), | 53 | 'error_msg' => $e->getMessage(), |
76 | ]); | 54 | ]); |
77 | } | 55 | } |
78 | 56 | ||
79 | // when content is imported, we have information in $content | 57 | // when content is imported, we have information in $content |
80 | // in case fetching content goes bad, we'll keep the imported information instead of overriding them | 58 | // in case fetching content goes bad, we'll keep the imported information instead of overriding them |
81 | if ($fetchedContent['html'] !== $this->fetchingErrorMessage) { | 59 | if (empty($content) || $fetchedContent['html'] !== $this->fetchingErrorMessage) { |
82 | $content = $fetchedContent; | 60 | $content = $fetchedContent; |
83 | } | 61 | } |
84 | } | 62 | } |
85 | 63 | ||
64 | // be sure to keep the url in case of error | ||
65 | // so we'll be able to refetch it in the future | ||
66 | $content['url'] = !empty($content['url']) ? $content['url'] : $url; | ||
67 | |||
86 | $this->stockEntry($entry, $content); | 68 | $this->stockEntry($entry, $content); |
87 | } | 69 | } |
88 | 70 | ||
@@ -126,7 +108,7 @@ class ContentProxy | |||
126 | try { | 108 | try { |
127 | $entry->setPublishedAt(new \DateTime($date)); | 109 | $entry->setPublishedAt(new \DateTime($date)); |
128 | } catch (\Exception $e) { | 110 | } catch (\Exception $e) { |
129 | $this->logger->warning('Error while defining date', ['e' => $e, 'url' => $url, 'date' => $content['date']]); | 111 | $this->logger->warning('Error while defining date', ['e' => $e, 'url' => $content['url'], 'date' => $content['date']]); |
130 | } | 112 | } |
131 | } | 113 | } |
132 | 114 | ||
@@ -170,19 +152,11 @@ class ContentProxy | |||
170 | * Validate that the given content has at least a title, an html and a url. | 152 | * Validate that the given content has at least a title, an html and a url. |
171 | * | 153 | * |
172 | * @param array $content | 154 | * @param array $content |
155 | * | ||
156 | * @return bool true if valid otherwise false | ||
173 | */ | 157 | */ |
174 | private function validateContent(array $content) | 158 | private function validateContent(array $content) |
175 | { | 159 | { |
176 | if (empty($content['title'])) { | 160 | return !empty($content['title']) && !empty($content['html']) && !empty($content['url']); |
177 | throw new Exception('Missing title from imported entry!'); | ||
178 | } | ||
179 | |||
180 | if (empty($content['url'])) { | ||
181 | throw new Exception('Missing URL from imported entry!'); | ||
182 | } | ||
183 | |||
184 | if (empty($content['html'])) { | ||
185 | throw new Exception('Missing html from imported entry!'); | ||
186 | } | ||
187 | } | 161 | } |
188 | } | 162 | } |
diff --git a/src/Wallabag/ImportBundle/Import/AbstractImport.php b/src/Wallabag/ImportBundle/Import/AbstractImport.php index bf568a1a..9f3d822a 100644 --- a/src/Wallabag/ImportBundle/Import/AbstractImport.php +++ b/src/Wallabag/ImportBundle/Import/AbstractImport.php | |||
@@ -115,14 +115,11 @@ abstract class AbstractImport implements ImportInterface | |||
115 | */ | 115 | */ |
116 | protected function fetchContent(Entry $entry, $url, array $content = []) | 116 | protected function fetchContent(Entry $entry, $url, array $content = []) |
117 | { | 117 | { |
118 | // be sure to set at least the given url | ||
119 | $content['url'] = isset($content['url']) ? $content['url'] : $url; | ||
120 | |||
121 | try { | 118 | try { |
122 | $this->contentProxy->importEntry($entry, $content, $this->disableContentUpdate); | 119 | $this->contentProxy->updateEntry($entry, $url, $content, $this->disableContentUpdate); |
123 | } catch (\Exception $e) { | 120 | } catch (\Exception $e) { |
124 | $this->logger->error('Error trying to import an entry.', [ | 121 | $this->logger->error('Error trying to import an entry.', [ |
125 | 'entry_url' => $content['url'], | 122 | 'entry_url' => $url, |
126 | 'error_msg' => $e->getMessage(), | 123 | 'error_msg' => $e->getMessage(), |
127 | ]); | 124 | ]); |
128 | } | 125 | } |
diff --git a/tests/Wallabag/CoreBundle/Controller/TagControllerTest.php b/tests/Wallabag/CoreBundle/Controller/TagControllerTest.php index f9bf7b87..af1ad7af 100644 --- a/tests/Wallabag/CoreBundle/Controller/TagControllerTest.php +++ b/tests/Wallabag/CoreBundle/Controller/TagControllerTest.php | |||
@@ -123,7 +123,7 @@ class TagControllerTest extends WallabagCoreTestCase | |||
123 | $this->assertEquals(302, $client->getResponse()->getStatusCode()); | 123 | $this->assertEquals(302, $client->getResponse()->getStatusCode()); |
124 | $this->assertEquals($entryUri, $client->getResponse()->getTargetUrl()); | 124 | $this->assertEquals($entryUri, $client->getResponse()->getTargetUrl()); |
125 | 125 | ||
126 | // re-retrieve the entry to be sure to get fresh data from database (mostly for tags) | 126 | // re-retrieve the entry to be sure to get fresh data from database (mostly for tags) |
127 | $entry = $this->getEntityManager()->getRepository(Entry::class)->find($entry->getId()); | 127 | $entry = $this->getEntityManager()->getRepository(Entry::class)->find($entry->getId()); |
128 | $this->assertNotContains($this->tagName, $entry->getTags()); | 128 | $this->assertNotContains($this->tagName, $entry->getTags()); |
129 | 129 | ||
diff --git a/tests/Wallabag/CoreBundle/Helper/ContentProxyTest.php b/tests/Wallabag/CoreBundle/Helper/ContentProxyTest.php index be287d84..a3570125 100644 --- a/tests/Wallabag/CoreBundle/Helper/ContentProxyTest.php +++ b/tests/Wallabag/CoreBundle/Helper/ContentProxyTest.php | |||
@@ -11,8 +11,6 @@ use Wallabag\CoreBundle\Entity\Tag; | |||
11 | use Wallabag\UserBundle\Entity\User; | 11 | use Wallabag\UserBundle\Entity\User; |
12 | use Wallabag\CoreBundle\Helper\RuleBasedTagger; | 12 | use Wallabag\CoreBundle\Helper\RuleBasedTagger; |
13 | use Graby\Graby; | 13 | use Graby\Graby; |
14 | use Monolog\Handler\TestHandler; | ||
15 | use Monolog\Logger; | ||
16 | 14 | ||
17 | class ContentProxyTest extends \PHPUnit_Framework_TestCase | 15 | class ContentProxyTest extends \PHPUnit_Framework_TestCase |
18 | { | 16 | { |
@@ -259,12 +257,13 @@ class ContentProxyTest extends \PHPUnit_Framework_TestCase | |||
259 | ->method('tag'); | 257 | ->method('tag'); |
260 | 258 | ||
261 | $logHandler = new TestHandler(); | 259 | $logHandler = new TestHandler(); |
262 | $logger = new Logger('test', array($logHandler)); | 260 | $logger = new Logger('test', [$logHandler]); |
263 | 261 | ||
264 | $proxy = new ContentProxy((new Graby()), $tagger, $logger, $this->fetchingErrorMessage); | 262 | $proxy = new ContentProxy((new Graby()), $tagger, $logger, $this->fetchingErrorMessage); |
265 | $entry = new Entry(new User()); | 263 | $entry = new Entry(new User()); |
266 | $proxy->importEntry( | 264 | $proxy->updateEntry( |
267 | $entry, | 265 | $entry, |
266 | 'http://1.1.1.1', | ||
268 | [ | 267 | [ |
269 | 'html' => str_repeat('this is my content', 325), | 268 | 'html' => str_repeat('this is my content', 325), |
270 | 'title' => 'this is my title', | 269 | 'title' => 'this is my title', |
@@ -299,6 +298,7 @@ class ContentProxyTest extends \PHPUnit_Framework_TestCase | |||
299 | $entry = new Entry(new User()); | 298 | $entry = new Entry(new User()); |
300 | $proxy->updateEntry( | 299 | $proxy->updateEntry( |
301 | $entry, | 300 | $entry, |
301 | 'http://1.1.1.1', | ||
302 | [ | 302 | [ |
303 | 'html' => str_repeat('this is my content', 325), | 303 | 'html' => str_repeat('this is my content', 325), |
304 | 'title' => 'this is my title', | 304 | 'title' => 'this is my title', |
@@ -326,26 +326,24 @@ class ContentProxyTest extends \PHPUnit_Framework_TestCase | |||
326 | 326 | ||
327 | public function testTaggerThrowException() | 327 | public function testTaggerThrowException() |
328 | { | 328 | { |
329 | $graby = $this->getMockBuilder('Graby\Graby') | ||
330 | ->disableOriginalConstructor() | ||
331 | ->getMock(); | ||
332 | |||
333 | $tagger = $this->getTaggerMock(); | 329 | $tagger = $this->getTaggerMock(); |
334 | $tagger->expects($this->once()) | 330 | $tagger->expects($this->once()) |
335 | ->method('tag') | 331 | ->method('tag') |
336 | ->will($this->throwException(new \Exception())); | 332 | ->will($this->throwException(new \Exception())); |
337 | 333 | ||
338 | $proxy = new ContentProxy($graby, $tagger, $this->getLogger(), $this->fetchingErrorMessage); | 334 | $proxy = new ContentProxy((new Graby()), $tagger, $this->getLogger(), $this->fetchingErrorMessage); |
339 | |||
340 | $entry = new Entry(new User()); | 335 | $entry = new Entry(new User()); |
341 | $content = array( | 336 | $proxy->updateEntry( |
342 | 'html' => str_repeat('this is my content', 325), | 337 | $entry, |
343 | 'title' => 'this is my title', | 338 | 'http://1.1.1.1', |
344 | 'url' => 'http://1.1.1.1', | 339 | [ |
345 | 'content_type' => 'text/html', | 340 | 'html' => str_repeat('this is my content', 325), |
346 | 'language' => 'fr', | 341 | 'title' => 'this is my title', |
342 | 'url' => 'http://1.1.1.1', | ||
343 | 'content_type' => 'text/html', | ||
344 | 'language' => 'fr', | ||
345 | ] | ||
347 | ); | 346 | ); |
348 | $proxy->importEntry($entry, $content, true); | ||
349 | 347 | ||
350 | $this->assertCount(0, $entry->getTags()); | 348 | $this->assertCount(0, $entry->getTags()); |
351 | } | 349 | } |
@@ -374,8 +372,9 @@ class ContentProxyTest extends \PHPUnit_Framework_TestCase | |||
374 | ->method('tag'); | 372 | ->method('tag'); |
375 | 373 | ||
376 | $proxy = new ContentProxy((new Graby()), $tagger, $this->getLogger(), $this->fetchingErrorMessage); | 374 | $proxy = new ContentProxy((new Graby()), $tagger, $this->getLogger(), $this->fetchingErrorMessage); |
377 | $entry = $proxy->updateEntry( | 375 | $entry = new Entry(new User()); |
378 | new Entry(new User()), | 376 | $proxy->updateEntry( |
377 | $entry, | ||
379 | 'http://1.1.1.1', | 378 | 'http://1.1.1.1', |
380 | [ | 379 | [ |
381 | 'html' => $html, | 380 | 'html' => $html, |
diff --git a/tests/Wallabag/ImportBundle/Import/ChromeImportTest.php b/tests/Wallabag/ImportBundle/Import/ChromeImportTest.php index 7a15e918..cec19534 100644 --- a/tests/Wallabag/ImportBundle/Import/ChromeImportTest.php +++ b/tests/Wallabag/ImportBundle/Import/ChromeImportTest.php | |||
@@ -89,7 +89,7 @@ class ChromeImportTest extends \PHPUnit_Framework_TestCase | |||
89 | 89 | ||
90 | $this->contentProxy | 90 | $this->contentProxy |
91 | ->expects($this->exactly(1)) | 91 | ->expects($this->exactly(1)) |
92 | ->method('importEntry') | 92 | ->method('updateEntry') |
93 | ->willReturn($entry); | 93 | ->willReturn($entry); |
94 | 94 | ||
95 | $res = $chromeImport->import(); | 95 | $res = $chromeImport->import(); |
@@ -118,7 +118,7 @@ class ChromeImportTest extends \PHPUnit_Framework_TestCase | |||
118 | 118 | ||
119 | $this->contentProxy | 119 | $this->contentProxy |
120 | ->expects($this->exactly(1)) | 120 | ->expects($this->exactly(1)) |
121 | ->method('importEntry') | 121 | ->method('updateEntry') |
122 | ->willReturn(new Entry($this->user)); | 122 | ->willReturn(new Entry($this->user)); |
123 | 123 | ||
124 | // check that every entry persisted are archived | 124 | // check that every entry persisted are archived |
@@ -158,7 +158,7 @@ class ChromeImportTest extends \PHPUnit_Framework_TestCase | |||
158 | 158 | ||
159 | $this->contentProxy | 159 | $this->contentProxy |
160 | ->expects($this->never()) | 160 | ->expects($this->never()) |
161 | ->method('importEntry'); | 161 | ->method('updateEntry'); |
162 | 162 | ||
163 | $producer = $this->getMockBuilder('OldSound\RabbitMqBundle\RabbitMq\Producer') | 163 | $producer = $this->getMockBuilder('OldSound\RabbitMqBundle\RabbitMq\Producer') |
164 | ->disableOriginalConstructor() | 164 | ->disableOriginalConstructor() |
@@ -198,7 +198,7 @@ class ChromeImportTest extends \PHPUnit_Framework_TestCase | |||
198 | 198 | ||
199 | $this->contentProxy | 199 | $this->contentProxy |
200 | ->expects($this->never()) | 200 | ->expects($this->never()) |
201 | ->method('importEntry'); | 201 | ->method('updateEntry'); |
202 | 202 | ||
203 | $factory = new RedisMockFactory(); | 203 | $factory = new RedisMockFactory(); |
204 | $redisMock = $factory->getAdapter('Predis\Client', true); | 204 | $redisMock = $factory->getAdapter('Predis\Client', true); |
diff --git a/tests/Wallabag/ImportBundle/Import/FirefoxImportTest.php b/tests/Wallabag/ImportBundle/Import/FirefoxImportTest.php index 09abac57..c186c820 100644 --- a/tests/Wallabag/ImportBundle/Import/FirefoxImportTest.php +++ b/tests/Wallabag/ImportBundle/Import/FirefoxImportTest.php | |||
@@ -89,7 +89,7 @@ class FirefoxImportTest extends \PHPUnit_Framework_TestCase | |||
89 | 89 | ||
90 | $this->contentProxy | 90 | $this->contentProxy |
91 | ->expects($this->exactly(2)) | 91 | ->expects($this->exactly(2)) |
92 | ->method('importEntry') | 92 | ->method('updateEntry') |
93 | ->willReturn($entry); | 93 | ->willReturn($entry); |
94 | 94 | ||
95 | $res = $firefoxImport->import(); | 95 | $res = $firefoxImport->import(); |
@@ -118,7 +118,7 @@ class FirefoxImportTest extends \PHPUnit_Framework_TestCase | |||
118 | 118 | ||
119 | $this->contentProxy | 119 | $this->contentProxy |
120 | ->expects($this->exactly(1)) | 120 | ->expects($this->exactly(1)) |
121 | ->method('importEntry') | 121 | ->method('updateEntry') |
122 | ->willReturn(new Entry($this->user)); | 122 | ->willReturn(new Entry($this->user)); |
123 | 123 | ||
124 | // check that every entry persisted are archived | 124 | // check that every entry persisted are archived |
@@ -158,7 +158,7 @@ class FirefoxImportTest extends \PHPUnit_Framework_TestCase | |||
158 | 158 | ||
159 | $this->contentProxy | 159 | $this->contentProxy |
160 | ->expects($this->never()) | 160 | ->expects($this->never()) |
161 | ->method('importEntry'); | 161 | ->method('updateEntry'); |
162 | 162 | ||
163 | $producer = $this->getMockBuilder('OldSound\RabbitMqBundle\RabbitMq\Producer') | 163 | $producer = $this->getMockBuilder('OldSound\RabbitMqBundle\RabbitMq\Producer') |
164 | ->disableOriginalConstructor() | 164 | ->disableOriginalConstructor() |
@@ -198,7 +198,7 @@ class FirefoxImportTest extends \PHPUnit_Framework_TestCase | |||
198 | 198 | ||
199 | $this->contentProxy | 199 | $this->contentProxy |
200 | ->expects($this->never()) | 200 | ->expects($this->never()) |
201 | ->method('importEntry'); | 201 | ->method('updateEntry'); |
202 | 202 | ||
203 | $factory = new RedisMockFactory(); | 203 | $factory = new RedisMockFactory(); |
204 | $redisMock = $factory->getAdapter('Predis\Client', true); | 204 | $redisMock = $factory->getAdapter('Predis\Client', true); |
diff --git a/tests/Wallabag/ImportBundle/Import/InstapaperImportTest.php b/tests/Wallabag/ImportBundle/Import/InstapaperImportTest.php index 05844490..9158c8a2 100644 --- a/tests/Wallabag/ImportBundle/Import/InstapaperImportTest.php +++ b/tests/Wallabag/ImportBundle/Import/InstapaperImportTest.php | |||
@@ -104,7 +104,7 @@ class InstapaperImportTest extends \PHPUnit_Framework_TestCase | |||
104 | 104 | ||
105 | $this->contentProxy | 105 | $this->contentProxy |
106 | ->expects($this->exactly(4)) | 106 | ->expects($this->exactly(4)) |
107 | ->method('importEntry') | 107 | ->method('updateEntry') |
108 | ->willReturn($entry); | 108 | ->willReturn($entry); |
109 | 109 | ||
110 | $res = $instapaperImport->import(); | 110 | $res = $instapaperImport->import(); |
@@ -133,7 +133,7 @@ class InstapaperImportTest extends \PHPUnit_Framework_TestCase | |||
133 | 133 | ||
134 | $this->contentProxy | 134 | $this->contentProxy |
135 | ->expects($this->once()) | 135 | ->expects($this->once()) |
136 | ->method('importEntry') | 136 | ->method('updateEntry') |
137 | ->willReturn(new Entry($this->user)); | 137 | ->willReturn(new Entry($this->user)); |
138 | 138 | ||
139 | // check that every entry persisted are archived | 139 | // check that every entry persisted are archived |
@@ -173,7 +173,7 @@ class InstapaperImportTest extends \PHPUnit_Framework_TestCase | |||
173 | 173 | ||
174 | $this->contentProxy | 174 | $this->contentProxy |
175 | ->expects($this->never()) | 175 | ->expects($this->never()) |
176 | ->method('importEntry'); | 176 | ->method('updateEntry'); |
177 | 177 | ||
178 | $producer = $this->getMockBuilder('OldSound\RabbitMqBundle\RabbitMq\Producer') | 178 | $producer = $this->getMockBuilder('OldSound\RabbitMqBundle\RabbitMq\Producer') |
179 | ->disableOriginalConstructor() | 179 | ->disableOriginalConstructor() |
@@ -213,7 +213,7 @@ class InstapaperImportTest extends \PHPUnit_Framework_TestCase | |||
213 | 213 | ||
214 | $this->contentProxy | 214 | $this->contentProxy |
215 | ->expects($this->never()) | 215 | ->expects($this->never()) |
216 | ->method('importEntry'); | 216 | ->method('updateEntry'); |
217 | 217 | ||
218 | $factory = new RedisMockFactory(); | 218 | $factory = new RedisMockFactory(); |
219 | $redisMock = $factory->getAdapter('Predis\Client', true); | 219 | $redisMock = $factory->getAdapter('Predis\Client', true); |
diff --git a/tests/Wallabag/ImportBundle/Import/PocketImportTest.php b/tests/Wallabag/ImportBundle/Import/PocketImportTest.php index f75e6bea..b81ebe15 100644 --- a/tests/Wallabag/ImportBundle/Import/PocketImportTest.php +++ b/tests/Wallabag/ImportBundle/Import/PocketImportTest.php | |||
@@ -282,7 +282,7 @@ class PocketImportTest extends \PHPUnit_Framework_TestCase | |||
282 | 282 | ||
283 | $this->contentProxy | 283 | $this->contentProxy |
284 | ->expects($this->once()) | 284 | ->expects($this->once()) |
285 | ->method('importEntry') | 285 | ->method('updateEntry') |
286 | ->willReturn($entry); | 286 | ->willReturn($entry); |
287 | 287 | ||
288 | $pocketImport->setClient($client); | 288 | $pocketImport->setClient($client); |
@@ -377,7 +377,7 @@ class PocketImportTest extends \PHPUnit_Framework_TestCase | |||
377 | 377 | ||
378 | $this->contentProxy | 378 | $this->contentProxy |
379 | ->expects($this->exactly(2)) | 379 | ->expects($this->exactly(2)) |
380 | ->method('importEntry') | 380 | ->method('updateEntry') |
381 | ->willReturn($entry); | 381 | ->willReturn($entry); |
382 | 382 | ||
383 | $pocketImport->setClient($client); | 383 | $pocketImport->setClient($client); |
@@ -450,7 +450,7 @@ JSON; | |||
450 | 450 | ||
451 | $this->contentProxy | 451 | $this->contentProxy |
452 | ->expects($this->never()) | 452 | ->expects($this->never()) |
453 | ->method('importEntry'); | 453 | ->method('updateEntry'); |
454 | 454 | ||
455 | $producer = $this->getMockBuilder('OldSound\RabbitMqBundle\RabbitMq\Producer') | 455 | $producer = $this->getMockBuilder('OldSound\RabbitMqBundle\RabbitMq\Producer') |
456 | ->disableOriginalConstructor() | 456 | ->disableOriginalConstructor() |
@@ -536,7 +536,7 @@ JSON; | |||
536 | 536 | ||
537 | $this->contentProxy | 537 | $this->contentProxy |
538 | ->expects($this->never()) | 538 | ->expects($this->never()) |
539 | ->method('ImportEntry'); | 539 | ->method('updateEntry'); |
540 | 540 | ||
541 | $factory = new RedisMockFactory(); | 541 | $factory = new RedisMockFactory(); |
542 | $redisMock = $factory->getAdapter('Predis\Client', true); | 542 | $redisMock = $factory->getAdapter('Predis\Client', true); |
@@ -621,7 +621,7 @@ JSON; | |||
621 | 621 | ||
622 | $this->contentProxy | 622 | $this->contentProxy |
623 | ->expects($this->once()) | 623 | ->expects($this->once()) |
624 | ->method('importEntry') | 624 | ->method('updateEntry') |
625 | ->will($this->throwException(new \Exception())); | 625 | ->will($this->throwException(new \Exception())); |
626 | 626 | ||
627 | $pocketImport->setClient($client); | 627 | $pocketImport->setClient($client); |
diff --git a/tests/Wallabag/ImportBundle/Import/ReadabilityImportTest.php b/tests/Wallabag/ImportBundle/Import/ReadabilityImportTest.php index 1b0daa92..8f466d38 100644 --- a/tests/Wallabag/ImportBundle/Import/ReadabilityImportTest.php +++ b/tests/Wallabag/ImportBundle/Import/ReadabilityImportTest.php | |||
@@ -89,7 +89,7 @@ class ReadabilityImportTest extends \PHPUnit_Framework_TestCase | |||
89 | 89 | ||
90 | $this->contentProxy | 90 | $this->contentProxy |
91 | ->expects($this->exactly(3)) | 91 | ->expects($this->exactly(3)) |
92 | ->method('importEntry') | 92 | ->method('updateEntry') |
93 | ->willReturn($entry); | 93 | ->willReturn($entry); |
94 | 94 | ||
95 | $res = $readabilityImport->import(); | 95 | $res = $readabilityImport->import(); |
@@ -118,7 +118,7 @@ class ReadabilityImportTest extends \PHPUnit_Framework_TestCase | |||
118 | 118 | ||
119 | $this->contentProxy | 119 | $this->contentProxy |
120 | ->expects($this->exactly(1)) | 120 | ->expects($this->exactly(1)) |
121 | ->method('importEntry') | 121 | ->method('updateEntry') |
122 | ->willReturn(new Entry($this->user)); | 122 | ->willReturn(new Entry($this->user)); |
123 | 123 | ||
124 | // check that every entry persisted are archived | 124 | // check that every entry persisted are archived |
@@ -158,7 +158,7 @@ class ReadabilityImportTest extends \PHPUnit_Framework_TestCase | |||
158 | 158 | ||
159 | $this->contentProxy | 159 | $this->contentProxy |
160 | ->expects($this->never()) | 160 | ->expects($this->never()) |
161 | ->method('importEntry'); | 161 | ->method('updateEntry'); |
162 | 162 | ||
163 | $producer = $this->getMockBuilder('OldSound\RabbitMqBundle\RabbitMq\Producer') | 163 | $producer = $this->getMockBuilder('OldSound\RabbitMqBundle\RabbitMq\Producer') |
164 | ->disableOriginalConstructor() | 164 | ->disableOriginalConstructor() |
@@ -198,7 +198,7 @@ class ReadabilityImportTest extends \PHPUnit_Framework_TestCase | |||
198 | 198 | ||
199 | $this->contentProxy | 199 | $this->contentProxy |
200 | ->expects($this->never()) | 200 | ->expects($this->never()) |
201 | ->method('importEntry'); | 201 | ->method('updateEntry'); |
202 | 202 | ||
203 | $factory = new RedisMockFactory(); | 203 | $factory = new RedisMockFactory(); |
204 | $redisMock = $factory->getAdapter('Predis\Client', true); | 204 | $redisMock = $factory->getAdapter('Predis\Client', true); |
diff --git a/tests/Wallabag/ImportBundle/Import/WallabagV1ImportTest.php b/tests/Wallabag/ImportBundle/Import/WallabagV1ImportTest.php index 3b2375a1..834b7ef5 100644 --- a/tests/Wallabag/ImportBundle/Import/WallabagV1ImportTest.php +++ b/tests/Wallabag/ImportBundle/Import/WallabagV1ImportTest.php | |||
@@ -113,7 +113,7 @@ class WallabagV1ImportTest extends \PHPUnit_Framework_TestCase | |||
113 | 113 | ||
114 | $this->contentProxy | 114 | $this->contentProxy |
115 | ->expects($this->exactly(1)) | 115 | ->expects($this->exactly(1)) |
116 | ->method('importEntry') | 116 | ->method('updateEntry') |
117 | ->willReturn($entry); | 117 | ->willReturn($entry); |
118 | 118 | ||
119 | $res = $wallabagV1Import->import(); | 119 | $res = $wallabagV1Import->import(); |
@@ -142,7 +142,7 @@ class WallabagV1ImportTest extends \PHPUnit_Framework_TestCase | |||
142 | 142 | ||
143 | $this->contentProxy | 143 | $this->contentProxy |
144 | ->expects($this->exactly(3)) | 144 | ->expects($this->exactly(3)) |
145 | ->method('importEntry') | 145 | ->method('updateEntry') |
146 | ->willReturn(new Entry($this->user)); | 146 | ->willReturn(new Entry($this->user)); |
147 | 147 | ||
148 | // check that every entry persisted are archived | 148 | // check that every entry persisted are archived |
@@ -182,7 +182,7 @@ class WallabagV1ImportTest extends \PHPUnit_Framework_TestCase | |||
182 | 182 | ||
183 | $this->contentProxy | 183 | $this->contentProxy |
184 | ->expects($this->never()) | 184 | ->expects($this->never()) |
185 | ->method('importEntry'); | 185 | ->method('updateEntry'); |
186 | 186 | ||
187 | $producer = $this->getMockBuilder('OldSound\RabbitMqBundle\RabbitMq\Producer') | 187 | $producer = $this->getMockBuilder('OldSound\RabbitMqBundle\RabbitMq\Producer') |
188 | ->disableOriginalConstructor() | 188 | ->disableOriginalConstructor() |
@@ -222,7 +222,7 @@ class WallabagV1ImportTest extends \PHPUnit_Framework_TestCase | |||
222 | 222 | ||
223 | $this->contentProxy | 223 | $this->contentProxy |
224 | ->expects($this->never()) | 224 | ->expects($this->never()) |
225 | ->method('importEntry'); | 225 | ->method('updateEntry'); |
226 | 226 | ||
227 | $factory = new RedisMockFactory(); | 227 | $factory = new RedisMockFactory(); |
228 | $redisMock = $factory->getAdapter('Predis\Client', true); | 228 | $redisMock = $factory->getAdapter('Predis\Client', true); |
diff --git a/tests/Wallabag/ImportBundle/Import/WallabagV2ImportTest.php b/tests/Wallabag/ImportBundle/Import/WallabagV2ImportTest.php index e1acf569..5cc04aa5 100644 --- a/tests/Wallabag/ImportBundle/Import/WallabagV2ImportTest.php +++ b/tests/Wallabag/ImportBundle/Import/WallabagV2ImportTest.php | |||
@@ -100,7 +100,7 @@ class WallabagV2ImportTest extends \PHPUnit_Framework_TestCase | |||
100 | 100 | ||
101 | $this->contentProxy | 101 | $this->contentProxy |
102 | ->expects($this->exactly(2)) | 102 | ->expects($this->exactly(2)) |
103 | ->method('importEntry') | 103 | ->method('updateEntry') |
104 | ->willReturn(new Entry($this->user)); | 104 | ->willReturn(new Entry($this->user)); |
105 | 105 | ||
106 | $res = $wallabagV2Import->import(); | 106 | $res = $wallabagV2Import->import(); |
@@ -129,7 +129,7 @@ class WallabagV2ImportTest extends \PHPUnit_Framework_TestCase | |||
129 | 129 | ||
130 | $this->contentProxy | 130 | $this->contentProxy |
131 | ->expects($this->exactly(2)) | 131 | ->expects($this->exactly(2)) |
132 | ->method('importEntry') | 132 | ->method('updateEntry') |
133 | ->willReturn(new Entry($this->user)); | 133 | ->willReturn(new Entry($this->user)); |
134 | 134 | ||
135 | // check that every entry persisted are archived | 135 | // check that every entry persisted are archived |
@@ -165,7 +165,7 @@ class WallabagV2ImportTest extends \PHPUnit_Framework_TestCase | |||
165 | 165 | ||
166 | $this->contentProxy | 166 | $this->contentProxy |
167 | ->expects($this->never()) | 167 | ->expects($this->never()) |
168 | ->method('importEntry'); | 168 | ->method('updateEntry'); |
169 | 169 | ||
170 | $producer = $this->getMockBuilder('OldSound\RabbitMqBundle\RabbitMq\Producer') | 170 | $producer = $this->getMockBuilder('OldSound\RabbitMqBundle\RabbitMq\Producer') |
171 | ->disableOriginalConstructor() | 171 | ->disableOriginalConstructor() |
@@ -201,7 +201,7 @@ class WallabagV2ImportTest extends \PHPUnit_Framework_TestCase | |||
201 | 201 | ||
202 | $this->contentProxy | 202 | $this->contentProxy |
203 | ->expects($this->never()) | 203 | ->expects($this->never()) |
204 | ->method('importEntry'); | 204 | ->method('updateEntry'); |
205 | 205 | ||
206 | $factory = new RedisMockFactory(); | 206 | $factory = new RedisMockFactory(); |
207 | $redisMock = $factory->getAdapter('Predis\Client', true); | 207 | $redisMock = $factory->getAdapter('Predis\Client', true); |
@@ -278,7 +278,7 @@ class WallabagV2ImportTest extends \PHPUnit_Framework_TestCase | |||
278 | 278 | ||
279 | $this->contentProxy | 279 | $this->contentProxy |
280 | ->expects($this->exactly(2)) | 280 | ->expects($this->exactly(2)) |
281 | ->method('importEntry') | 281 | ->method('updateEntry') |
282 | ->will($this->throwException(new \Exception())); | 282 | ->will($this->throwException(new \Exception())); |
283 | 283 | ||
284 | $res = $wallabagV2Import->import(); | 284 | $res = $wallabagV2Import->import(); |