aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--src/Wallabag/CoreBundle/GuzzleSiteAuthenticator/GrabySiteConfigBuilder.php2
-rw-r--r--src/Wallabag/CoreBundle/Helper/DownloadImages.php2
-rw-r--r--src/Wallabag/CoreBundle/Helper/RuleBasedTagger.php2
-rw-r--r--src/Wallabag/CoreBundle/Helper/TagsAssigner.php2
-rw-r--r--src/Wallabag/ImportBundle/Import/AbstractImport.php2
-rw-r--r--src/Wallabag/ImportBundle/Import/BrowserImport.php6
-rw-r--r--src/Wallabag/ImportBundle/Import/InstapaperImport.php2
-rw-r--r--tests/Wallabag/CoreBundle/GuzzleSiteAuthenticator/GrabySiteConfigBuilderTest.php68
8 files changed, 77 insertions, 9 deletions
diff --git a/src/Wallabag/CoreBundle/GuzzleSiteAuthenticator/GrabySiteConfigBuilder.php b/src/Wallabag/CoreBundle/GuzzleSiteAuthenticator/GrabySiteConfigBuilder.php
index 2e57aac8..90e00c62 100644
--- a/src/Wallabag/CoreBundle/GuzzleSiteAuthenticator/GrabySiteConfigBuilder.php
+++ b/src/Wallabag/CoreBundle/GuzzleSiteAuthenticator/GrabySiteConfigBuilder.php
@@ -114,7 +114,7 @@ class GrabySiteConfigBuilder implements SiteConfigBuilder
114 $extraFields = []; 114 $extraFields = [];
115 foreach ($extraFieldsStrings as $extraField) { 115 foreach ($extraFieldsStrings as $extraField) {
116 if (false === strpos($extraField, '=')) { 116 if (false === strpos($extraField, '=')) {
117 break; 117 continue;
118 } 118 }
119 119
120 list($fieldName, $fieldValue) = explode('=', $extraField, 2); 120 list($fieldName, $fieldValue) = explode('=', $extraField, 2);
diff --git a/src/Wallabag/CoreBundle/Helper/DownloadImages.php b/src/Wallabag/CoreBundle/Helper/DownloadImages.php
index 8c1c208f..cc3dcfce 100644
--- a/src/Wallabag/CoreBundle/Helper/DownloadImages.php
+++ b/src/Wallabag/CoreBundle/Helper/DownloadImages.php
@@ -56,7 +56,7 @@ class DownloadImages
56 $imagePath = $this->processSingleImage($entryId, $image, $url, $relativePath); 56 $imagePath = $this->processSingleImage($entryId, $image, $url, $relativePath);
57 57
58 if (false === $imagePath) { 58 if (false === $imagePath) {
59 break; 59 continue;
60 } 60 }
61 61
62 // if image contains "&" and we can't find it in the html it might be because it's encoded as & 62 // if image contains "&" and we can't find it in the html it might be because it's encoded as &
diff --git a/src/Wallabag/CoreBundle/Helper/RuleBasedTagger.php b/src/Wallabag/CoreBundle/Helper/RuleBasedTagger.php
index d156df84..fbdf2ac7 100644
--- a/src/Wallabag/CoreBundle/Helper/RuleBasedTagger.php
+++ b/src/Wallabag/CoreBundle/Helper/RuleBasedTagger.php
@@ -37,7 +37,7 @@ class RuleBasedTagger
37 37
38 foreach ($rules as $rule) { 38 foreach ($rules as $rule) {
39 if (!$this->rulerz->satisfies($entry, $rule->getRule())) { 39 if (!$this->rulerz->satisfies($entry, $rule->getRule())) {
40 break; 40 continue;
41 } 41 }
42 42
43 $this->logger->info('Matching rule.', [ 43 $this->logger->info('Matching rule.', [
diff --git a/src/Wallabag/CoreBundle/Helper/TagsAssigner.php b/src/Wallabag/CoreBundle/Helper/TagsAssigner.php
index 519150f5..e6b4989f 100644
--- a/src/Wallabag/CoreBundle/Helper/TagsAssigner.php
+++ b/src/Wallabag/CoreBundle/Helper/TagsAssigner.php
@@ -49,7 +49,7 @@ class TagsAssigner
49 49
50 // avoid empty tag 50 // avoid empty tag
51 if (0 === \strlen($label)) { 51 if (0 === \strlen($label)) {
52 break; 52 continue;
53 } 53 }
54 54
55 if (isset($tagsNotYetFlushed[$label])) { 55 if (isset($tagsNotYetFlushed[$label])) {
diff --git a/src/Wallabag/ImportBundle/Import/AbstractImport.php b/src/Wallabag/ImportBundle/Import/AbstractImport.php
index 5ae4aa8d..d39d71b6 100644
--- a/src/Wallabag/ImportBundle/Import/AbstractImport.php
+++ b/src/Wallabag/ImportBundle/Import/AbstractImport.php
@@ -169,7 +169,7 @@ abstract class AbstractImport implements ImportInterface
169 $entry = $this->parseEntry($importedEntry); 169 $entry = $this->parseEntry($importedEntry);
170 170
171 if (null === $entry) { 171 if (null === $entry) {
172 break; 172 continue;
173 } 173 }
174 174
175 // store each entry to be flushed so we can trigger the entry.saved event for each of them 175 // store each entry to be flushed so we can trigger the entry.saved event for each of them
diff --git a/src/Wallabag/ImportBundle/Import/BrowserImport.php b/src/Wallabag/ImportBundle/Import/BrowserImport.php
index 99717beb..3987e80f 100644
--- a/src/Wallabag/ImportBundle/Import/BrowserImport.php
+++ b/src/Wallabag/ImportBundle/Import/BrowserImport.php
@@ -158,13 +158,13 @@ abstract class BrowserImport extends AbstractImport
158 158
159 foreach ($entries as $importedEntry) { 159 foreach ($entries as $importedEntry) {
160 if ((array) $importedEntry !== $importedEntry) { 160 if ((array) $importedEntry !== $importedEntry) {
161 break; 161 continue;
162 } 162 }
163 163
164 $entry = $this->parseEntry($importedEntry); 164 $entry = $this->parseEntry($importedEntry);
165 165
166 if (null === $entry) { 166 if (null === $entry) {
167 break; 167 continue;
168 } 168 }
169 169
170 // @see AbstractImport 170 // @see AbstractImport
@@ -206,7 +206,7 @@ abstract class BrowserImport extends AbstractImport
206 { 206 {
207 foreach ($entries as $importedEntry) { 207 foreach ($entries as $importedEntry) {
208 if ((array) $importedEntry !== $importedEntry) { 208 if ((array) $importedEntry !== $importedEntry) {
209 break; 209 continue;
210 } 210 }
211 211
212 // set userId for the producer (it won't know which user is connected) 212 // set userId for the producer (it won't know which user is connected)
diff --git a/src/Wallabag/ImportBundle/Import/InstapaperImport.php b/src/Wallabag/ImportBundle/Import/InstapaperImport.php
index 6b6b35af..439c978c 100644
--- a/src/Wallabag/ImportBundle/Import/InstapaperImport.php
+++ b/src/Wallabag/ImportBundle/Import/InstapaperImport.php
@@ -65,7 +65,7 @@ class InstapaperImport extends AbstractImport
65 $handle = fopen($this->filepath, 'r'); 65 $handle = fopen($this->filepath, 'r');
66 while (false !== ($data = fgetcsv($handle, 10240))) { 66 while (false !== ($data = fgetcsv($handle, 10240))) {
67 if ('URL' === $data[0]) { 67 if ('URL' === $data[0]) {
68 break; 68 continue;
69 } 69 }
70 70
71 // last element in the csv is the folder where the content belong 71 // last element in the csv is the folder where the content belong
diff --git a/tests/Wallabag/CoreBundle/GuzzleSiteAuthenticator/GrabySiteConfigBuilderTest.php b/tests/Wallabag/CoreBundle/GuzzleSiteAuthenticator/GrabySiteConfigBuilderTest.php
index 1173fc3d..7beccd30 100644
--- a/tests/Wallabag/CoreBundle/GuzzleSiteAuthenticator/GrabySiteConfigBuilderTest.php
+++ b/tests/Wallabag/CoreBundle/GuzzleSiteAuthenticator/GrabySiteConfigBuilderTest.php
@@ -134,4 +134,72 @@ class GrabySiteConfigBuilderTest extends TestCase
134 134
135 $this->assertCount(1, $records, 'One log was recorded'); 135 $this->assertCount(1, $records, 'One log was recorded');
136 } 136 }
137
138 public function testBuildConfigWithBadExtraFields()
139 {
140 /* @var \Graby\SiteConfig\ConfigBuilder|\PHPUnit_Framework_MockObject_MockObject */
141 $grabyConfigBuilderMock = $this->getMockBuilder('Graby\SiteConfig\ConfigBuilder')
142 ->disableOriginalConstructor()
143 ->getMock();
144
145 $grabySiteConfig = new GrabySiteConfig();
146 $grabySiteConfig->requires_login = true;
147 $grabySiteConfig->login_uri = 'http://www.example.com/login';
148 $grabySiteConfig->login_username_field = 'login';
149 $grabySiteConfig->login_password_field = 'password';
150 $grabySiteConfig->login_extra_fields = ['field'];
151 $grabySiteConfig->not_logged_in_xpath = '//div[@class="need-login"]';
152
153 $grabyConfigBuilderMock
154 ->method('buildForHost')
155 ->with('example.com')
156 ->will($this->returnValue($grabySiteConfig));
157
158 $logger = new Logger('foo');
159 $handler = new TestHandler();
160 $logger->pushHandler($handler);
161
162 $siteCrentialRepo = $this->getMockBuilder('Wallabag\CoreBundle\Repository\SiteCredentialRepository')
163 ->disableOriginalConstructor()
164 ->getMock();
165 $siteCrentialRepo->expects($this->once())
166 ->method('findOneByHostAndUser')
167 ->with('example.com', 1)
168 ->willReturn(['username' => 'foo', 'password' => 'bar']);
169
170 $user = $this->getMockBuilder('Wallabag\UserBundle\Entity\User')
171 ->disableOriginalConstructor()
172 ->getMock();
173 $user->expects($this->once())
174 ->method('getId')
175 ->willReturn(1);
176
177 $token = new UsernamePasswordToken($user, 'pass', 'provider');
178
179 $tokenStorage = new TokenStorage();
180 $tokenStorage->setToken($token);
181
182 $this->builder = new GrabySiteConfigBuilder(
183 $grabyConfigBuilderMock,
184 $tokenStorage,
185 $siteCrentialRepo,
186 $logger
187 );
188
189 $config = $this->builder->buildForHost('www.example.com');
190
191 $this->assertSame('example.com', $config->getHost());
192 $this->assertTrue($config->requiresLogin());
193 $this->assertSame('http://www.example.com/login', $config->getLoginUri());
194 $this->assertSame('login', $config->getUsernameField());
195 $this->assertSame('password', $config->getPasswordField());
196 $this->assertSame([], $config->getExtraFields());
197 $this->assertSame('//div[@class="need-login"]', $config->getNotLoggedInXpath());
198 $this->assertSame('foo', $config->getUsername());
199 $this->assertSame('bar', $config->getPassword());
200
201 $records = $handler->getRecords();
202
203 $this->assertCount(1, $records, 'One log was recorded');
204 }
137} 205}