Skip to content
Permalink
Browse files

Fix tests broken by the previous commit.

  • Loading branch information...
markstory committed Oct 3, 2012
1 parent 72bf1ca commit 883cc834777b3b9f1b874deaf9bed46df72e0c2f
@@ -140,7 +140,6 @@ public function initialize(Controller $controller) {
if (empty($this->ext) || $this->ext == 'html') {
$this->_setExtension();
}
$this->params = $controller->params;
if (!empty($this->settings['viewClassMap'])) {
$this->viewClassMap($this->settings['viewClassMap']);
}
@@ -113,27 +113,27 @@ public function testPaginate() {
$Controller->request->query = array('page' => '-1');
$results = Hash::extract($Controller->Paginator->paginate('PaginatorControllerPost'), '{n}.PaginatorControllerPost.id');
$this->assertEquals(1, $Controller->params['paging']['PaginatorControllerPost']['page']);
$this->assertEquals(1, $Controller->request->params['paging']['PaginatorControllerPost']['page']);
$this->assertEquals(array(1, 2, 3), $results);
$Controller->request->query = array('sort' => 'PaginatorControllerPost.id', 'direction' => 'asc');
$results = Hash::extract($Controller->Paginator->paginate('PaginatorControllerPost'), '{n}.PaginatorControllerPost.id');
$this->assertEquals(1, $Controller->params['paging']['PaginatorControllerPost']['page']);
$this->assertEquals(1, $Controller->request->params['paging']['PaginatorControllerPost']['page']);
$this->assertEquals(array(1, 2, 3), $results);
$Controller->request->query = array('sort' => 'PaginatorControllerPost.id', 'direction' => 'desc');
$results = Hash::extract($Controller->Paginator->paginate('PaginatorControllerPost'), '{n}.PaginatorControllerPost.id');
$this->assertEquals(1, $Controller->params['paging']['PaginatorControllerPost']['page']);
$this->assertEquals(1, $Controller->request->params['paging']['PaginatorControllerPost']['page']);
$this->assertEquals(array(3, 2, 1), $results);
$Controller->request->query = array('sort' => 'id', 'direction' => 'desc');
$results = Hash::extract($Controller->Paginator->paginate('PaginatorControllerPost'), '{n}.PaginatorControllerPost.id');
$this->assertEquals(1, $Controller->params['paging']['PaginatorControllerPost']['page']);
$this->assertEquals(1, $Controller->request->params['paging']['PaginatorControllerPost']['page']);
$this->assertEquals(array(3, 2, 1), $results);
$Controller->request->query = array('sort' => 'NotExisting.field', 'direction' => 'desc');
$results = Hash::extract($Controller->Paginator->paginate('PaginatorControllerPost'), '{n}.PaginatorControllerPost.id');
$this->assertEquals(1, $Controller->params['paging']['PaginatorControllerPost']['page'], 'Invalid field in query %s');
$this->assertEquals(1, $Controller->request->params['paging']['PaginatorControllerPost']['page'], 'Invalid field in query %s');
$this->assertEquals(array(1, 2, 3), $results);
$Controller->request->query = array(
@@ -146,33 +146,33 @@ public function testPaginate() {
$Controller->request->query = array();
$Controller->Paginator->settings = array('limit' => 0, 'maxLimit' => 10);
$Controller->Paginator->paginate('PaginatorControllerPost');
$this->assertSame(1, $Controller->params['paging']['PaginatorControllerPost']['page']);
$this->assertSame($Controller->params['paging']['PaginatorControllerPost']['pageCount'], 3);
$this->assertSame($Controller->params['paging']['PaginatorControllerPost']['prevPage'], false);
$this->assertSame($Controller->params['paging']['PaginatorControllerPost']['nextPage'], true);
$this->assertSame(1, $Controller->request->params['paging']['PaginatorControllerPost']['page']);
$this->assertSame($Controller->request->params['paging']['PaginatorControllerPost']['pageCount'], 3);
$this->assertSame($Controller->request->params['paging']['PaginatorControllerPost']['prevPage'], false);
$this->assertSame($Controller->request->params['paging']['PaginatorControllerPost']['nextPage'], true);
$Controller->request->query = array();
$Controller->Paginator->settings = array('limit' => 'garbage!', 'maxLimit' => 10);
$Controller->Paginator->paginate('PaginatorControllerPost');
$this->assertSame(1, $Controller->params['paging']['PaginatorControllerPost']['page']);
$this->assertSame($Controller->params['paging']['PaginatorControllerPost']['pageCount'], 3);
$this->assertSame($Controller->params['paging']['PaginatorControllerPost']['prevPage'], false);
$this->assertSame($Controller->params['paging']['PaginatorControllerPost']['nextPage'], true);
$this->assertSame(1, $Controller->request->params['paging']['PaginatorControllerPost']['page']);
$this->assertSame($Controller->request->params['paging']['PaginatorControllerPost']['pageCount'], 3);
$this->assertSame($Controller->request->params['paging']['PaginatorControllerPost']['prevPage'], false);
$this->assertSame($Controller->request->params['paging']['PaginatorControllerPost']['nextPage'], true);
$Controller->request->query = array();
$Controller->Paginator->settings = array('limit' => '-1', 'maxLimit' => 10);
$Controller->Paginator->paginate('PaginatorControllerPost');
$this->assertSame($Controller->params['paging']['PaginatorControllerPost']['limit'], 1);
$this->assertSame(1, $Controller->params['paging']['PaginatorControllerPost']['page']);
$this->assertSame($Controller->params['paging']['PaginatorControllerPost']['pageCount'], 3);
$this->assertSame($Controller->params['paging']['PaginatorControllerPost']['prevPage'], false);
$this->assertSame($Controller->params['paging']['PaginatorControllerPost']['nextPage'], true);
$this->assertSame($Controller->request->params['paging']['PaginatorControllerPost']['limit'], 1);
$this->assertSame(1, $Controller->request->params['paging']['PaginatorControllerPost']['page']);
$this->assertSame($Controller->request->params['paging']['PaginatorControllerPost']['pageCount'], 3);
$this->assertSame($Controller->request->params['paging']['PaginatorControllerPost']['prevPage'], false);
$this->assertSame($Controller->request->params['paging']['PaginatorControllerPost']['nextPage'], true);
$Controller->Paginator->settings = array('conditions' => array('PaginatorAuthor.user' => 'mariano'));
$Controller->Paginator->paginate('PaginatorControllerPost');
$this->assertSame(2, $Controller->params['paging']['PaginatorControllerPost']['count']);
$this->assertSame(2, $Controller->request->params['paging']['PaginatorControllerPost']['count']);
}
/**
@@ -215,12 +215,12 @@ public function testPaginateExtraParams() {
$Controller->uses = array('PaginatorControllerPost', 'PaginatorControllerComment');
$Controller->request->params['pass'] = array('1');
$Controller->params['url'] = array();
$Controller->request->query = array();
$Controller->constructClasses();
$Controller->request->query = array('page' => '-1', 'contain' => array('PaginatorControllerComment'));
$result = $Controller->Paginator->paginate('PaginatorControllerPost');
$this->assertEquals(1, $Controller->params['paging']['PaginatorControllerPost']['page']);
$this->assertEquals(1, $Controller->request->params['paging']['PaginatorControllerPost']['page']);
$this->assertEquals(array(1, 2, 3), Hash::extract($result, '{n}.PaginatorControllerPost.id'));
$this->assertTrue(!isset($Controller->PaginatorControllerPost->lastQueries[1]['contain']));
@@ -232,7 +232,7 @@ public function testPaginateExtraParams() {
),
);
$result = $Controller->Paginator->paginate('PaginatorControllerPost');
$this->assertEquals(1, $Controller->params['paging']['PaginatorControllerPost']['page']);
$this->assertEquals(1, $Controller->request->params['paging']['PaginatorControllerPost']['page']);
$this->assertEquals(array(1, 2, 3), Hash::extract($result, '{n}.PaginatorControllerPost.id'));
$this->assertTrue(isset($Controller->PaginatorControllerPost->lastQueries[1]['contain']));
@@ -248,7 +248,7 @@ public function testPaginateExtraParams() {
$Controller->request->query = array('limit' => 12);
$Controller->Paginator->settings = array('limit' => 30, 'maxLimit' => 100);
$result = $Controller->Paginator->paginate('PaginatorControllerPost');
$paging = $Controller->params['paging']['PaginatorControllerPost'];
$paging = $Controller->request->params['paging']['PaginatorControllerPost'];
$this->assertEquals(12, $Controller->PaginatorControllerPost->lastQueries[1]['limit']);
$this->assertEquals(12, $paging['options']['limit']);
@@ -300,7 +300,7 @@ public function testPaginateSpecialType() {
$Controller = new PaginatorTestController($this->request);
$Controller->uses = array('PaginatorControllerPost', 'PaginatorControllerComment');
$Controller->passedArgs[] = '1';
$Controller->params['url'] = array();
$Controller->request->query = [];
$Controller->constructClasses();
$Controller->Paginator->settings = array(
@@ -317,7 +317,7 @@ public function testPaginateSpecialType() {
$Controller->PaginatorControllerPost->lastQueries[1]['conditions'],
array('PaginatorControllerPost.id > ' => '1')
);
$this->assertFalse(isset($Controller->params['paging']['PaginatorControllerPost']['options'][0]));
$this->assertFalse(isset($Controller->request->params['paging']['PaginatorControllerPost']['options'][0]));
}
/**
@@ -328,14 +328,14 @@ public function testPaginateSpecialType() {
public function testDefaultPaginateParams() {
$Controller = new PaginatorTestController($this->request);
$Controller->modelClass = 'PaginatorControllerPost';
$Controller->params['url'] = array();
$Controller->request->query = [];
$Controller->constructClasses();
$Controller->Paginator->settings = array(
'order' => 'PaginatorControllerPost.id DESC',
'maxLimit' => 10,
);
$results = Hash::extract($Controller->Paginator->paginate('PaginatorControllerPost'), '{n}.PaginatorControllerPost.id');
$this->assertEquals('PaginatorControllerPost.id DESC', $Controller->params['paging']['PaginatorControllerPost']['order']);
$this->assertEquals('PaginatorControllerPost.id DESC', $Controller->request->params['paging']['PaginatorControllerPost']['order']);
$this->assertEquals(array(3, 2, 1), $results);
}
@@ -347,7 +347,7 @@ public function testDefaultPaginateParams() {
public function testPaginateOrderVirtualField() {
$Controller = new PaginatorTestController($this->request);
$Controller->uses = array('PaginatorControllerPost', 'PaginatorControllerComment');
$Controller->params['url'] = array();
$Controller->request->query = [];
$Controller->constructClasses();
$Controller->PaginatorControllerPost->virtualFields = array(
'offset_test' => 'PaginatorControllerPost.id + 1'
@@ -374,7 +374,7 @@ public function testPaginateOrderVirtualField() {
public function testPaginateOrderVirtualFieldJoinedModel() {
$Controller = new PaginatorTestController($this->request);
$Controller->uses = array('PaginatorControllerPost');
$Controller->params['url'] = array();
$Controller->request->query = [];
$Controller->constructClasses();
$Controller->PaginatorControllerPost->recursive = 0;
$Controller->Paginator->settings = array(
@@ -682,26 +682,26 @@ public function testPaginateMaxLimit() {
'contain' => array('ControllerComment'), 'limit' => '1000'
);
$result = $Controller->paginate('PaginatorControllerPost');
$this->assertEquals(100, $Controller->params['paging']['PaginatorControllerPost']['options']['limit']);
$this->assertEquals(100, $Controller->request->params['paging']['PaginatorControllerPost']['options']['limit']);
$Controller->request->query = array(
'contain' => array('ControllerComment'), 'limit' => '1000', 'maxLimit' => 1000
);
$result = $Controller->paginate('PaginatorControllerPost');
$this->assertEquals(100, $Controller->params['paging']['PaginatorControllerPost']['options']['limit']);
$this->assertEquals(100, $Controller->request->params['paging']['PaginatorControllerPost']['options']['limit']);
$Controller->request->query = array('contain' => array('ControllerComment'), 'limit' => '10');
$result = $Controller->paginate('PaginatorControllerPost');
$this->assertEquals(10, $Controller->params['paging']['PaginatorControllerPost']['options']['limit']);
$this->assertEquals(10, $Controller->request->params['paging']['PaginatorControllerPost']['options']['limit']);
$Controller->request->query = array('contain' => array('ControllerComment'), 'limit' => '1000');
$Controller->paginate = array('maxLimit' => 2000);
$result = $Controller->paginate('PaginatorControllerPost');
$this->assertEquals(1000, $Controller->params['paging']['PaginatorControllerPost']['options']['limit']);
$this->assertEquals(1000, $Controller->request->params['paging']['PaginatorControllerPost']['options']['limit']);
$Controller->request->query = array('contain' => array('ControllerComment'), 'limit' => '5000');
$result = $Controller->paginate('PaginatorControllerPost');
$this->assertEquals(2000, $Controller->params['paging']['PaginatorControllerPost']['options']['limit']);
$this->assertEquals(2000, $Controller->request->params['paging']['PaginatorControllerPost']['options']['limit']);
}
/**
@@ -750,23 +750,23 @@ public function testPaginateCustomFind() {
$result = $Controller->paginate();
$this->assertEquals(array(1, 2, 3, 4), Hash::extract($result, '{n}.PaginatorCustomPost.id'));
$result = $Controller->params['paging']['PaginatorCustomPost'];
$result = $Controller->request->params['paging']['PaginatorCustomPost'];
$this->assertEquals(4, $result['current']);
$this->assertEquals(4, $result['count']);
$Controller->paginate = array('published');
$result = $Controller->paginate();
$this->assertEquals(array(1, 2, 3), Hash::extract($result, '{n}.PaginatorCustomPost.id'));
$result = $Controller->params['paging']['PaginatorCustomPost'];
$result = $Controller->request->params['paging']['PaginatorCustomPost'];
$this->assertEquals(3, $result['current']);
$this->assertEquals(3, $result['count']);
$Controller->paginate = array('published', 'limit' => 2);
$result = $Controller->paginate();
$this->assertEquals(array(1, 2), Hash::extract($result, '{n}.PaginatorCustomPost.id'));
$result = $Controller->params['paging']['PaginatorCustomPost'];
$result = $Controller->request->params['paging']['PaginatorCustomPost'];
$this->assertEquals(2, $result['current']);
$this->assertEquals(3, $result['count']);
$this->assertEquals(2, $result['pageCount']);
@@ -798,7 +798,7 @@ public function testPaginateCustomFindFieldsArray() {
2 => 'Second Post',
);
$this->assertEquals($expected, $result);
$result = $Controller->params['paging']['PaginatorCustomPost'];
$result = $Controller->request->params['paging']['PaginatorCustomPost'];
$this->assertEquals(2, $result['current']);
$this->assertEquals(3, $result['count']);
$this->assertEquals(2, $result['pageCount']);
@@ -830,7 +830,7 @@ public function testPaginateCustomFindWithCustomFindKey() {
2 => 'Second Post',
);
$this->assertEquals($expected, $result);
$result = $Controller->params['paging']['PaginatorCustomPost'];
$result = $Controller->request->params['paging']['PaginatorCustomPost'];
$this->assertEquals(2, $result['current']);
$this->assertEquals(3, $result['count']);
$this->assertEquals(2, $result['pageCount']);
@@ -872,7 +872,7 @@ public function testPaginateCustomFindGroupBy() {
)
);
$this->assertEquals($expected, $result);
$result = $Controller->params['paging']['PaginatorCustomPost'];
$result = $Controller->request->params['paging']['PaginatorCustomPost'];
$this->assertEquals(2, $result['current']);
$this->assertEquals(3, $result['count']);
$this->assertEquals(2, $result['pageCount']);
@@ -894,7 +894,7 @@ public function testPaginateCustomFindGroupBy() {
),
);
$this->assertEquals($expected, $result);
$result = $Controller->params['paging']['PaginatorCustomPost'];
$result = $Controller->request->params['paging']['PaginatorCustomPost'];
$this->assertEquals(1, $result['current']);
$this->assertEquals(3, $result['count']);
$this->assertEquals(2, $result['pageCount']);
@@ -943,7 +943,7 @@ public function testPaginateCustomFindCount() {
)
);
$this->assertEquals($expected, $result);
$result = $Controller->params['paging']['PaginatorCustomPost'];
$result = $Controller->request->params['paging']['PaginatorCustomPost'];
$this->assertEquals(2, $result['current']);
$this->assertEquals(3, $result['count']);
$this->assertEquals(2, $result['pageCount']);
@@ -263,7 +263,7 @@ public function testDisabling() {
$this->RequestHandler->initialize($this->Controller);
$this->Controller->beforeFilter();
$this->RequestHandler->startup($this->Controller);
$this->assertEquals(true, $this->Controller->params['isAjax']);
$this->assertEquals(true, $this->Controller->request->params['isAjax']);
}
/**
@@ -308,8 +308,8 @@ public function testStartupCallback() {
$_SERVER['CONTENT_TYPE'] = 'application/xml';
$this->Controller->request = $this->getMock('Cake\Network\Request', array('_readInput'));
$this->RequestHandler->startup($this->Controller);
$this->assertTrue(is_array($this->Controller->data));
$this->assertFalse(is_object($this->Controller->data));
$this->assertTrue(is_array($this->Controller->request->data));
$this->assertFalse(is_object($this->Controller->request->data));
}
/**
@@ -322,8 +322,8 @@ public function testStartupCallbackCharset() {
$_SERVER['CONTENT_TYPE'] = 'application/xml; charset=UTF-8';
$this->Controller->request = $this->getMock('Cake\Network\Request', array('_readInput'));
$this->RequestHandler->startup($this->Controller);
$this->assertTrue(is_array($this->Controller->data));
$this->assertFalse(is_object($this->Controller->data));
$this->assertTrue(is_array($this->Controller->request->data));
$this->assertFalse(is_object($this->Controller->request->data));
}
/**
@@ -228,7 +228,7 @@ public function testConstructorSettingProperties() {
*/
public function testStartup() {
$this->Controller->Security->startup($this->Controller);
$result = $this->Controller->params['_Token']['key'];
$result = $this->Controller->request->params['_Token']['key'];
$this->assertNotNull($result);
$this->assertTrue($this->Controller->Session->check('_Token'));
}
@@ -502,7 +502,7 @@ public function testValidatePostNoSession() {
$this->Controller->Security->startup($this->Controller);
$this->Controller->Session->delete('_Token');
$key = $this->Controller->params['_Token']['key'];
$key = $this->Controller->request->params['_Token']['key'];
$fields = 'a5475372b40f6e3ccbf9f8af191f20e1642fd877%3AModel.valid';
$this->Controller->data = array(
@@ -519,7 +519,7 @@ public function testValidatePostNoSession() {
*/
public function testValidatePostFormHacking() {
$this->Controller->Security->startup($this->Controller);
$key = $this->Controller->params['_Token']['key'];
$key = $this->Controller->request->params['_Token']['key'];
$unlocked = '';
$this->Controller->request->data = array(
@@ -1095,7 +1095,7 @@ public function testSettingTokenForRequestAction() {
$this->Controller->Security->startup($this->Controller);
$key = $this->Controller->request->params['_Token']['key'];
$this->Controller->params['requested'] = 1;
$this->Controller->request->params['requested'] = 1;
unset($this->Controller->request->params['_Token']);
$this->Controller->Security->startup($this->Controller);

0 comments on commit 883cc83

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