Skip to content

Commit

Permalink
Improved test cases where router parses url extensions
Browse files Browse the repository at this point in the history
  • Loading branch information
Takayuki Miwa committed Jan 14, 2011
1 parent bb3eb13 commit aa7fd1f
Showing 1 changed file with 21 additions and 19 deletions.
40 changes: 21 additions & 19 deletions tests/cases/components/search_pagination.test.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?php

App::import('Component', 'SearchPagination.SearchPagination');
App::import('Lib', 'Router');

class TestControllerForSearchPaginationComponentTestCase
extends Controller {
Expand All @@ -17,9 +18,23 @@ class SearchPaginationComponentTestCase extends CakeTestCase {
var $s;
var $c;
var $url = '/search/pagination';
var $_escapedGet;

function startTest() {
function startTest($method) {
Router::reload();
$this->c = new TestControllerForSearchPaginationComponentTestCase();

// set 'ext' parameter
if(preg_match('/parseExtensions/i', $method)) {
Router::parseExtensions();
}

$this->c->params = Router::parse($this->url);

// always set 'url' parameter
if(!isset($this->c->params['url'])) {
$this->c->params['url'] = array();
}
$this->c->params['url']['url'] = $this->url;

$this->s = new SearchPaginationComponent();
Expand Down Expand Up @@ -159,24 +174,7 @@ function testSetup_Get_NoParams() {
}

function testSetup_Get_NoParams_When_Router_ParseExtensions() {
$model = 'Article';
$params = array();
$default = array('foo' => 'bar');

// set 'ext' parameter
App::import('Lib', 'Router');
Router::parseExtensions();
$this->c->params = Router::parse('/articles/index');

$this->_setGetParams($params);

$data = $this->s->setup($model, $default);
$this->assertIdentical($default, $data);
$this->assertIdentical($default, $this->c->data[$model]);

// default parameters are not succeeded!
$this->assertIdentical(array('__search_params' => array()),
$this->c->helpers[$this->s->helperName]);
$this->testSetup_Get_NoParams();
}

function testSetup_Get_someParams() {
Expand All @@ -196,6 +194,10 @@ function testSetup_Get_someParams() {
$this->c->helpers[$this->s->helperName]);
}

function testSetup_Get_someParams_When_Router_ParseExtensions() {
$this->testSetup_Get_someParams();
}

function testSetup_Post_someParams() {
$model = 'Article';
$params = array('baz' => array(1,2,3),
Expand Down

0 comments on commit aa7fd1f

Please sign in to comment.