Skip to content
Permalink
Browse files

Fix remaining failing tests.

Add an alternate signature for Request::__construct()
Using a string in the constructor lets you set the url.
  • Loading branch information...
markstory committed Jun 4, 2012
1 parent 646120a commit 2eb2b1eb6a5bdc103b9933dd0335f017905fac29
Showing with 16 additions and 30 deletions.
  1. +3 −1 lib/Cake/Network/Request.php
  2. +13 −29 lib/Cake/Test/TestCase/Routing/DispatcherTest.php
@@ -159,7 +159,9 @@ public static function createFromGlobals() {
* @param array $config An array of request data to create a request with.
*/
public function __construct($config = array()) {
$config = (array)$config;
if (is_string($config)) {
$config = array('url' => $config);
}
$config += array(
'params' => $this->params,
'query' => array(),
@@ -314,21 +314,6 @@ public function testParseParamsWithoutZerosAndEmptyPost() {
$this->assertFalse(!empty($request['form']));
}
/**
* testParseParamsReturnsPostedData method
*
* @return void
*/
public function testParseParamsReturnsPostedData() {
$_POST['testdata'] = "My Posted Content";
$Dispatcher = new Dispatcher();
$request = new Request("/");
$event = new Event(__CLASS__, $Dispatcher, array('request' => $request));
$Dispatcher->parseParams($event);
$test = $Dispatcher->parseParams($event);
$this->assertEquals("My Posted Content", $request['data']['testdata']);
}
/**
* testQueryStringOnRoot method
*
@@ -494,7 +479,6 @@ public function testDispatchActionReturnsResponse() {
public function testAdminDispatch() {
$Dispatcher = new TestDispatcher();
Configure::write('Routing.prefixes', array('admin'));
Configure::write('App.baseUrl','/cake/repo/branches/1.2.x.x/index.php');
$url = new Request('admin/test_dispatch_pages/index/param:value/param2:value2');
$response = $this->getMock('Cake\Network\Response');
@@ -507,11 +491,8 @@ public function testAdminDispatch() {
$this->assertTrue($Dispatcher->controller->params['admin']);
$expected = '/cake/repo/branches/1.2.x.x/index.php/admin/test_dispatch_pages/index/param:value/param2:value2';
$expected = '/admin/test_dispatch_pages/index/param:value/param2:value2';
$this->assertSame($expected, $Dispatcher->controller->here);
$expected = '/cake/repo/branches/1.2.x.x/index.php';
$this->assertSame($expected, $Dispatcher->controller->base);
}
/**
@@ -1038,9 +1019,10 @@ public function testHttpMethodOverrides() {
$this->assertEquals($value, $request[$key], 'Value mismatch for ' . $key . ' %s');
}
$_POST['_method'] = 'PUT';
$request = new Request('/posts/5');
$request = new Request(array(
'url' => '/posts/5',
'post' => array('_method' => 'PUT')
));
$event = new Event(__CLASS__, $dispatcher, array('request' => $request));
$dispatcher->parseParams($event);
$expected = array(
@@ -1055,12 +1037,16 @@ public function testHttpMethodOverrides() {
$this->assertEquals($value, $request[$key], 'Value mismatch for ' . $key . ' %s');
}
$_POST['_method'] = 'POST';
$_POST['data'] = array('Post' => array('title' => 'New Post'));
$_POST['extra'] = 'data';
$_SERVER = array();
$request = new Request('/posts');
$request = new Request(array(
'url' => '/posts',
'post' => array(
'_method' => 'POST',
'Post' => array('title' => 'New Post'),
'extra' => 'data'
),
));
$event = new Event(__CLASS__, $dispatcher, array('request' => $request));
$dispatcher->parseParams($event);
$expected = array(
@@ -1074,8 +1060,6 @@ public function testHttpMethodOverrides() {
foreach ($expected as $key => $value) {
$this->assertEquals($value, $request[$key], 'Value mismatch for ' . $key . ' %s');
}
unset($_POST['_method']);
}
/**

0 comments on commit 2eb2b1e

Please sign in to comment.
You can’t perform that action at this time.