Browse Source

Merge pull request #6043 from cakephp/3.0-plugin-shell

3.0 plugin shell
ADmad 11 years ago
parent
commit
7ecd991e82

+ 51 - 0
src/Shell/PluginShell.php

@@ -0,0 +1,51 @@
+<?php
+/**
+ * CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
+ * Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
+ *
+ * Licensed under The MIT License
+ * For full copyright and license information, please see the LICENSE.txt
+ * Redistributions of files must retain the above copyright notice.
+ *
+ * @copyright     Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
+ * @link          http://cakephp.org CakePHP(tm) Project
+ * @since         3.0.0
+ * @license       http://www.opensource.org/licenses/mit-license.php MIT License
+ */
+namespace Cake\Shell;
+
+use Cake\Console\Shell;
+
+/**
+ * Shell for tasks related to plugins.
+ *
+ */
+class PluginShell extends Shell
+{
+
+    /**
+     * Contains tasks to load and instantiate
+     *
+     * @var array
+     */
+    public $tasks = ['Assets'];
+
+    /**
+     * Gets the option parser instance and configures it.
+     *
+     * @return \Cake\Console\ConsoleOptionParser
+     */
+    public function getOptionParser()
+    {
+        $parser = parent::getOptionParser();
+
+        $parser->description(
+            'Plugin Shell perform various tasks related to plugin.'
+        )->addSubcommand('assets', [
+            'help' => 'Symlink / copy plugin assets to app\'s webroot',
+            'parser' => $this->Assets->getOptionParser()
+        ]);
+
+        return $parser;
+    }
+}

+ 3 - 3
src/Shell/PluginAssetsShell.php

@@ -12,7 +12,7 @@
  * @since         3.0.0
  * @license       http://www.opensource.org/licenses/mit-license.php MIT License
  */
-namespace Cake\Shell;
+namespace Cake\Shell\Task;
 
 use Cake\Console\Shell;
 use Cake\Core\Plugin;
@@ -20,10 +20,10 @@ use Cake\Filesystem\Folder;
 use Cake\Utility\Inflector;
 
 /**
- * Shell for symlinking / copying plugin assets to app's webroot.
+ * Task for symlinking / copying plugin assets to app's webroot.
  *
  */
-class PluginAssetsShell extends Shell
+class AssetsTask extends Shell
 {
 
     /**

+ 1 - 1
tests/TestCase/Shell/CommandListShellTest.php

@@ -99,7 +99,7 @@ class CommandListShellTest extends TestCase
         $expected = "/\[.*TestPluginTwo.*\] example, welcome/";
         $this->assertRegExp($expected, $output);
 
-        $expected = "/\[.*CORE.*\] i18n, orm_cache, plugin_assets, server/";
+        $expected = "/\[.*CORE.*\] i18n, orm_cache, plugin, server/";
         $this->assertRegExp($expected, $output);
 
         $expected = "/\[.*app.*\] sample/";

+ 1 - 1
tests/TestCase/Shell/CompletionShellTest.php

@@ -120,7 +120,7 @@ class CompletionShellTest extends TestCase
         $output = $this->out->output;
 
         $expected = "TestPlugin.example TestPlugin.sample " .
-            "TestPluginTwo.example TestPluginTwo.welcome i18n orm_cache plugin_assets server sample\n";
+            "TestPluginTwo.example TestPluginTwo.welcome i18n orm_cache plugin server sample\n";
         $this->assertTextEquals($expected, $output);
     }
 

+ 14 - 14
tests/TestCase/Shell/PluginAssetsShellTest.php

@@ -12,20 +12,20 @@
  * @since         3.0.0
  * @license       http://www.opensource.org/licenses/mit-license.php MIT License
  */
-namespace Cake\Test\TestCase\Shell;
+namespace Cake\Test\TestCase\Shell\Task;
 
 use Cake\Core\App;
 use Cake\Core\Configure;
 use Cake\Core\Plugin;
 use Cake\Filesystem\Folder;
-use Cake\Shell\PluginAssetsTask;
+use Cake\Shell\Task\AssetsTask;
 use Cake\TestSuite\TestCase;
 
 /**
- * PluginAssetsShellTest class
+ * AssetsTaskTest class
  *
  */
-class PluginAssetsShellTest extends TestCase
+class AssetsTaskTest extends TestCase
 {
 
     /**
@@ -39,13 +39,13 @@ class PluginAssetsShellTest extends TestCase
 
         $this->skipIf(
             DS === '\\',
-            'Skip PluginAssetsShell tests on windows to prevent side effects for UrlHelper tests on AppVeyor.'
+            'Skip AssetsTask tests on windows to prevent side effects for UrlHelper tests on AppVeyor.'
         );
 
         $this->io = $this->getMock('Cake\Console\ConsoleIo', [], [], '', false);
 
-        $this->shell = $this->getMock(
-            'Cake\Shell\PluginAssetsShell',
+        $this->Task = $this->getMock(
+            'Cake\Shell\Task\AssetsTask',
             ['in', 'out', 'err', '_stop'],
             [$this->io]
         );
@@ -59,7 +59,7 @@ class PluginAssetsShellTest extends TestCase
     public function tearDown()
     {
         parent::tearDown();
-        unset($this->shell);
+        unset($this->Task);
         Plugin::unload();
     }
 
@@ -73,7 +73,7 @@ class PluginAssetsShellTest extends TestCase
         Plugin::load('TestPlugin');
         Plugin::load('Company/TestPluginThree');
 
-        $this->shell->symlink();
+        $this->Task->symlink();
 
         $path = WWW_ROOT . 'test_plugin';
         $link = new \SplFileInfo($path);
@@ -109,7 +109,7 @@ class PluginAssetsShellTest extends TestCase
 
         mkdir(WWW_ROOT . 'company');
 
-        $this->shell->symlink();
+        $this->Task->symlink();
         $path = WWW_ROOT . 'company' . DS . 'test_plugin_three';
         $link = new \SplFileInfo($path);
         if (DS === '\\') {
@@ -132,7 +132,7 @@ class PluginAssetsShellTest extends TestCase
         Plugin::load('TestTheme');
 
         $shell = $this->getMock(
-            'Cake\Shell\PluginAssetsShell',
+            'Cake\Shell\Task\AssetsTask',
             ['in', 'out', 'err', '_stop', '_createSymlink', '_copyDirectory'],
             [$this->io]
         );
@@ -153,7 +153,7 @@ class PluginAssetsShellTest extends TestCase
     {
         Plugin::load('TestPluginTwo');
 
-        $this->shell->symlink();
+        $this->Task->symlink();
         $this->assertFalse(file_exists(WWW_ROOT . 'test_plugin_two'));
     }
 
@@ -167,7 +167,7 @@ class PluginAssetsShellTest extends TestCase
         Plugin::load('TestPlugin');
         Plugin::load('Company/TestPluginThree');
 
-        $this->shell->symlink('TestPlugin');
+        $this->Task->symlink('TestPlugin');
 
         $path = WWW_ROOT . 'test_plugin';
         $link = new \SplFileInfo($path);
@@ -190,7 +190,7 @@ class PluginAssetsShellTest extends TestCase
         Plugin::load('TestPlugin');
         Plugin::load('Company/TestPluginThree');
 
-        $this->shell->copy();
+        $this->Task->copy();
 
         $path = WWW_ROOT . 'test_plugin';
         $dir = new \SplFileInfo($path);