]> git.immae.eu Git - github/wallabag/wallabag.git/commitdiff
Merge pull request #3161 from wallabag/scrutinizer-2.3
authorNicolas LÅ“uillet <nicolas@loeuillet.org>
Wed, 31 May 2017 09:46:41 +0000 (11:46 +0200)
committerGitHub <noreply@github.com>
Wed, 31 May 2017 09:46:41 +0000 (11:46 +0200)
Fix some Scrutinizer issues

src/Wallabag/CoreBundle/Entity/Entry.php
src/Wallabag/CoreBundle/GuzzleSiteAuthenticator/GrabySiteConfigBuilder.php
src/Wallabag/CoreBundle/Helper/RuleBasedTagger.php
tests/Wallabag/CoreBundle/Command/InstallCommandTest.php

index 08a67c34b1f00275b1f61b3cf5bed3b734800560..9a7dd4e7b77e43613e7a1048a847fda7afb724d4 100644 (file)
@@ -550,7 +550,7 @@ class Entry
     }
 
     /**
-     * @return ArrayCollection<Tag>
+     * @return ArrayCollection
      */
     public function getTags()
     {
@@ -685,7 +685,7 @@ class Entry
     }
 
     /**
-     * @return int
+     * @return string
      */
     public function getHttpStatus()
     {
@@ -693,7 +693,7 @@ class Entry
     }
 
     /**
-     * @param int $httpStatus
+     * @param string $httpStatus
      *
      * @return Entry
      */
index c712bb26e2de7c66f487132da00e63e8c718d463..1c56fa9f44279c0fa800abc5726bbd9ad876e043 100644 (file)
@@ -5,7 +5,6 @@ namespace Wallabag\CoreBundle\GuzzleSiteAuthenticator;
 use BD\GuzzleSiteAuthenticator\SiteConfig\SiteConfig;
 use BD\GuzzleSiteAuthenticator\SiteConfig\SiteConfigBuilder;
 use Graby\SiteConfig\ConfigBuilder;
-use OutOfRangeException;
 use Psr\Log\LoggerInterface;
 
 class GrabySiteConfigBuilder implements SiteConfigBuilder
@@ -38,13 +37,7 @@ class GrabySiteConfigBuilder implements SiteConfigBuilder
     }
 
     /**
-     * Builds the SiteConfig for a host.
-     *
-     * @param string $host The "www." prefix is ignored
-     *
-     * @return SiteConfig
-     *
-     * @throws OutOfRangeException If there is no config for $host
+     * {@inheritdoc}
      */
     public function buildForHost($host)
     {
index add27db2b4ea0741a06fe1a70dc2ee928a307ca9..509d0dec9c2b70b53b7da3e5822462cd17354af7 100644 (file)
@@ -15,6 +15,7 @@ class RuleBasedTagger
     private $rulerz;
     private $tagRepository;
     private $entryRepository;
+    private $logger;
 
     public function __construct(RulerZ $rulerz, TagRepository $tagRepository, EntryRepository $entryRepository, LoggerInterface $logger)
     {
index 122a87d400239c53f6c83ab9ec790ee02154824c..71c2ffc633917c74a5d00016cd30d704932c1f5c 100644 (file)
@@ -67,18 +67,14 @@ class InstallCommandTest extends WallabagCoreTestCase
 
         $command = $application->find('wallabag:install');
 
-        // We mock the QuestionHelper
-        $question = $this->getMockBuilder('Symfony\Component\Console\Helper\QuestionHelper')
-            ->disableOriginalConstructor()
-            ->getMock();
-        $question->expects($this->any())
-            ->method('ask')
-            ->will($this->returnValue('yes_'.uniqid('', true)));
-
-        // We override the standard helper with our mock
-        $command->getHelperSet()->set($question, 'question');
-
         $tester = new CommandTester($command);
+        $tester->setInputs([
+            'y', // dropping database
+            'y', // create super admin
+            'username_'.uniqid('', true), // username
+            'password_'.uniqid('', true), // password
+            'email_'.uniqid('', true).'@wallabag.it', // email
+        ]);
         $tester->execute([
             'command' => $command->getName(),
         ]);
@@ -97,18 +93,13 @@ class InstallCommandTest extends WallabagCoreTestCase
 
         $command = $application->find('wallabag:install');
 
-        // We mock the QuestionHelper
-        $question = $this->getMockBuilder('Symfony\Component\Console\Helper\QuestionHelper')
-            ->disableOriginalConstructor()
-            ->getMock();
-        $question->expects($this->any())
-            ->method('ask')
-            ->will($this->returnValue('yes_'.uniqid('', true)));
-
-        // We override the standard helper with our mock
-        $command->getHelperSet()->set($question, 'question');
-
         $tester = new CommandTester($command);
+        $tester->setInputs([
+            'y', // create super admin
+            'username_'.uniqid('', true), // username
+            'password_'.uniqid('', true), // password
+            'email_'.uniqid('', true).'@wallabag.it', // email
+        ]);
         $tester->execute([
             'command' => $command->getName(),
             '--reset' => true,
@@ -150,18 +141,13 @@ class InstallCommandTest extends WallabagCoreTestCase
 
         $command = $application->find('wallabag:install');
 
-        // We mock the QuestionHelper
-        $question = $this->getMockBuilder('Symfony\Component\Console\Helper\QuestionHelper')
-            ->disableOriginalConstructor()
-            ->getMock();
-        $question->expects($this->any())
-            ->method('ask')
-            ->will($this->returnValue('yes_'.uniqid('', true)));
-
-        // We override the standard helper with our mock
-        $command->getHelperSet()->set($question, 'question');
-
         $tester = new CommandTester($command);
+        $tester->setInputs([
+            'y', // create super admin
+            'username_'.uniqid('', true), // username
+            'password_'.uniqid('', true), // password
+            'email_'.uniqid('', true).'@wallabag.it', // email
+        ]);
         $tester->execute([
             'command' => $command->getName(),
         ]);
@@ -183,23 +169,12 @@ class InstallCommandTest extends WallabagCoreTestCase
 
         $command = $application->find('wallabag:install');
 
-        // We mock the QuestionHelper
-        $question = $this->getMockBuilder('Symfony\Component\Console\Helper\QuestionHelper')
-            ->disableOriginalConstructor()
-            ->getMock();
-
-        $question->expects($this->exactly(3))
-            ->method('ask')
-            ->will($this->onConsecutiveCalls(
-                false, // don't want to reset the entire database
-                true, // do want to reset the schema
-                false // don't want to create a new user
-            ));
-
-        // We override the standard helper with our mock
-        $command->getHelperSet()->set($question, 'question');
-
         $tester = new CommandTester($command);
+        $tester->setInputs([
+            'n', // don't want to reset the entire database
+            'y', // do want to reset the schema
+            'n', // don't want to create a new user
+        ]);
         $tester->execute([
             'command' => $command->getName(),
         ]);
@@ -239,22 +214,11 @@ class InstallCommandTest extends WallabagCoreTestCase
 
         $command = $application->find('wallabag:install');
 
-        // We mock the QuestionHelper
-        $question = $this->getMockBuilder('Symfony\Component\Console\Helper\QuestionHelper')
-            ->disableOriginalConstructor()
-            ->getMock();
-
-        $question->expects($this->exactly(2))
-            ->method('ask')
-            ->will($this->onConsecutiveCalls(
-                false, // don't want to reset the entire database
-                false // don't want to create a new user
-            ));
-
-        // We override the standard helper with our mock
-        $command->getHelperSet()->set($question, 'question');
-
         $tester = new CommandTester($command);
+        $tester->setInputs([
+            'n', // don't want to reset the entire database
+            'n', // don't want to create a new user
+        ]);
         $tester->execute([
             'command' => $command->getName(),
         ]);
@@ -275,21 +239,11 @@ class InstallCommandTest extends WallabagCoreTestCase
 
         $command = $application->find('wallabag:install');
 
-        // We mock the QuestionHelper
-        $question = $this->getMockBuilder('Symfony\Component\Console\Helper\QuestionHelper')
-            ->disableOriginalConstructor()
-            ->getMock();
-        $question->expects($this->any())
-            ->method('ask')
-            ->will($this->returnValue('yes_'.uniqid('', true)));
-
-        // We override the standard helper with our mock
-        $command->getHelperSet()->set($question, 'question');
-
         $tester = new CommandTester($command);
         $tester->execute([
             'command' => $command->getName(),
-            '--no-interaction' => true,
+        ], [
+            'interactive' => false,
         ]);
 
         $this->assertContains('Checking system requirements.', $tester->getDisplay());