mirror of
https://github.com/wallabag/wallabag.git
synced 2025-01-11 01:15:26 +00:00
Merge pull request #3857 from wallabag/php73
Replace continue; with break; to avoid PHP 7.3 warnings
This commit is contained in:
commit
fc4c1f50b4
7 changed files with 78 additions and 10 deletions
|
@ -108,7 +108,7 @@ class EntryFilterType extends AbstractType
|
|||
->add('httpStatus', TextFilterType::class, [
|
||||
'apply_filter' => function (QueryInterface $filterQuery, $field, $values) {
|
||||
$value = $values['value'];
|
||||
if (false === array_key_exists($value, Response::$statusTexts)) {
|
||||
if (false === \array_key_exists($value, Response::$statusTexts)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -77,7 +77,7 @@ abstract class BrowserImport extends AbstractImport
|
|||
*/
|
||||
public function parseEntry(array $importedEntry)
|
||||
{
|
||||
if ((!array_key_exists('guid', $importedEntry) || (!array_key_exists('id', $importedEntry))) && \is_array(reset($importedEntry))) {
|
||||
if ((!\array_key_exists('guid', $importedEntry) || (!\array_key_exists('id', $importedEntry))) && \is_array(reset($importedEntry))) {
|
||||
if ($this->producer) {
|
||||
$this->parseEntriesForProducer($importedEntry);
|
||||
|
||||
|
@ -89,7 +89,7 @@ abstract class BrowserImport extends AbstractImport
|
|||
return;
|
||||
}
|
||||
|
||||
if (array_key_exists('children', $importedEntry)) {
|
||||
if (\array_key_exists('children', $importedEntry)) {
|
||||
if ($this->producer) {
|
||||
$this->parseEntriesForProducer($importedEntry['children']);
|
||||
|
||||
|
@ -101,11 +101,11 @@ abstract class BrowserImport extends AbstractImport
|
|||
return;
|
||||
}
|
||||
|
||||
if (!array_key_exists('uri', $importedEntry) && !array_key_exists('url', $importedEntry)) {
|
||||
if (!\array_key_exists('uri', $importedEntry) && !\array_key_exists('url', $importedEntry)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$url = array_key_exists('uri', $importedEntry) ? $importedEntry['uri'] : $importedEntry['url'];
|
||||
$url = \array_key_exists('uri', $importedEntry) ? $importedEntry['uri'] : $importedEntry['url'];
|
||||
|
||||
$existingEntry = $this->em
|
||||
->getRepository('WallabagCoreBundle:Entry')
|
||||
|
@ -126,7 +126,7 @@ abstract class BrowserImport extends AbstractImport
|
|||
// update entry with content (in case fetching failed, the given entry will be return)
|
||||
$this->fetchContent($entry, $data['url'], $data);
|
||||
|
||||
if (array_key_exists('tags', $data)) {
|
||||
if (\array_key_exists('tags', $data)) {
|
||||
$this->tagsAssigner->assignTagsToEntry(
|
||||
$entry,
|
||||
$data['tags']
|
||||
|
|
|
@ -57,7 +57,7 @@ class ChromeImport extends BrowserImport
|
|||
'created_at' => substr($entry['date_added'], 0, 10),
|
||||
];
|
||||
|
||||
if (array_key_exists('tags', $entry) && '' !== $entry['tags']) {
|
||||
if (\array_key_exists('tags', $entry) && '' !== $entry['tags']) {
|
||||
$data['tags'] = $entry['tags'];
|
||||
}
|
||||
|
||||
|
|
|
@ -57,7 +57,7 @@ class FirefoxImport extends BrowserImport
|
|||
'created_at' => substr($entry['dateAdded'], 0, 10),
|
||||
];
|
||||
|
||||
if (array_key_exists('tags', $entry) && '' !== $entry['tags']) {
|
||||
if (\array_key_exists('tags', $entry) && '' !== $entry['tags']) {
|
||||
$data['tags'] = $entry['tags'];
|
||||
}
|
||||
|
||||
|
|
|
@ -122,7 +122,7 @@ abstract class WallabagImport extends AbstractImport
|
|||
// update entry with content (in case fetching failed, the given entry will be return)
|
||||
$this->fetchContent($entry, $data['url'], $data);
|
||||
|
||||
if (array_key_exists('tags', $data)) {
|
||||
if (\array_key_exists('tags', $data)) {
|
||||
$this->tagsAssigner->assignTagsToEntry(
|
||||
$entry,
|
||||
$data['tags'],
|
||||
|
|
|
@ -61,7 +61,7 @@ class WallabagV1Import extends WallabagImport
|
|||
$data['html'] = $this->fetchingErrorMessage;
|
||||
}
|
||||
|
||||
if (array_key_exists('tags', $entry) && '' !== $entry['tags']) {
|
||||
if (\array_key_exists('tags', $entry) && '' !== $entry['tags']) {
|
||||
$data['tags'] = $entry['tags'];
|
||||
}
|
||||
|
||||
|
|
|
@ -134,4 +134,72 @@ class GrabySiteConfigBuilderTest extends TestCase
|
|||
|
||||
$this->assertCount(1, $records, 'One log was recorded');
|
||||
}
|
||||
|
||||
public function testBuildConfigWithBadExtraFields()
|
||||
{
|
||||
/* @var \Graby\SiteConfig\ConfigBuilder|\PHPUnit_Framework_MockObject_MockObject */
|
||||
$grabyConfigBuilderMock = $this->getMockBuilder('Graby\SiteConfig\ConfigBuilder')
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
|
||||
$grabySiteConfig = new GrabySiteConfig();
|
||||
$grabySiteConfig->requires_login = true;
|
||||
$grabySiteConfig->login_uri = 'http://www.example.com/login';
|
||||
$grabySiteConfig->login_username_field = 'login';
|
||||
$grabySiteConfig->login_password_field = 'password';
|
||||
$grabySiteConfig->login_extra_fields = ['field'];
|
||||
$grabySiteConfig->not_logged_in_xpath = '//div[@class="need-login"]';
|
||||
|
||||
$grabyConfigBuilderMock
|
||||
->method('buildForHost')
|
||||
->with('example.com')
|
||||
->will($this->returnValue($grabySiteConfig));
|
||||
|
||||
$logger = new Logger('foo');
|
||||
$handler = new TestHandler();
|
||||
$logger->pushHandler($handler);
|
||||
|
||||
$siteCrentialRepo = $this->getMockBuilder('Wallabag\CoreBundle\Repository\SiteCredentialRepository')
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
$siteCrentialRepo->expects($this->once())
|
||||
->method('findOneByHostAndUser')
|
||||
->with('example.com', 1)
|
||||
->willReturn(['username' => 'foo', 'password' => 'bar']);
|
||||
|
||||
$user = $this->getMockBuilder('Wallabag\UserBundle\Entity\User')
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
$user->expects($this->once())
|
||||
->method('getId')
|
||||
->willReturn(1);
|
||||
|
||||
$token = new UsernamePasswordToken($user, 'pass', 'provider');
|
||||
|
||||
$tokenStorage = new TokenStorage();
|
||||
$tokenStorage->setToken($token);
|
||||
|
||||
$this->builder = new GrabySiteConfigBuilder(
|
||||
$grabyConfigBuilderMock,
|
||||
$tokenStorage,
|
||||
$siteCrentialRepo,
|
||||
$logger
|
||||
);
|
||||
|
||||
$config = $this->builder->buildForHost('www.example.com');
|
||||
|
||||
$this->assertSame('example.com', $config->getHost());
|
||||
$this->assertTrue($config->requiresLogin());
|
||||
$this->assertSame('http://www.example.com/login', $config->getLoginUri());
|
||||
$this->assertSame('login', $config->getUsernameField());
|
||||
$this->assertSame('password', $config->getPasswordField());
|
||||
$this->assertSame([], $config->getExtraFields());
|
||||
$this->assertSame('//div[@class="need-login"]', $config->getNotLoggedInXpath());
|
||||
$this->assertSame('foo', $config->getUsername());
|
||||
$this->assertSame('bar', $config->getPassword());
|
||||
|
||||
$records = $handler->getRecords();
|
||||
|
||||
$this->assertCount(1, $records, 'One log was recorded');
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue