Browse Source

Remove empty array when plugin requires nothing

Jad Bitar 10 years ago
parent
commit
a743dacc59
2 changed files with 23 additions and 1 deletions
  1. 1 1
      src/Shell/Task/LoadTask.php
  2. 22 0
      tests/TestCase/Shell/Task/LoadTaskTest.php

+ 1 - 1
src/Shell/Task/LoadTask.php

@@ -76,7 +76,7 @@ class LoadTask extends Shell
             $append = "\nPlugin::load('%s', [%s]);\n";
             $options = implode(', ', array_filter([$autoloadString, $bootstrapString, $routesString]));
 
-            $bootstrap->append(sprintf($append, $plugin, $options));
+            $bootstrap->append(str_replace(', []', '', sprintf($append, $plugin, $options)));
             $this->out('');
             $this->out(sprintf('%s modified', $this->bootstrap));
             return true;

+ 22 - 0
tests/TestCase/Shell/Task/LoadTaskTest.php

@@ -145,4 +145,26 @@ class LoadTaskTest extends TestCase
         $bootstrap = new File($this->bootstrap, false);
         $this->assertContains($expected, $bootstrap->read());
     }
+
+    /**
+     * testLoad
+     *
+     * @return void
+     */
+    public function testLoadNothing()
+    {
+        $this->Task->params = [
+            'bootstrap' => false,
+            'routes' => false,
+            'autoload' => false,
+        ];
+
+        $action = $this->Task->main('TestPlugin');
+
+        $this->assertTrue($action);
+
+        $expected = "Plugin::load('TestPlugin');";
+        $bootstrap = new File($this->bootstrap, false);
+        $this->assertContains($expected, $bootstrap->read());
+    }
 }