Skip to content

Commit

Permalink
Merge pull request #6952 from cakephp/cleanup-plugin-loading
Browse files Browse the repository at this point in the history
Remove empty array when plugin requires nothing
  • Loading branch information
lorenzo committed Jul 6, 2015
2 parents fe2c025 + a743dac commit fa01bb1
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Shell/Task/LoadTask.php
Expand Up @@ -76,7 +76,7 @@ protected function _modifyBootstrap($plugin, $hasBootstrap, $hasRoutes, $hasAuto
$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;
Expand Down
22 changes: 22 additions & 0 deletions tests/TestCase/Shell/Task/LoadTaskTest.php
Expand Up @@ -145,4 +145,26 @@ public function testLoadNoAutoload()
$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());
}
}

0 comments on commit fa01bb1

Please sign in to comment.