F3_liebig_1220860655.diff
| Packages/FLOW3/Classes/Controller/F3_FLOW3_Controller_Package.php (revision 0) | ||
|---|---|---|
| 1 |
<?php |
|
| 2 |
declare(ENCODING = 'utf-8'); |
|
| 3 |
|
|
| 4 |
/* * |
|
| 5 |
* This script is part of the TYPO3 project - inspiring people to share! * |
|
| 6 |
* * |
|
| 7 |
* TYPO3 is free software; you can redistribute it and/or modify it under * |
|
| 8 |
* the terms of the GNU General Public License version 2 as published by * |
|
| 9 |
* the Free Software Foundation. * |
|
| 10 |
* * |
|
| 11 |
* This script is distributed in the hope that it will be useful, but * |
|
| 12 |
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN- * |
|
| 13 |
* TABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General * |
|
| 14 |
* Public License for more details. * |
|
| 15 |
* */ |
|
| 16 |
|
|
| 17 |
/** |
|
| 18 |
* @package FLOW3 |
|
| 19 |
* @subpackage MVC |
|
| 20 |
* @version $Id$ |
|
| 21 |
*/ |
|
| 22 |
|
|
| 23 |
/** |
|
| 24 |
* Package controller to handle packages from CLI (create/activate/deactivate packages) |
|
| 25 |
* |
|
| 26 |
* @package FLOW3 |
|
| 27 |
* @subpackage MVC |
|
| 28 |
* @version $Id$ |
|
| 29 |
* @license http://opensource.org/licenses/gpl-license.php GNU Public License, version 2 |
|
| 30 |
*/ |
|
| 31 |
class F3_FLOW3_Controller_Package extends F3_FLOW3_MVC_Controller_ActionController {
|
|
| 32 |
|
|
| 33 |
/** |
|
| 34 |
* @var F3_FLOW3_Package_ManagerInterface |
|
| 35 |
*/ |
|
| 36 |
protected $packageManager; |
|
| 37 |
|
|
| 38 |
/** |
|
| 39 |
* @var array |
|
| 40 |
*/ |
|
| 41 |
protected $supportedRequestTypes = array('F3_FLOW3_MVC_CLI_Request');
|
|
| 42 |
|
|
| 43 |
|
|
| 44 |
/** |
|
| 45 |
* Initializes this controller |
|
| 46 |
* |
|
| 47 |
* @return void |
|
| 48 |
* @author Tobias Liebig <mail_typo3@etobi.de> |
|
| 49 |
*/ |
|
| 50 |
public function initializeController() {
|
|
| 51 |
$this->arguments->addNewArgument('packageKey');
|
|
| 52 |
} |
|
| 53 |
|
|
| 54 |
|
|
| 55 |
/** |
|
| 56 |
* Injects the package manager |
|
| 57 |
* |
|
| 58 |
* @param F3_FLOW3_Package_ManagerInterface $packageManager |
|
| 59 |
* @return void |
|
| 60 |
* @author Tobias Liebig <mail_typo3@etobi.de> |
|
| 61 |
*/ |
|
| 62 |
public function injectPackageManager(F3_FLOW3_Package_ManagerInterface $packageManager) {
|
|
| 63 |
$this->packageManager = $packageManager; |
|
| 64 |
} |
|
| 65 |
|
|
| 66 |
|
|
| 67 |
/** |
|
| 68 |
* default action (no arguments given) |
|
| 69 |
* @return void |
|
| 70 |
* @author Tobias Liebig <mail_typo3@etobi.de> |
|
| 71 |
*/ |
|
| 72 |
public function defaultAction() {
|
|
| 73 |
return $this->helpAction(); |
|
| 74 |
} |
|
| 75 |
|
|
| 76 |
|
|
| 77 |
/** |
|
| 78 |
* create the package |
|
| 79 |
* |
|
| 80 |
* @return void |
|
| 81 |
* @author Tobias Liebig <mail_typo3@etobi.de> |
|
| 82 |
*/ |
|
| 83 |
public function createAction() {
|
|
| 84 |
if ($this->arguments['packageKey'] == '') {
|
|
| 85 |
return $this->helpAction(); |
|
| 86 |
} else {
|
|
| 87 |
$this->packageManager->createPackage($this->arguments['packageKey']->getValue()); |
|
| 88 |
return 'new package "' . $this->arguments['packageKey'] . '" created.' . chr(10); |
|
| 89 |
} |
|
| 90 |
} |
|
| 91 |
|
|
| 92 |
|
|
| 93 |
/** |
|
| 94 |
* activate the package |
|
| 95 |
* |
|
| 96 |
* @return void |
|
| 97 |
* @author Tobias Liebig <mail_typo3@etobi.de> |
|
| 98 |
*/ |
|
| 99 |
public function activateAction() {
|
|
| 100 |
if ($this->arguments['packageKey'] == '') {
|
|
| 101 |
return $this->helpAction(); |
|
| 102 |
} else {
|
|
| 103 |
$this->packageManager->activatePackage($this->arguments['packageKey']->getValue()); |
|
| 104 |
return 'package "' . $this->arguments['packageKey'] . '" activated.' . chr(10); |
|
| 105 |
} |
|
| 106 |
} |
|
| 107 |
|
|
| 108 |
|
|
| 109 |
/** |
|
| 110 |
* deactivate the package |
|
| 111 |
* |
|
| 112 |
* @return void |
|
| 113 |
* @author Tobias Liebig <mail_typo3@etobi.de> |
|
| 114 |
*/ |
|
| 115 |
public function deactivateAction() {
|
|
| 116 |
if ($this->arguments['packageKey'] == '') {
|
|
| 117 |
return $this->helpAction(); |
|
| 118 |
} else {
|
|
| 119 |
$this->packageManager->deactivatePackage($this->arguments['packageKey']->getValue()); |
|
| 120 |
return 'package "' . $this->arguments['packageKey'] . '" deactivated.' . chr(10); |
|
| 121 |
} |
|
| 122 |
} |
|
| 123 |
|
|
| 124 |
|
|
| 125 |
/** |
|
| 126 |
* remove the package |
|
| 127 |
* |
|
| 128 |
* @return void |
|
| 129 |
* @author Tobias Liebig <mail_typo3@etobi.de> |
|
| 130 |
*/ |
|
| 131 |
public function removeAction() {
|
|
| 132 |
if ($this->arguments['packageKey'] == '') {
|
|
| 133 |
return $this->helpAction(); |
|
| 134 |
} else {
|
|
| 135 |
$this->packageManager->removePackage($this->arguments['packageKey']->getValue()); |
|
| 136 |
return 'package "' . $this->arguments['packageKey'] . '" removed.' . chr(10); |
|
| 137 |
} |
|
| 138 |
} |
|
| 139 |
|
|
| 140 |
|
|
| 141 |
/** |
|
| 142 |
* displays a help screen |
|
| 143 |
* |
|
| 144 |
* @return void |
|
| 145 |
* @author Tobias Liebig <mail_typo3@etobi.de> |
|
| 146 |
*/ |
|
| 147 |
public function helpAction() {
|
|
| 148 |
return chr(10) . |
|
| 149 |
'FLOW3 Package CLI Controller' . chr(10) . |
|
| 150 |
'Usage: php index_dev.php FLOW3 Package <command> package-key=<PACKAGE>' . chr(10). |
|
| 151 |
chr(10) . |
|
| 152 |
'<command>:' . chr(10) . |
|
| 153 |
' create - create a new package' . chr(10). |
|
| 154 |
' activate - activate a package' . chr(10). |
|
| 155 |
' deactivate - activate a package' . chr(10) |
|
| 156 |
; |
|
| 157 |
} |
|
| 158 |
} |
|
| 159 |
|
|
| 160 |
?> |
|
| 161 | 0 | |
| Packages/FLOW3/Classes/Controller/F3_FLOW3_Controller_Cache.php (revision 0) | ||
|---|---|---|
| 1 |
<?php |
|
| 2 |
declare(ENCODING = 'utf-8'); |
|
| 3 |
|
|
| 4 |
/* * |
|
| 5 |
* This script is part of the TYPO3 project - inspiring people to share! * |
|
| 6 |
* * |
|
| 7 |
* TYPO3 is free software; you can redistribute it and/or modify it under * |
|
| 8 |
* the terms of the GNU General Public License version 2 as published by * |
|
| 9 |
* the Free Software Foundation. * |
|
| 10 |
* * |
|
| 11 |
* This script is distributed in the hope that it will be useful, but * |
|
| 12 |
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN- * |
|
| 13 |
* TABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General * |
|
| 14 |
* Public License for more details. * |
|
| 15 |
* */ |
|
| 16 |
|
|
| 17 |
/** |
|
| 18 |
* @package FLOW3 |
|
| 19 |
* @subpackage MVC |
|
| 20 |
* @version $Id$ |
|
| 21 |
*/ |
|
| 22 |
|
|
| 23 |
/** |
|
| 24 |
* Package controller to handle cache from CLI (flush) |
|
| 25 |
* |
|
| 26 |
* @package FLOW3 |
|
| 27 |
* @subpackage MVC |
|
| 28 |
* @version $Id$ |
|
| 29 |
* @license http://opensource.org/licenses/gpl-license.php GNU Public License, version 2 |
|
| 30 |
*/ |
|
| 31 |
class F3_FLOW3_Controller_Cache extends F3_FLOW3_MVC_Controller_ActionController {
|
|
| 32 |
|
|
| 33 |
/** |
|
| 34 |
* @var F3_FLOW3_Cache_Manager |
|
| 35 |
*/ |
|
| 36 |
protected $cacheManager; |
|
| 37 |
|
|
| 38 |
/** |
|
| 39 |
* @var array |
|
| 40 |
*/ |
|
| 41 |
protected $supportedRequestTypes = array('F3_FLOW3_MVC_CLI_Request');
|
|
| 42 |
|
|
| 43 |
|
|
| 44 |
|
|
| 45 |
/** |
|
| 46 |
* Injects the cache manager |
|
| 47 |
* |
|
| 48 |
* @param F3_FLOW3_Cache_Manager $cacheManager |
|
| 49 |
* @return void |
|
| 50 |
* @author Tobias Liebig <mail_typo3@etobi.de> |
|
| 51 |
*/ |
|
| 52 |
public function injectCacheManager(F3_FLOW3_Cache_Manager $cacheManager) {
|
|
| 53 |
$this->cacheManager = $cacheManager; |
|
| 54 |
} |
|
| 55 |
|
|
| 56 |
|
|
| 57 |
/** |
|
| 58 |
* create the package |
|
| 59 |
* |
|
| 60 |
* @return void |
|
| 61 |
* @author Tobias Liebig <mail_typo3@etobi.de> |
|
| 62 |
*/ |
|
| 63 |
public function flushAction() {
|
|
| 64 |
$this->cacheManager->flushCaches(); |
|
| 65 |
return 'all caches flushed.' . chr(10); |
|
| 66 |
} |
|
| 67 |
} |
|
| 68 |
|
|
| 69 |
?> |
|
| Packages/FLOW3/Tests/Controller/F3_FLOW3_Controller_PackageTest.php (revision 0) | ||
|---|---|---|
| 1 |
<?php |
|
| 2 |
declare(ENCODING = 'utf-8'); |
|
| 3 |
|
|
| 4 |
/* * |
|
| 5 |
* This script is part of the TYPO3 project - inspiring people to share! * |
|
| 6 |
* * |
|
| 7 |
* TYPO3 is free software; you can redistribute it and/or modify it under * |
|
| 8 |
* the terms of the GNU General Public License version 2 as published by * |
|
| 9 |
* the Free Software Foundation. * |
|
| 10 |
* * |
|
| 11 |
* This script is distributed in the hope that it will be useful, but * |
|
| 12 |
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN- * |
|
| 13 |
* TABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General * |
|
| 14 |
* Public License for more details. * |
|
| 15 |
* */ |
|
| 16 |
|
|
| 17 |
/** |
|
| 18 |
* @package FLOW3 |
|
| 19 |
* @subpackage Controller |
|
| 20 |
* @version $Id$ |
|
| 21 |
*/ |
|
| 22 |
|
|
| 23 |
/** |
|
| 24 |
* Testcase for the Package Controller (CLI) |
|
| 25 |
* |
|
| 26 |
* @package FLOW3 |
|
| 27 |
* @subpackage Controller |
|
| 28 |
* @version $Id$ |
|
| 29 |
* @license http://opensource.org/licenses/gpl-license.php GNU Public License, version 2 |
|
| 30 |
*/ |
|
| 31 |
class F3_FLOW3_Controller_PackageTest extends F3_Testing_BaseTestCase {
|
|
| 32 |
|
|
| 33 |
|
|
| 34 |
/** |
|
| 35 |
* @test |
|
| 36 |
* @author Tobias Liebig <mail_typo3@etobi.de> |
|
| 37 |
*/ |
|
| 38 |
public function testCreateActionCallsPackageManagerCreatePackage() {
|
|
| 39 |
// get mocked Packagemanager |
|
| 40 |
$packageManager = $this->getMock('F3_FLOW3_Package_ManagerInterface');
|
|
| 41 |
|
|
| 42 |
$packageManager->expects($this->once()) |
|
| 43 |
->method('createPackage')
|
|
| 44 |
->with($this->equalTo('FooBarPackageName'));
|
|
| 45 |
|
|
| 46 |
$packageController = new F3_FLOW3_Controller_Package($this->componentFactory, $packageManager); |
|
| 47 |
$packageController->injectPackageManager($packageManager); |
|
| 48 |
$packageController->initializeController(); |
|
| 49 |
|
|
| 50 |
$argumentPackageKey = new F3_FLOW3_MVC_Controller_Argument('packageKey','Text', $this->componentFactory);
|
|
| 51 |
$packageControllerArguments = $packageController->getArguments(); |
|
| 52 |
$packageControllerArguments['packageKey']->setValue('FooBarPackageName');
|
|
| 53 |
|
|
| 54 |
$packageController->createAction(); |
|
| 55 |
} |
|
| 56 |
|
|
| 57 |
/** |
|
| 58 |
* @test |
|
| 59 |
* @author Tobias Liebig <mail_typo3@etobi.de> |
|
| 60 |
*/ |
|
| 61 |
public function testActivateActionCallsPackageManagerActivatePackage() {
|
|
| 62 |
// get mocked Packagemanager |
|
| 63 |
$packageManager = $this->getMock('F3_FLOW3_Package_ManagerInterface');
|
|
| 64 |
|
|
| 65 |
$packageManager->expects($this->once()) |
|
| 66 |
->method('activatePackage')
|
|
| 67 |
->with($this->equalTo('FooBarPackageName'));
|
|
| 68 |
|
|
| 69 |
$packageController = new F3_FLOW3_Controller_Package($this->componentFactory, $packageManager); |
|
| 70 |
$packageController->injectPackageManager($packageManager); |
|
| 71 |
$packageController->initializeController(); |
|
| 72 |
|
|
| 73 |
$argumentPackageKey = new F3_FLOW3_MVC_Controller_Argument('packageKey','Text', $this->componentFactory);
|
|
| 74 |
$packageControllerArguments = $packageController->getArguments(); |
|
| 75 |
$packageControllerArguments['packageKey']->setValue('FooBarPackageName');
|
|
| 76 |
|
|
| 77 |
$packageController->activateAction(); |
|
| 78 |
} |
|
| 79 |
|
|
| 80 |
/** |
|
| 81 |
* @test |
|
| 82 |
* @author Tobias Liebig <mail_typo3@etobi.de> |
|
| 83 |
*/ |
|
| 84 |
public function testDeactivateActionCallsPackageManagerDeactivatePackage() {
|
|
| 85 |
// get mocked Packagemanager |
|
| 86 |
$packageManager = $this->getMock('F3_FLOW3_Package_ManagerInterface');
|
|
| 87 |
|
|
| 88 |
$packageManager->expects($this->once()) |
|
| 89 |
->method('deactivatePackage')
|
|
| 90 |
->with($this->equalTo('FooBarPackageName'));
|
|
| 91 |
|
|
| 92 |
$packageController = new F3_FLOW3_Controller_Package($this->componentFactory, $packageManager); |
|
| 93 |
$packageController->injectPackageManager($packageManager); |
|
| 94 |
$packageController->initializeController(); |
|
| 95 |
|
|
| 96 |
$argumentPackageKey = new F3_FLOW3_MVC_Controller_Argument('packageKey','Text', $this->componentFactory);
|
|
| 97 |
$packageControllerArguments = $packageController->getArguments(); |
|
| 98 |
$packageControllerArguments['packageKey']->setValue('FooBarPackageName');
|
|
| 99 |
|
|
| 100 |
$packageController->deactivateAction(); |
|
| 101 |
} |
|
| 102 |
|
|
| 103 |
|
|
| 104 |
/** |
|
| 105 |
* @test |
|
| 106 |
* @author Tobias Liebig <mail_typo3@etobi.de> |
|
| 107 |
*/ |
|
| 108 |
public function testDeactivateActionCallsPackageManagerRemovePackage() {
|
|
| 109 |
// get mocked Packagemanager |
|
| 110 |
$packageManager = $this->getMock('F3_FLOW3_Package_ManagerInterface');
|
|
| 111 |
|
|
| 112 |
$packageManager->expects($this->once()) |
|
| 113 |
->method('removePackage')
|
|
| 114 |
->with($this->equalTo('FooBarPackageName'));
|
|
| 115 |
|
|
| 116 |
$packageController = new F3_FLOW3_Controller_Package($this->componentFactory, $packageManager); |
|
| 117 |
$packageController->injectPackageManager($packageManager); |
|
| 118 |
$packageController->initializeController(); |
|
| 119 |
|
|
| 120 |
$argumentPackageKey = new F3_FLOW3_MVC_Controller_Argument('packageKey','Text', $this->componentFactory);
|
|
| 121 |
$packageControllerArguments = $packageController->getArguments(); |
|
| 122 |
$packageControllerArguments['packageKey']->setValue('FooBarPackageName');
|
|
| 123 |
|
|
| 124 |
$packageController->removeAction(); |
|
| 125 |
} |
|
| 126 |
|
|
| 127 |
|
|
| 128 |
/** |
|
| 129 |
* @test |
|
| 130 |
* @author Tobias Liebig <mail_typo3@etobi.de> |
|
| 131 |
*/ |
|
| 132 |
public function testCreateActionWithoutPackageKeyCallsHelpAction() {
|
|
| 133 |
// get mocked Packagemanager |
|
| 134 |
$packageManager = $this->getMock('F3_FLOW3_Package_ManagerInterface');
|
|
| 135 |
|
|
| 136 |
// mock method helpAction (and only that) for Package Controller |
|
| 137 |
$packageController = $this->getMock('F3_FLOW3_Controller_Package',
|
|
| 138 |
array('helpAction'),
|
|
| 139 |
array($this->componentFactory, $packageManager)); |
|
| 140 |
|
|
| 141 |
$packageController->expects($this->once()) |
|
| 142 |
->method('helpAction');
|
|
| 143 |
|
|
| 144 |
$packageController->initializeController(); |
|
| 145 |
|
|
| 146 |
$packageController->createAction(); |
|
| 147 |
} |
|
| 148 |
|
|
| 149 |
|
|
| 150 |
/** |
|
| 151 |
* @test |
|
| 152 |
* @author Tobias Liebig <mail_typo3@etobi.de> |
|
| 153 |
*/ |
|
| 154 |
public function testDefaultActionCallsHelpAction() {
|
|
| 155 |
// get mocked Packagemanager |
|
| 156 |
$packageManager = $this->getMock('F3_FLOW3_Package_ManagerInterface');
|
|
| 157 |
|
|
| 158 |
// mock method helpAction (and only that) for Package Controller |
|
| 159 |
$packageController = $this->getMock('F3_FLOW3_Controller_Package',
|
|
| 160 |
array('helpAction'),
|
|
| 161 |
array($this->componentFactory, $packageManager)); |
|
| 162 |
|
|
| 163 |
$packageController->expects($this->once()) |
|
| 164 |
->method('helpAction');
|
|
| 165 |
|
|
| 166 |
$packageController->initializeController(); |
|
| 167 |
|
|
| 168 |
$packageController->defaultAction(); |
|
| 169 |
} |
|
| 170 |
|
|
| 171 |
|
|
| 172 |
|
|
| 173 |
|
|
| 174 |
|
|
| 175 |
} |
|
| 176 |
|
|
| 177 |
?> |
|
| Packages/FLOW3/Tests/Controller/F3_FLOW3_Controller_CacheTest.php (revision 0) | ||
|---|---|---|
| 1 |
<?php |
|
| 2 |
declare(ENCODING = 'utf-8'); |
|
| 3 |
|
|
| 4 |
/* * |
|
| 5 |
* This script is part of the TYPO3 project - inspiring people to share! * |
|
| 6 |
* * |
|
| 7 |
* TYPO3 is free software; you can redistribute it and/or modify it under * |
|
| 8 |
* the terms of the GNU General Public License version 2 as published by * |
|
| 9 |
* the Free Software Foundation. * |
|
| 10 |
* * |
|
| 11 |
* This script is distributed in the hope that it will be useful, but * |
|
| 12 |
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN- * |
|
| 13 |
* TABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General * |
|
| 14 |
* Public License for more details. * |
|
| 15 |
* */ |
|
| 16 |
|
|
| 17 |
/** |
|
| 18 |
* @package FLOW3 |
|
| 19 |
* @subpackage Controller |
|
| 20 |
* @version $Id$ |
|
| 21 |
*/ |
|
| 22 |
|
|
| 23 |
/** |
|
| 24 |
* Testcase for the Cache Controller (CLI) |
|
| 25 |
* |
|
| 26 |
* @package FLOW3 |
|
| 27 |
* @subpackage Controller |
|
| 28 |
* @version $Id$ |
|
| 29 |
* @license http://opensource.org/licenses/gpl-license.php GNU Public License, version 2 |
|
| 30 |
*/ |
|
| 31 |
class F3_FLOW3_Controller_CacheTest extends F3_Testing_BaseTestCase {
|
|
| 32 |
|
|
| 33 |
|
|
| 34 |
/** |
|
| 35 |
* @test |
|
| 36 |
* @author Tobias Liebig <mail_typo3@etobi.de> |
|
| 37 |
*/ |
|
| 38 |
public function testFlushActionCallsCacheManagerFlushCache() {
|
|
| 39 |
// get mocked Cachemanager |
|
| 40 |
$cacheManager = $this->getMock('F3_FLOW3_Cache_Manager');
|
|
| 41 |
|
|
| 42 |
$cacheManager->expects($this->once()) |
|
| 43 |
->method('flushCaches')
|
|
| 44 |
->with(); |
|
| 45 |
|
|
| 46 |
$cacheController = new F3_FLOW3_Controller_Cache($this->componentFactory, $this->componentFactory->getComponent('F3_FLOW3_Package_ManagerInterface'));
|
|
| 47 |
$cacheController->injectCacheManager($cacheManager); |
|
| 48 |
|
|
| 49 |
$cacheController->flushAction(); |
|
| 50 |
} |
|
| 51 |
} |
|
| 52 |
|
|
| 53 |
?> |
|
| FLOW3.sh (revision 0) | ||
|---|---|---|
| 1 |
#!/bin/sh |
|
| 2 |
############################################################################### |
|
| 3 |
# |
|
| 4 |
# This script is part of the TYPO3 project - inspiring people to share! |
|
| 5 |
# |
|
| 6 |
# TYPO3 is free software; you can redistribute it and/or modify it under |
|
| 7 |
# the terms of the GNU General Public License version 2 as published by |
|
| 8 |
# the Free Software Foundation. |
|
| 9 |
# |
|
| 10 |
# This script is distributed in the hope that it will be useful, but |
|
| 11 |
# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN- |
|
| 12 |
# TABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General |
|
| 13 |
# Public License for more details. |
|
| 14 |
# |
|
| 15 |
# |
|
| 16 |
############################################################################### |
|
| 17 |
|
|
| 18 |
## |
|
| 19 |
# |
|
| 20 |
# @package FLOW3 |
|
| 21 |
# @author Tobias Liebig <mail_typo3@etobi.de> |
|
| 22 |
# @version $Id$ |
|
| 23 |
# @license http://opensource.org/licenses/gpl-license.php GNU Public License, version 2 |
|
| 24 |
# |
|
| 25 |
## |
|
| 26 |
|
|
| 27 |
# Configuration |
|
| 28 |
PHP='/usr/local/bin/php' |
|
| 29 |
BOOTSTRAP='Public/index.php' |
|
| 30 |
BOOTSTRAPDEV='Public/index_dev.php' |
|
| 31 |
|
|
| 32 |
|
|
| 33 |
printUsage () {
|
|
| 34 |
echo 'FLOW3.sh CLI' |
|
| 35 |
echo '' |
|
| 36 |
echo 'usage: FLOW3 <options> <command>' |
|
| 37 |
echo '' |
|
| 38 |
echo '' |
|
| 39 |
echo 'Options:' |
|
| 40 |
echo '' |
|
| 41 |
echo ' -h, --help - print this message' |
|
| 42 |
echo ' -d, --dev - execute in development context' |
|
| 43 |
echo '' |
|
| 44 |
echo '' |
|
| 45 |
echo 'Available commands:' |
|
| 46 |
echo '' |
|
| 47 |
echo ' package create <package-key> - create a new package' |
|
| 48 |
echo ' package activate <package-key> - activate a package' |
|
| 49 |
echo ' package deactivate <package-key> - deactivate a package' |
|
| 50 |
echo ' package remove <package-key> - remove a package' |
|
| 51 |
echo '' |
|
| 52 |
echo ' cache flush - flush all caches' |
|
| 53 |
echo '' |
|
| 54 |
echo ' testing <package-key> <output-directory> [<testcaseClassName> [<coverage-directory>]] ' |
|
| 55 |
echo ' - run unit tests' |
|
| 56 |
echo ' <package-key> Package to test (mandatory)' |
|
| 57 |
echo ' <output-directory> path to write the logfile.xml (mandatory)' |
|
| 58 |
echo ' <testcaseClassName> only run this testcase (optional)' |
|
| 59 |
echo ' <coverage-directory> path to write the clover.xml (optional)' |
|
| 60 |
echo '' |
|
| 61 |
exit 1 |
|
| 62 |
} |
|
| 63 |
|
|
| 64 |
# check minimum argument count |
|
| 65 |
if [ $# -lt 2 ]; then |
|
| 66 |
printUsage |
|
| 67 |
fi |
|
| 68 |
|
|
| 69 |
PACKAGE='' |
|
| 70 |
CONTROLLER='' |
|
| 71 |
ACTION='' |
|
| 72 |
ARGUMENTS='' |
|
| 73 |
|
|
| 74 |
|
|
| 75 |
# parse argument list |
|
| 76 |
while [ $# -ge 1 ]; do |
|
| 77 |
case $1 in |
|
| 78 |
help|--help|-h) |
|
| 79 |
printUsage |
|
| 80 |
;; |
|
| 81 |
|
|
| 82 |
--dev|-d) |
|
| 83 |
BOOTSTRAP=$BOOTSTRAPDEV |
|
| 84 |
;; |
|
| 85 |
|
|
| 86 |
package) |
|
| 87 |
PACKAGE='FLOW3' |
|
| 88 |
CONTROLLER='Package' |
|
| 89 |
shift |
|
| 90 |
case $1 in |
|
| 91 |
create|activate|deactivate|remove) |
|
| 92 |
if [ $# -ne 2 ]; then |
|
| 93 |
echo 'Please specify a package-key' |
|
| 94 |
echo |
|
| 95 |
printUsage |
|
| 96 |
else |
|
| 97 |
ACTION=$1 |
|
| 98 |
shift |
|
| 99 |
ARGUMENTS="package-key=$1" |
|
| 100 |
fi |
|
| 101 |
esac |
|
| 102 |
;; |
|
| 103 |
|
|
| 104 |
testing) |
|
| 105 |
PACKAGE='Testing' |
|
| 106 |
CONTROLLER='CLI' |
|
| 107 |
ACTION='run' |
|
| 108 |
shift |
|
| 109 |
if [ $# -lt 2 ]; then |
|
| 110 |
echo 'Please specify a package-key and output-directory' |
|
| 111 |
echo |
|
| 112 |
printUsage |
|
| 113 |
else |
|
| 114 |
ARGUMENTS="package-key=$1" |
|
| 115 |
shift |
|
| 116 |
ARGUMENTS="$ARGUMENTS output-directory=$1" |
|
| 117 |
|
|
| 118 |
if [ $# -gt 1 ]; then |
|
| 119 |
shift |
|
| 120 |
ARGUMENTS="$ARGUMENTS testcaseClassName=$1" |
|
| 121 |
fi |
|
| 122 |
if [ $# -gt 1 ]; then |
|
| 123 |
shift |
|
| 124 |
ARGUMENTS="$ARGUMENTS coverage-directory=$1" |
|
| 125 |
fi |
|
| 126 |
fi |
|
| 127 |
;; |
|
| 128 |
|
|
| 129 |
cache) |
|
| 130 |
shift |
|
| 131 |
if [ $# -lt 1 ]; then |
|
| 132 |
echo 'Please specify a subcommand' |
|
| 133 |
echo |
|
| 134 |
printUsage |
|
| 135 |
else |
|
| 136 |
if [ "$1" = 'flush' ]; then |
|
| 137 |
PACKAGE='FLOW3' |
|
| 138 |
CONTROLLER='Cache' |
|
| 139 |
ACTION='flush' |
|
| 140 |
fi |
|
| 141 |
fi |
|
| 142 |
;; |
|
| 143 |
|
|
| 144 |
*) |
|
| 145 |
PACKAGE='' |
|
| 146 |
CONTROLLER='' |
|
| 147 |
ACTION='' |
|
| 148 |
ARGUMENTS='' |
|
| 149 |
;; |
|
| 150 |
|
|
| 151 |
esac |
|
| 152 |
shift |
|
| 153 |
done |
|
| 154 |
|
|
| 155 |
|
|
| 156 |
|
|
| 157 |
if [ "$PACKAGE" = '' -o "$CONTROLLER" = '' -o "$ACTION" = '' ]; then |
|
| 158 |
printUsage |
|
| 159 |
fi |
|
| 160 |
|
|
| 161 |
|
|
| 162 |
# echo P $PACKAGE |
|
| 163 |
# echo C $CONTROLLER |
|
| 164 |
# echo A $ACTION |
|
| 165 |
# echo A $ARGUMENTS |
|
| 166 |
|
|
| 167 |
# execute the command |
|
| 168 |
$PHP $BOOTSTRAP $PACKAGE $CONTROLLER $ACTION $ARGUMENTS |
|
| 169 | 0 | |