Skip to content

Commit

Permalink
Fixing tests and removing one that made no sense
Browse files Browse the repository at this point in the history
  • Loading branch information
lorenzo committed Jun 9, 2014
1 parent 697dfce commit 3a66afa
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 29 deletions.
2 changes: 1 addition & 1 deletion src/Controller/Controller.php
Expand Up @@ -325,7 +325,7 @@ public function __get($name) {
*/
public function setRequest(Request $request) {
$this->request = $request;
$this->plugin = isset($request->params['plugin']) ? Inflector::camelize($request->params['plugin']) : null;
$this->plugin = isset($request->params['plugin']) ? $request->params['plugin'] : null;
$this->view = isset($request->params['action']) ? $request->params['action'] : null;

if (isset($request->params['pass'])) {
Expand Down
4 changes: 2 additions & 2 deletions src/TestSuite/ControllerTestCase.php
Expand Up @@ -286,9 +286,9 @@ protected function _testAction($url = '', $options = array()) {
if ($this->controller === null && $this->autoMock) {
$plugin = '';
if (!empty($request->params['plugin'])) {
$plugin = Inflector::camelize($request->params['plugin']) . '.';
$plugin = $request->params['plugin'] . '.';
}
$controllerName = Inflector::camelize($request->params['controller']);
$controllerName = $request->params['controller'];
if (!empty($request->params['prefix'])) {
$controllerName = Inflector::camelize($request->params['prefix']) . '/' . $controllerName;
}
Expand Down
2 changes: 1 addition & 1 deletion src/View/Helper.php
Expand Up @@ -319,7 +319,7 @@ public function assetTimestamp($path) {
//@codingStandardsIgnoreEnd
}
$segments = explode('/', ltrim($filepath, '/'));
$plugin = Inflector::camelize($segments[0]);
$plugin = $segments[0];
if (Plugin::loaded($plugin)) {
unset($segments[0]);
$pluginPath = Plugin::path($plugin) . 'webroot' . DS . implode(DS, $segments);
Expand Down
1 change: 0 additions & 1 deletion src/View/Helper/HtmlHelper.php
Expand Up @@ -18,7 +18,6 @@
use Cake\Core\Configure;
use Cake\Error;
use Cake\Network\Response;
use Cake\Utility\Inflector;
use Cake\View\Helper;
use Cake\View\Helper\StringTemplateTrait;
use Cake\View\View;
Expand Down
25 changes: 1 addition & 24 deletions tests/TestCase/TestSuite/ControllerTestCaseTest.php
Expand Up @@ -52,6 +52,7 @@ public function setUp() {
DispatcherFactory::add('Routing');
DispatcherFactory::add('ControllerFactory');
Router::reload();
require CAKE . 'Config/routes.php';
TableRegistry::clear();
}

Expand Down Expand Up @@ -227,37 +228,13 @@ public function testTestActionWithPlugin() {
$this->assertEquals('It is a variable', $this->Case->controller->viewVars['test_value']);
}

/**
* Tests using loaded routes during tests
*
* @return void
*/
public function testUseRoutes() {
Router::connect('/:controller/:action/*');
include APP . '/Config/routes.php';

$controller = $this->Case->generate('TestsApps');
$controller->components()->load('RequestHandler');
$result = $this->Case->testAction('/tests_apps/index.json', array('return' => 'contents'));
$result = json_decode($result, true);
$expected = array('cakephp' => 'cool');
$this->assertEquals($expected, $result);

include APP . '/Config/routes.php';
$result = $this->Case->testAction('/some_alias');
$this->assertEquals(5, $result);
}

/**
* Tests not using loaded routes during tests
*
* @expectedException \Cake\Controller\Error\MissingActionException
* @return void
*/
public function testSkipRoutes() {
Router::connect('/:controller/:action/*');
include APP . 'Config/routes.php';

$this->Case->loadRoutes = false;
$this->Case->testAction('/tests_apps/missing_action.json', array('return' => 'view'));
}
Expand Down

0 comments on commit 3a66afa

Please sign in to comment.