Browse Source

Merge pull request #13089 from cakephp/testcase-loadplugins-readability

Improve code readability for humans and IDEs
Mark Sch 7 years ago
parent
commit
c1c72185ee
2 changed files with 6 additions and 6 deletions
  1. 0 1
      phpstan.neon
  2. 6 5
      src/TestSuite/TestCase.php

+ 0 - 1
phpstan.neon

@@ -24,7 +24,6 @@ parameters:
         - '#Call to an undefined method Cake\\Auth\\Storage\\StorageInterface::setConfig\(\)#'
         - '#Variable \$_SESSION in isset\(\) always exists and is not nullable#'
         - '#PHPDoc tag @throws with type PHPUnit\\Exception is not subtype of Throwable#'
-        - '#Call to an undefined method PHPUnit\\Framework\\MockObject\\MockObject#'
         - '#Call to an undefined method DOMNode::setAttribute\(\)#'
         - '#Binary operation "\+" between array|false and array results in an error#'
         - '#Result of method Cake\\Auth\\BaseAuthenticate::unauthenticated\(\) \(void\) is used#'

+ 6 - 5
src/TestSuite/TestCase.php

@@ -197,21 +197,22 @@ abstract class TestCase extends BaseTestCase
      * Useful to test how plugins being loaded/not loaded interact with other
      * elements in CakePHP or applications.
      *
-     * @param array $plugins list of Plugins to load
+     * @param array $plugins List of Plugins to load.
      * @return \Cake\Http\BaseApplication
      */
     public function loadPlugins(array $plugins = [])
     {
+        /** @var \Cake\Http\BaseApplication $app */
         $app = $this->getMockForAbstractClass(
             BaseApplication::class,
             ['']
         );
 
-        foreach ($plugins as $k => $opts) {
-            if (is_array($opts)) {
-                $app->addPlugin($k, $opts);
+        foreach ($plugins as $pluginName => $config) {
+            if (is_array($config)) {
+                $app->addPlugin($pluginName, $config);
             } else {
-                $app->addPlugin($opts);
+                $app->addPlugin($config);
             }
         }
         $app->pluginBootstrap();