Permalink
Browse files

restructured for new directory convention and rewritten using new loa…

…ding class feature
  • Loading branch information...
1 parent b40c6f9 commit 7fce568e503c92c5e511e17b9868af5e901f03ec hiromi2424 committed Jun 5, 2011
Showing with 241 additions and 192 deletions.
  1. +1 −1 vendors/shells/benchmark.php → Console/Command/BenchmarkShell.php
  2. +1 −1 vendors/shells/whitespace.php → Console/Command/WhitespaceShell.php
  3. +15 −9 Controller/Component/{Toolbar.php → ToolbarComponent.php}
  4. 0 { → Controller}/DebugKitAppController.php
  5. +2 −1 Controller/ToolbarAccessController.php
  6. 0 {locale → Locale}/debug_kit.pot
  7. 0 {locale → Locale}/eng/LC_MESSAGES/debug_kit.po
  8. 0 {locale → Locale}/spa/LC_MESSAGES/debug_kit.po
  9. +1 −3 Model/Behavior/TimedBehavior.php
  10. 0 { → Model}/DebugKitAppModel.php
  11. +5 −4 Model/{ToolbarAccessModel.php → ToolbarAccess.php}
  12. +6 −6 tests/cases/all_debug_kit_view.test.php → Test/Case/AllDebugKitTest.php
  13. +6 −6 tests/cases/all_debug_kit_without_view.test.php → Test/Case/AllDebugKitViewTest.php
  14. +43 −0 Test/Case/AllDebugKitWithoutViewTest.php
  15. +18 −20 tests/cases/components/toolbar.test.php → Test/Case/Controller/Component/ToolbarComponentTest.php
  16. +63 −0 Test/Case/DebugkitGroupTestCase.php
  17. +1 −1 tests/cases/behaviors/timed.test.php → Test/Case/Model/Behavior/TimedBehaviorTest.php
  18. +1 −1 tests/cases/models/toolbar_access.test.php → Test/Case/Model/ToolbarAccessTest.php
  19. +3 −0 tests/cases/test_objects.php → Test/Case/TestFireCake.php
  20. +2 −2 tests/cases/vendors/debug_kit_debugger.test.php → Test/Case/Vendor/DebugKitDebuggerTest.php
  21. +3 −3 tests/cases/vendors/fire_cake.test.php → Test/Case/Vendor/FireCakeTest.php
  22. +19 −17 tests/cases/views/debug.test.php → Test/Case/View/DebugViewTest.php
  23. +11 −8 tests/cases/helpers/fire_php_toolbar.test.php → Test/Case/View/Helper/FirePhpToolbarHelperTest.php
  24. +11 −6 tests/cases/helpers/html_toolbar.test.php → Test/Case/View/Helper/HtmlToolbarHelperTest.php
  25. +8 −6 tests/cases/helpers/toolbar.test.php → Test/Case/View/Helper/ToolbarHelperTest.php
  26. 0 ...p/controllers/debug_kit_test_controller.php → Test/test_app/Controller/DebugKitTestController.php
  27. 0 ...endors/plugin_test_panel.php → Test/test_app/Plugin/DebugkitTestPlugin/Vendor/PluginTestPanel.php
  28. 0 tests/test_app/vendors/test_panel.php → Test/test_app/Vendor/TestPanel.php
  29. 0 {tests/test_app/views/debug_kit_test → Test/test_app/View/DebugKitTest}/request_action_render.ctp
  30. +1 −1 vendors/debug_kit_debugger.php → Vendor/DebugKitDebugger.php
  31. +3 −2 vendors/fire_cake.php → Vendor/FireCake.php
  32. +6 −6 View/{debug.php → DebugView.php}
  33. 0 View/{elements → Elements}/debug_toolbar.ctp
  34. 0 View/{elements → Elements}/history_panel.ctp
  35. 0 View/{elements → Elements}/log_panel.ctp
  36. 0 View/{elements → Elements}/request_panel.ctp
  37. 0 View/{elements → Elements}/session_panel.ctp
  38. +1 −1 View/{elements → Elements}/sql_log_panel.ctp
  39. +1 −1 View/{elements → Elements}/timer_panel.ctp
  40. 0 View/{elements → Elements}/variables_panel.ctp
  41. +2 −2 View/Helper/{FirePhpToolbar.php → FirePhpToolbarHelper.php}
  42. +4 −4 View/Helper/HtmlToolbarHelper.php
  43. +2 −1 View/Helper/SimpleGraphHelper.php
  44. +1 −1 View/Helper/ToolbarHelper.php
  45. 0 View/{toolbar_access → ToolbarAccess}/history_state.ctp
  46. 0 View/{toolbar_access → ToolbarAccess}/sql_explain.ctp
  47. +0 −78 tests/lib/debug_kit_group_test.php
@@ -44,7 +44,7 @@ public function main() {
$url = $this->args[0];
$defaults = array('t' => 100, 'n' => 10);
- $options = array_merge($defaults, $this->params);
+ $options = array_merge($defaults, $this->request->params);
$times = array();
$this->out(String::insert(__d('debug_kit', '-> Testing :url'), compact('url')));
@@ -19,7 +19,7 @@
* @since DebugKit 1.3
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
-App::import('Core',array('Folder'));
+App::uses('Folder', 'Utility');
class WhitespaceShell extends Shell {
@@ -122,7 +122,7 @@ public function __construct(ComponentCollection $collection, $settings = array()
$this->enabled = false;
return false;
}
- App::import('Vendor', 'DebugKit.DebugKitDebugger');
+ App::uses('DebugKitDebugger', 'DebugKit.vendors');
DebugKitDebugger::setMemoryPoint(__d('debug_kit', 'Component initialization'));
DebugKitDebugger::startTimer('componentInit', __d('debug_kit', 'Component initialization and startup'));
@@ -302,11 +302,20 @@ protected function _gatherVars($controller) {
protected function _loadPanels($panels, $settings) {
foreach ($panels as $panel) {
$className = $panel . 'Panel';
- if (!class_exists($className) && !App::import('Vendor', $className)) {
+ list($plugin, $className) = pluginSplit($className);
+
+ if ($plugin) {
+ if (!CakePlugin::loaded($plugin)) {
+ CakePlugin::load($plugin, $settings);
+ }
+ $plugin .= '.';
+ }
+
+ App::uses($className, $plugin . 'vendors');
+ if (!class_exists($className)) {
trigger_error(__d('debug_kit', 'Could not load DebugToolbar panel %s', $panel), E_USER_WARNING);
continue;
}
- list($plugin, $className) = pluginSplit($className);
$panelObj = new $className($settings);
if (is_subclass_of($panelObj, 'DebugPanel') || is_subclass_of($panelObj, 'debugpanel')) {
list(, $panel) = pluginSplit($panel);
@@ -324,14 +333,14 @@ protected function _loadPanels($panels, $settings) {
*/
protected function _makeViewClass($baseClassName) {
if (!class_exists('DoppelGangerView')) {
- $parent = strtolower($baseClassName) === 'view' ? false : true;
- App::import('View', $baseClassName, $parent);
+ $plugin = false;
if (strpos($baseClassName, '.') !== false) {
list($plugin, $baseClassName) = explode('.', $baseClassName);
}
if (strpos($baseClassName, 'View') === false) {
$baseClassName .= 'View';
}
+ App::uses($baseClassName, $plugin . 'View');
$class = "class DoppelGangerView extends $baseClassName {}";
$this->_eval($class);
}
@@ -650,7 +659,7 @@ public function beforeRender($controller) {
$driver = $db->config['datasource'];
}
$explain = false;
- $isExplainable = ($driver === 'mysql' || $driver === 'mysqli' || $driver === 'postgres');
+ $isExplainable = (preg_match('/(Mysql|Postgres)$/', $driver));
if ($isExplainable) {
$explain = true;
}
@@ -676,9 +685,6 @@ class LogPanel extends DebugPanel {
*/
public function __construct($settings) {
parent::__construct();
- if (!class_exists('CakeLog')) {
- App::import('Core', 'CakeLog');
- }
$existing = CakeLog::configured();
if (empty($existing)) {
CakeLog::config('default', array(
File renamed without changes.
@@ -19,6 +19,8 @@
* @since DebugKit 1.1
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
**/
+App::uses('Security', 'Utility');
+
class ToolbarAccessController extends DebugKitAppController {
/**
* name
@@ -96,7 +98,6 @@ public function sql_explain() {
) {
throw new BadRequestException('Invalid parameters');
}
- App::import('Core', 'Security');
$hash = Security::hash($this->request->data['log']['sql'] . $this->request->data['log']['ds'], null, true);
if ($hash !== $this->request->data['log']['hash']) {
throw new BadRequestException('Invalid parameters');
File renamed without changes.
@@ -17,6 +17,7 @@
* @since DebugKit 1.3
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
+App::uses('DebugKitDebugger', 'DebugKit.vendors');
class TimedBehavior extends ModelBehavior {
@@ -45,9 +46,6 @@ class TimedBehavior extends ModelBehavior {
* @return void
*/
public function setup($Model, $settings = null) {
- if (!class_exists('DebugKitDebugger')){
- App::import('Vendor', 'DebugKit.DebugKitDebugger');
- }
if (is_array($settings)) {
$this->settings[$Model->alias] = array_merge($this->_defaults, $settings);
} else {
File renamed without changes.
@@ -19,6 +19,8 @@
* @since DebugKit 1.3
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
**/
+App::uses('ConnectionManager', 'Model');
+
class ToolbarAccess extends Object {
/**
@@ -30,14 +32,13 @@ class ToolbarAccess extends Object {
* @return array Array of explain information or empty array if connection is unsupported.
*/
public function explainQuery($connection, $query) {
- App::import('Model', 'ConnectionManager');
$db = ConnectionManager::getDataSource($connection);
- $driver = $db->config['driver'];
+ $datasource = $db->config['datasource'];
$return = array();
- if ($driver === 'mysqli' || $driver === 'mysql' || $driver === 'postgres') {
+ if (preg_match('/(Mysql|Postgres)$/', $datasource)) {
$explained = $db->query('EXPLAIN ' . $query);
- if ($driver === 'postgres') {
+ if (preg_match('/Postgres$/', $datasource)) {
$queryPlan = array();
foreach ($explained as $postgreValue) {
$queryPlan[] = array($postgreValue[0]['QUERY PLAN']);
@@ -1,6 +1,6 @@
<?php
-require_once App::pluginPath('DebugKit') . 'tests' . DS . 'lib' . DS . 'debug_kit_group_test.php';
+require_once dirname(__FILE__) . DS . 'DebugkitGroupTestCase.php';
/**
* View Group Test for debugkit
@@ -27,16 +27,16 @@
* @subpackage cake.tests.cases
*/
-class AllDebugKitViewTest extends DebugkitGroupTest {
+class AllDebugKitTest extends DebugkitGroupTestCase {
/**
*
*
- * @access public
- * @return void
+ * @return PHPUnit_Framework_TestSuite the instance of PHPUnit_Framework_TestSuite
*/
public static function suite() {
- $suite = self::_getSuite();
- $suite->addTestFiles(self::_testFiles('views'));
+ $suite = new self;
+ $files = $suite->getTestFiles();
+ $suite->addTestFiles($files);
return $suite;
}
@@ -1,6 +1,6 @@
<?php
-require_once App::pluginPath('DebugKit') . 'tests' . DS . 'lib' . DS . 'debug_kit_group_test.php';
+require_once dirname(__FILE__) . DS . 'DebugkitGroupTestCase.php';
/**
* View Group Test for debugkit
@@ -27,16 +27,16 @@
* @subpackage cake.tests.cases
*/
-class AllDebugKitWithoutViewTest extends DebugkitGroupTest {
+class AllDebugKitViewTest extends DebugkitGroupTestCase {
/**
*
*
- * @access public
- * @return void
+ * @return PHPUnit_Framework_TestSuite the instance of PHPUnit_Framework_TestSuite
*/
public static function suite() {
- $suite = self::_getSuite();
- $suite->addTestFiles(self::_testFiles(null, 'views'));
+ $suite = new self;
+ $files = $suite->getTestFiles('View');
+ $suite->addTestFiles($files);
return $suite;
}
@@ -0,0 +1,43 @@
+<?php
+
+require_once dirname(__FILE__) . DS . 'DebugkitGroupTestCase.php';
+
+/**
+ * View Group Test for debugkit
+ *
+ * PHP versions 4 and 5
+ *
+ * CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
+ * Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org)
+ *
+ * Licensed under The MIT License
+ * Redistributions of files must retain the above copyright notice.
+ *
+ * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org)
+ * @link http://cakephp.org
+ * @package debug_kit
+ * @subpackage debug_kit.tests.groups
+ * @since DebugKit 1.0
+ * @license MIT License (http://www.opensource.org/licenses/mit-license.php)
+ **/
+/**
+ * DebugKitViewTestSuite class
+ *
+ * @package cake
+ * @subpackage cake.tests.cases
+ */
+
+class AllDebugKitWithoutViewTest extends DebugkitGroupTestCase {
+/**
+ *
+ *
+ * @return PHPUnit_Framework_TestSuite the instance of PHPUnit_Framework_TestSuite
+ */
+ public static function suite() {
+ $suite = new self;
+ $files = $suite->getTestFiles(null, 'View');
+ $suite->addTestFiles($files);
+
+ return $suite;
+ }
+}
@@ -18,7 +18,12 @@
* @since DebugKit 0.1
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
-App::import('Component', 'DebugKit.Toolbar');
+App::uses('Router', 'Routing');
+App::uses('Controller', 'Controller');
+App::uses('AppController', 'Controller');
+App::uses('Component', 'Controller');
+App::uses('Model', 'Model');
+App::uses('ToolbarComponent', 'DebugKit.Controller/Component');
class TestToolbarComponent extends ToolbarComponent {
public $evalTest = false;
@@ -37,17 +42,11 @@ protected function _eval($code) {
}
}
-if (!class_exists('AppController')) {
- class AppController extends Controller {
-
- }
-}
-
/**
-* DebugToolbar Test case
+* DebugKitToolbarComponentTestCase Test case
*/
-class DebugToolbarTestCase extends CakeTestCase {
+class DebugKitToolbarComponentTestCase extends CakeTestCase {
/**
* fixtures.
@@ -155,10 +154,10 @@ public function testLoadPluginPanels() {
$debugKitPath = App::pluginPath('DebugKit');
$noDir = (empty($debugKitPath) || !file_exists($debugKitPath));
if ($noDir) {
- $this->markTestAsSkipped('Could not find debug_kit in plugin paths');
+ $this->markTestAsSkipped('Could not find DebugKit in plugin paths');
}
- App::build(array('plugins' => array($debugKitPath . 'tests' . DS . 'test_app' . DS . 'plugins' . DS)));
+ App::build(array('plugins' => array($debugKitPath . 'Test' . DS . 'test_app' . DS . 'Plugin' . DS)));
$this->_loadController();
$this->Controller->Toolbar->loadPanels(array('DebugkitTestPlugin.PluginTest'));
@@ -173,7 +172,7 @@ public function testLoadPluginPanels() {
public function testPluginViewParsing() {
$this->_loadController();
- App::import('Vendor', 'DebugKit.DebugKitDebugger');
+ App::uses('DebugKitDebugger', 'DebugKit.vendors');
$this->Controller->Toolbar->evalTest = true;
$this->Controller->viewClass = 'Plugin.OtherView';
$this->Controller->Toolbar->startup($this->Controller);
@@ -190,11 +189,11 @@ public function testVendorPanels() {
$debugKitPath = App::pluginPath('DebugKit');
$noDir = (empty($debugKitPath) || !file_exists($debugKitPath));
if ($noDir) {
- $this->markTestAsSkipped('Could not find debug_kit in plugin paths');
+ $this->markTestAsSkipped('Could not find DebugKit in plugin paths');
}
App::build(array(
- 'vendors' => array($debugKitPath . 'tests' . DS . 'test_app' . DS . 'vendors' . DS)
+ 'vendors' => array($debugKitPath . 'Test' . DS . 'test_app' . DS . 'Vendor' . DS)
));
$this->_loadController(array(
'panels' => array('test'),
@@ -568,14 +567,14 @@ public function testNoRequestActionInterference() {
$debugKitPath = App::pluginPath('DebugKit');
$noDir = (empty($debugKitPath) || !file_exists($debugKitPath));
if ($noDir) {
- $this->markTestAsSkipped('Could not find debug_kit in plugin paths');
+ $this->markTestAsSkipped('Could not find DebugKit in plugin paths');
}
App::build(array(
- 'controllers' => $debugKitPath . 'tests' . DS . 'test_app' . DS . 'controllers' . DS,
- 'views' => array(
- $debugKitPath . 'tests' . DS . 'test_app' . DS . 'views' . DS,
- CAKE_CORE_INCLUDE_PATH . DS . 'cake' . DS . 'libs' . DS . 'view' . DS
+ 'Controller' => $debugKitPath . 'Test' . DS . 'test_app' . DS . 'Controller' . DS,
+ 'View' => array(
+ $debugKitPath . 'Test' . DS . 'test_app' . DS . 'View' . DS,
+ CAKE_CORE_INCLUDE_PATH . DS . 'Cake' . DS . 'View' . DS
),
'plugins' => $this->_paths['plugins']
));
@@ -595,7 +594,6 @@ public function testNoRequestActionInterference() {
* @return void
**/
public function testSqlLogPanel() {
- App::import('Core', 'Model');
$Article = ClassRegistry::init('Article');
$Article->find('first', array('conditions' => array('Article.id' => 1)));
Oops, something went wrong.

0 comments on commit 7fce568

Please sign in to comment.