Removing $request->query[url]. This simulated value is also available at $request->url, and having it in the query array confuses things, as GET[url] no longer exists.

Fixing failing tests elsewhere in the framework.
This commit is contained in:
mark_story 2011-02-20 21:52:20 -05:00
parent 2190596764
commit d1821b3f9d
11 changed files with 37 additions and 59 deletions

View file

@ -167,15 +167,15 @@ class CakeRequest implements ArrayAccess {
} else { } else {
$query = $_GET; $query = $_GET;
} }
if (strpos($this->url, '?') !== false) { if (strpos($this->url, '?') !== false) {
list(, $querystr) = explode('?', $this->url); list(, $querystr) = explode('?', $this->url);
parse_str($querystr, $queryArgs); parse_str($querystr, $queryArgs);
$query += $queryArgs; $query += $queryArgs;
} }
if (isset($this->params['url'])) { if (isset($this->params['url'])) {
$query = array_merge($this->params['url'], $query); $query = array_merge($this->params['url'], $query);
} }
$query['url'] = $this->url;
$this->query = $query; $this->query = $query;
} }

View file

@ -289,8 +289,8 @@ class AuthComponent extends Component {
$url = ''; $url = '';
if (isset($request->query['url'])) { if (isset($request->url)) {
$url = $request->query['url']; $url = $request->url;
} }
$url = Router::normalize($url); $url = Router::normalize($url);
$loginAction = Router::normalize($this->loginAction); $loginAction = Router::normalize($this->loginAction);

View file

@ -66,20 +66,19 @@ class ApiShellTest extends CakeTestCase {
'8. getResponse()', '8. getResponse()',
'9. header($status)', '9. header($status)',
'10. httpCodes($code = NULL)', '10. httpCodes($code = NULL)',
'11. isAuthorized()', '11. loadModel($modelClass = NULL, $id = NULL)',
'12. loadModel($modelClass = NULL, $id = NULL)', '12. paginate($object = NULL, $scope = array (), $whitelist = array ())',
'13. paginate($object = NULL, $scope = array (), $whitelist = array ())', '13. postConditions($data = array (), $op = NULL, $bool = \'AND\', $exclusive = false)',
'14. postConditions($data = array (), $op = NULL, $bool = \'AND\', $exclusive = false)', '14. redirect($url, $status = NULL, $exit = true)',
'15. redirect($url, $status = NULL, $exit = true)', '15. referer($default = NULL, $local = false)',
'16. referer($default = NULL, $local = false)', '16. render($view = NULL, $layout = NULL)',
'17. render($action = NULL, $layout = NULL, $file = NULL)', '17. set($one, $two = NULL)',
'18. set($one, $two = NULL)', '18. setAction($action)',
'19. setAction($action)', '19. setRequest($request)',
'20. setRequest($request)', '20. shutdownProcess()',
'21. shutdownProcess()', '21. startupProcess()',
'22. startupProcess()', '22. validate()',
'23. validate()', '23. validateErrors()'
'24. validateErrors()'
); );
$this->Shell->expects($this->at(2))->method('out')->with($expected); $this->Shell->expects($this->at(2))->method('out')->with($expected);

View file

@ -74,12 +74,11 @@ class CakeRequestTestCase extends CakeTestCase {
'two' => 'banana' 'two' => 'banana'
); );
$request = new CakeRequest('some/path'); $request = new CakeRequest('some/path');
$this->assertEqual($request->query, $_GET + array('url' => 'some/path')); $this->assertEqual($request->query, $_GET);
$_GET = array( $_GET = array(
'one' => 'param', 'one' => 'param',
'two' => 'banana', 'two' => 'banana',
'url' => 'some/path'
); );
$request = new CakeRequest('some/path'); $request = new CakeRequest('some/path');
$this->assertEqual($request->query, $_GET); $this->assertEqual($request->query, $_GET);
@ -94,8 +93,10 @@ class CakeRequestTestCase extends CakeTestCase {
function testQueryStringParsingFromInputUrl() { function testQueryStringParsingFromInputUrl() {
$_GET = array(); $_GET = array();
$request = new CakeRequest('some/path?one=something&two=else'); $request = new CakeRequest('some/path?one=something&two=else');
$expected = array('one' => 'something', 'two' => 'else', 'url' => 'some/path?one=something&two=else'); $expected = array('one' => 'something', 'two' => 'else');
$this->assertEqual($request->query, $expected); $this->assertEqual($request->query, $expected);
$this->assertEquals('some/path?one=something&two=else', $request->url);
} }
/** /**

View file

@ -443,7 +443,7 @@ class AuthTest extends CakeTestCase {
$this->Controller->data = array(); $this->Controller->data = array();
$this->Controller->request->addParams(Router::parse('auth_test/login')); $this->Controller->request->addParams(Router::parse('auth_test/login'));
$this->Controller->request->query['url'] = 'auth_test/login'; $this->Controller->request->url = 'auth_test/login';
$this->Auth->Session->delete('Auth'); $this->Auth->Session->delete('Auth');
$this->Auth->loginRedirect = '/users/dashboard'; $this->Auth->loginRedirect = '/users/dashboard';
@ -730,7 +730,7 @@ class AuthTest extends CakeTestCase {
)); ));
$this->Auth->request->addParams(Router::parse('users/login')); $this->Auth->request->addParams(Router::parse('users/login'));
$this->Auth->request->query['url'] = 'users/login'; $this->Auth->request->url = 'users/login';
$this->Auth->initialize($this->Controller); $this->Auth->initialize($this->Controller);
$this->Auth->loginRedirect = array( $this->Auth->loginRedirect = array(
@ -771,7 +771,7 @@ class AuthTest extends CakeTestCase {
'AuthUser' => array('id'=>'1', 'username' => 'nate') 'AuthUser' => array('id'=>'1', 'username' => 'nate')
)); ));
$this->Auth->request->params['action'] = 'login'; $this->Auth->request->params['action'] = 'login';
$this->Auth->request->query['url'] = 'auth_test/login'; $this->Auth->request->url = 'auth_test/login';
$this->Auth->initialize($this->Controller); $this->Auth->initialize($this->Controller);
$this->Auth->loginAction = 'auth_test/login'; $this->Auth->loginAction = 'auth_test/login';
$this->Auth->loginRedirect = false; $this->Auth->loginRedirect = false;
@ -784,7 +784,7 @@ class AuthTest extends CakeTestCase {
$this->Auth->Session->delete('Auth'); $this->Auth->Session->delete('Auth');
$url = '/posts/index/year:2008/month:feb'; $url = '/posts/index/year:2008/month:feb';
$this->Auth->request->addParams(Router::parse($url)); $this->Auth->request->addParams(Router::parse($url));
$this->Auth->request->query['url'] = Router::normalize($url); $this->Auth->request->url = Router::normalize($url);
$this->Auth->initialize($this->Controller); $this->Auth->initialize($this->Controller);
$this->Auth->loginAction = array('controller' => 'AuthTest', 'action' => 'login'); $this->Auth->loginAction = array('controller' => 'AuthTest', 'action' => 'login');
$this->Auth->startup($this->Controller); $this->Auth->startup($this->Controller);
@ -795,7 +795,7 @@ class AuthTest extends CakeTestCase {
$this->Auth->Session->delete('Auth'); $this->Auth->Session->delete('Auth');
$url = '/posts/view/1'; $url = '/posts/view/1';
$this->Auth->request->addParams(Router::parse($url)); $this->Auth->request->addParams(Router::parse($url));
$this->Auth->request->query['url'] = Router::normalize($url); $this->Auth->request->url = Router::normalize($url);
$this->Auth->initialize($this->Controller); $this->Auth->initialize($this->Controller);
$this->Auth->loginAction = array('controller' => 'AuthTest', 'action' => 'login'); $this->Auth->loginAction = array('controller' => 'AuthTest', 'action' => 'login');
$this->Auth->startup($this->Controller); $this->Auth->startup($this->Controller);
@ -843,7 +843,7 @@ class AuthTest extends CakeTestCase {
$url = '/posts/edit/1'; $url = '/posts/edit/1';
$this->Auth->request = $this->Controller->request = new CakeRequest($url); $this->Auth->request = $this->Controller->request = new CakeRequest($url);
$this->Auth->request->addParams(Router::parse($url)); $this->Auth->request->addParams(Router::parse($url));
$this->Auth->request->query = array('url' => Router::normalize($url)); $this->Auth->request->url = Router::normalize($url);
$this->Auth->initialize($this->Controller); $this->Auth->initialize($this->Controller);
$this->Auth->loginAction = array('controller' => 'AuthTest', 'action' => 'login'); $this->Auth->loginAction = array('controller' => 'AuthTest', 'action' => 'login');
$this->Auth->startup($this->Controller); $this->Auth->startup($this->Controller);
@ -856,7 +856,7 @@ class AuthTest extends CakeTestCase {
$url = '/AuthTest/login'; $url = '/AuthTest/login';
$this->Auth->request = $this->Controller->request = new CakeRequest($url); $this->Auth->request = $this->Controller->request = new CakeRequest($url);
$this->Auth->request->addParams(Router::parse($url)); $this->Auth->request->addParams(Router::parse($url));
$this->Auth->request->query['url'] = Router::normalize($url); $this->Auth->request->url = Router::normalize($url);
$this->Auth->initialize($this->Controller); $this->Auth->initialize($this->Controller);
$this->Auth->loginAction = array('controller' => 'AuthTest', 'action' => 'login'); $this->Auth->loginAction = array('controller' => 'AuthTest', 'action' => 'login');
$this->Auth->startup($this->Controller); $this->Auth->startup($this->Controller);
@ -965,11 +965,11 @@ class AuthTest extends CakeTestCase {
$url = '/admin/auth_test/login'; $url = '/admin/auth_test/login';
$this->Auth->request->addParams(Router::parse($url)); $this->Auth->request->addParams(Router::parse($url));
$this->Auth->request->query['url'] = ltrim($url, '/'); $this->Auth->request->url = ltrim($url, '/');
Router::setRequestInfo(array( Router::setRequestInfo(array(
array( array(
'pass' => array(), 'action' => 'admin_login', 'plugin' => null, 'controller' => 'auth_test', 'pass' => array(), 'action' => 'admin_login', 'plugin' => null, 'controller' => 'auth_test',
'admin' => true, 'url' => array('url' => $this->Auth->request->query['url']), 'admin' => true,
), ),
array( array(
'base' => null, 'here' => $url, 'base' => null, 'here' => $url,

View file

@ -27,6 +27,8 @@ class CrudAuthorizeTest extends CakeTestCase {
* @return void * @return void
*/ */
function setUp() { function setUp() {
Configure::write('Routing.prefixes', array());
parent::setUp(); parent::setUp();
$this->controller = $this->getMock('Controller', array(), array(), '', false); $this->controller = $this->getMock('Controller', array(), array(), '', false);
$this->Acl = $this->getMock('AclComponent', array(), array(), '', false); $this->Acl = $this->getMock('AclComponent', array(), array(), '', false);

View file

@ -1020,20 +1020,6 @@ class ControllerTest extends CakeTestCase {
$this->assertidentical($TestController->data, $expected); $this->assertidentical($TestController->data, $expected);
} }
/**
* testUnimplementedIsAuthorized method
*
* @expectedException PHPUnit_Framework_Error
* @access public
* @return void
*/
function testUnimplementedIsAuthorized() {
$request = new CakeRequest('controller_posts/index');
$TestController = new TestController($request);
$TestController->isAuthorized();
}
/** /**
* testValidateErrors method * testValidateErrors method
* *

View file

@ -771,11 +771,11 @@ class ScaffoldTest extends CakeTestCase {
function testScaffoldChangingViewProperty() { function testScaffoldChangingViewProperty() {
$this->Controller->action = 'edit'; $this->Controller->action = 'edit';
$this->Controller->theme = 'test_theme'; $this->Controller->theme = 'test_theme';
$this->Controller->view = 'Theme'; $this->Controller->viewClass = 'Theme';
$this->Controller->constructClasses(); $this->Controller->constructClasses();
$Scaffold = new TestScaffoldMock($this->Controller, $this->Controller->request); $Scaffold = new TestScaffoldMock($this->Controller, $this->Controller->request);
$this->assertEqual($this->Controller->view, 'Scaffold'); $this->assertEqual($this->Controller->viewClass, 'Scaffold');
} }
/** /**

View file

@ -388,7 +388,6 @@ class ControllerTestCaseTest extends CakeTestCase {
'return' => 'vars', 'return' => 'vars',
'method' => 'get', 'method' => 'get',
)); ));
$this->assertTrue(isset($result['params']['url']['url']));
$this->assertEqual(array_keys($result['params']['named']), array('var1', 'var2')); $this->assertEqual(array_keys($result['params']['named']), array('var1', 'var2'));
$result = $this->Case->testAction('/tests_apps_posts/url_var/gogo/val2', array( $result = $this->Case->testAction('/tests_apps_posts/url_var/gogo/val2', array(
@ -407,7 +406,6 @@ class ControllerTestCaseTest extends CakeTestCase {
)); ));
$this->assertTrue(isset($result['params']['url']['red'])); $this->assertTrue(isset($result['params']['url']['red']));
$this->assertTrue(isset($result['params']['url']['blue'])); $this->assertTrue(isset($result['params']['url']['blue']));
$this->assertTrue(isset($result['params']['url']['url']));
} }
/** /**

View file

@ -227,6 +227,7 @@ class DebuggerTest extends CakeTestCase {
View::$helpers = array View::$helpers = array
View::$viewPath = "" View::$viewPath = ""
View::$viewVars = array View::$viewVars = array
View::$view = NULL
View::$layout = "default" View::$layout = "default"
View::$layoutPath = NULL View::$layoutPath = NULL
View::$autoLayout = true View::$autoLayout = true

View file

@ -862,7 +862,6 @@ class DispatcherTest extends CakeTestCase {
*/ */
public function testPluginDispatch() { public function testPluginDispatch() {
$_POST = array(); $_POST = array();
$_SERVER['PHP_SELF'] = '/cake/repo/branches/1.2.x.x/index.php';
Router::reload(); Router::reload();
$Dispatcher = new TestDispatcher(); $Dispatcher = new TestDispatcher();
@ -879,7 +878,6 @@ class DispatcherTest extends CakeTestCase {
'pass' => array('home'), 'pass' => array('home'),
'named' => array('param'=> 'value', 'param2'=> 'value2'), 'plugin'=> 'my_plugin', 'named' => array('param'=> 'value', 'param2'=> 'value2'), 'plugin'=> 'my_plugin',
'controller'=> 'some_pages', 'action'=> 'display', 'form'=> array(), 'controller'=> 'some_pages', 'action'=> 'display', 'form'=> array(),
'url'=> array('url'=> 'my_plugin/some_pages/home/param:value/param2:value2'),
); );
foreach ($expected as $key => $value) { foreach ($expected as $key => $value) {
$this->assertEqual($result[$key], $value, 'Value mismatch ' . $key . ' %'); $this->assertEqual($result[$key], $value, 'Value mismatch ' . $key . ' %');
@ -889,12 +887,6 @@ class DispatcherTest extends CakeTestCase {
$this->assertIdentical($controller->name, 'SomePages'); $this->assertIdentical($controller->name, 'SomePages');
$this->assertIdentical($controller->params['controller'], 'some_pages'); $this->assertIdentical($controller->params['controller'], 'some_pages');
$this->assertIdentical($controller->passedArgs, array('0' => 'home', 'param'=>'value', 'param2'=>'value2')); $this->assertIdentical($controller->passedArgs, array('0' => 'home', 'param'=>'value', 'param2'=>'value2'));
$expected = '/cake/repo/branches/1.2.x.x/my_plugin/some_pages/home/param:value/param2:value2';
$this->assertIdentical($expected, $controller->here);
$expected = '/cake/repo/branches/1.2.x.x';
$this->assertIdentical($expected, $controller->base);
} }
/** /**
@ -904,7 +896,7 @@ class DispatcherTest extends CakeTestCase {
*/ */
public function testAutomaticPluginDispatch() { public function testAutomaticPluginDispatch() {
$_POST = array(); $_POST = array();
$_SERVER['PHP_SELF'] = '/cake/repo/branches/1.2.x.x/index.php'; $_SERVER['SCRIPT_NAME'] = '/cake/repo/branches/1.2.x.x/index.php';
Router::reload(); Router::reload();
$Dispatcher = new TestDispatcher(); $Dispatcher = new TestDispatcher();
@ -1018,11 +1010,10 @@ class DispatcherTest extends CakeTestCase {
'prefix' => 'admin', 'prefix' => 'admin',
'admin' => true, 'admin' => true,
'form' => array(), 'form' => array(),
'url' => array('url' => 'admin/articles_test'),
'return' => 1 'return' => 1
); );
foreach ($expected as $key => $value) { foreach ($expected as $key => $value) {
$this->assertEqual($controller->params[$key], $expected[$key], 'Value mismatch ' . $key . ' %s'); $this->assertEqual($controller->request[$key], $expected[$key], 'Value mismatch ' . $key . ' %s');
} }
} }