mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-18 18:46:17 +00:00
Moving to include tests and test suite in the 1.2.x.x core releases
git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@4430 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
parent
c98de6fe7f
commit
4c25103751
12 changed files with 2222 additions and 0 deletions
103
cake/tests/cases/dispatcher.test.php
Normal file
103
cake/tests/cases/dispatcher.test.php
Normal file
|
@ -0,0 +1,103 @@
|
|||
<?php
|
||||
/* SVN FILE: $Id$ */
|
||||
/**
|
||||
* Short description for file.
|
||||
*
|
||||
* Long description for file
|
||||
*
|
||||
* PHP versions 4 and 5
|
||||
*
|
||||
* CakePHP(tm) Tests <https://trac.cakephp.org/wiki/Developement/TestSuite>
|
||||
* Copyright 2005-2007, Cake Software Foundation, Inc.
|
||||
* 1785 E. Sahara Avenue, Suite 490-204
|
||||
* Las Vegas, Nevada 89104
|
||||
*
|
||||
* Licensed under The Open Group Test Suite License
|
||||
* Redistributions of files must retain the above copyright notice.
|
||||
*
|
||||
* @filesource
|
||||
* @copyright Copyright 2005-2007, Cake Software Foundation, Inc.
|
||||
* @link https://trac.cakephp.org/wiki/Developement/TestSuite CakePHP(tm) Tests
|
||||
* @package cake.tests
|
||||
* @subpackage cake.tests.cases
|
||||
* @since CakePHP(tm) v 1.2.0.4206
|
||||
* @version $Revision$
|
||||
* @modifiedby $LastChangedBy$
|
||||
* @lastmodified $Date$
|
||||
* @license http://www.opensource.org/licenses/opengroup.php The Open Group Test Suite License
|
||||
*/
|
||||
require_once LIBS.'neat_array.php';
|
||||
require_once CAKE.'dispatcher.php';
|
||||
/**
|
||||
* Short description for class.
|
||||
*
|
||||
* @package cake.tests
|
||||
* @subpackage cake.tests.cases
|
||||
*/
|
||||
class DispatcherTest extends UnitTestCase {
|
||||
|
||||
function testParseParamsWithoutZerosAndEmptyPost() {
|
||||
$dispatcher =& new Dispatcher();
|
||||
$test = $dispatcher->parseParams("/testcontroller/testaction/params1/params2/params3");
|
||||
$this->assertIdentical($test['controller'], 'testcontroller', "<br />Parsed URL shows controller is {$test['controller']} expected testcontroller" );
|
||||
$this->assertIdentical($test['action'], 'testaction', "<br />Parsed URL shows action is {$test['action']} expected testaction" );
|
||||
$this->assertIdentical($test['pass'][0], 'params1', "<br />Parsed URL shows action is {$test['pass'][0]} expected params1" );
|
||||
$this->assertIdentical($test['pass'][1], 'params2', "<br />Parsed URL shows action is {$test['pass'][1]} expected params2" );
|
||||
$this->assertIdentical($test['pass'][2], 'params3', "<br />Parsed URL shows action is {$test['pass'][2]} expected params3" );
|
||||
$this->assertFalse(!empty($test['form']), "<br />Parsed URL returning post data expected not post data");
|
||||
}
|
||||
|
||||
function testParseParamsReturnsPostedData() {
|
||||
$_POST['testdata'] = "My Posted Content";
|
||||
$dispatcher =& new Dispatcher();
|
||||
$test = $dispatcher->parseParams("/");
|
||||
$this->assertTrue($test['form'], "Parsed URL not returning post data");
|
||||
$this->assertIdentical($test['form']['testdata'],
|
||||
"My Posted Content",
|
||||
"'Post content is {$test['form']['testdata']} expected My Posted Content");
|
||||
}
|
||||
|
||||
function testParseParamsWithSingleZero() {
|
||||
$dispatcher =& new Dispatcher();
|
||||
$test = $dispatcher->parseParams("/testcontroller/testaction/1/0/23");
|
||||
$this->assertIdentical($test['controller'], 'testcontroller', "<br />Parsed URL shows controller is {$test['controller']} expected testcontroller" );
|
||||
$this->assertIdentical($test['action'], 'testaction', "<br />Parsed URL shows action is {$test['action']} expected testaction" );
|
||||
$this->assertIdentical($test['pass'][0], '1', "value is {$test['pass'][0]} expected 1" );
|
||||
$this->assertPattern('/\\A(?:0)\\z/', $test['pass'][1], "value is {$test['pass'][1]} expected 0" );
|
||||
$this->assertIdentical($test['pass'][2], '23', "value is {$test['pass'][2]} expected 23" );
|
||||
}
|
||||
|
||||
function testParseParamsWithManySingleZeros() {
|
||||
$dispatcher =& new Dispatcher();
|
||||
$test = $dispatcher->parseParams("/testcontroller/testaction/0/0/0/0/0/0");
|
||||
$this->assertPattern('/\\A(?:0)\\z/', $test['pass'][0], "value is {$test['pass'][0]} expected 0" );
|
||||
$this->assertPattern('/\\A(?:0)\\z/', $test['pass'][1], "value is {$test['pass'][1]} expected 0" );
|
||||
$this->assertPattern('/\\A(?:0)\\z/', $test['pass'][2], "value is {$test['pass'][2]} expected 0" );
|
||||
$this->assertPattern('/\\A(?:0)\\z/', $test['pass'][3], "value is {$test['pass'][3]} expected 0" );
|
||||
$this->assertPattern('/\\A(?:0)\\z/', $test['pass'][4], "value is {$test['pass'][4]} expected 0" );
|
||||
$this->assertPattern('/\\A(?:0)\\z/', $test['pass'][5], "value is {$test['pass'][5]} expected 0" );
|
||||
}
|
||||
|
||||
function testParseParamsWithManyZerosInEachSectionOfUrl() {
|
||||
$dispatcher =& new Dispatcher();
|
||||
$test = $dispatcher->parseParams("/testcontroller/testaction/000/0000/00000/000000/000000/0000000");
|
||||
$this->assertPattern('/\\A(?:000)\\z/', $test['pass'][0], "value is {$test['pass'][0]} expected 000" );
|
||||
$this->assertPattern('/\\A(?:0000)\\z/', $test['pass'][1], "value is {$test['pass'][1]} expected 0000" );
|
||||
$this->assertPattern('/\\A(?:00000)\\z/', $test['pass'][2], "value is {$test['pass'][2]} expected 00000" );
|
||||
$this->assertPattern('/\\A(?:000000)\\z/', $test['pass'][3], "value is {$test['pass'][3]} expected 000000" );
|
||||
$this->assertPattern('/\\A(?:000000)\\z/', $test['pass'][4], "value is {$test['pass'][4]} expected 000000" );
|
||||
$this->assertPattern('/\\A(?:0000000)\\z/', $test['pass'][5], "value is {$test['pass'][5]} expected 0000000" );
|
||||
}
|
||||
|
||||
function testParseParamsWithMixedOneToManyZerosInEachSectionOfUrl() {
|
||||
$dispatcher =& new Dispatcher();
|
||||
$test = $dispatcher->parseParams("/testcontroller/testaction/01/0403/04010/000002/000030/0000400");
|
||||
$this->assertPattern('/\\A(?:01)\\z/', $test['pass'][0], "value is {$test['pass'][0]} expected 01" );
|
||||
$this->assertPattern('/\\A(?:0403)\\z/', $test['pass'][1], "value is {$test['pass'][1]} expected 0403" );
|
||||
$this->assertPattern('/\\A(?:04010)\\z/', $test['pass'][2], "value is {$test['pass'][2]} expected 04010" );
|
||||
$this->assertPattern('/\\A(?:000002)\\z/', $test['pass'][3], "value is {$test['pass'][3]} expected 000002" );
|
||||
$this->assertPattern('/\\A(?:000030)\\z/', $test['pass'][4], "value is {$test['pass'][4]} expected 000030" );
|
||||
$this->assertPattern('/\\A(?:0000400)\\z/', $test['pass'][5], "value is {$test['pass'][5]} expected 0000400" );
|
||||
}
|
||||
}
|
||||
?>
|
|
@ -0,0 +1,73 @@
|
|||
<?php
|
||||
/* SVN FILE: $Id$ */
|
||||
/**
|
||||
* Short description for file.
|
||||
*
|
||||
* Long description for file
|
||||
*
|
||||
* PHP versions 4 and 5
|
||||
*
|
||||
* CakePHP(tm) Tests <https://trac.cakephp.org/wiki/Developement/TestSuite>
|
||||
* Copyright 2005-2007, Cake Software Foundation, Inc.
|
||||
* 1785 E. Sahara Avenue, Suite 490-204
|
||||
* Las Vegas, Nevada 89104
|
||||
*
|
||||
* Licensed under The Open Group Test Suite License
|
||||
* Redistributions of files must retain the above copyright notice.
|
||||
*
|
||||
* @filesource
|
||||
* @copyright Copyright 2005-2007, Cake Software Foundation, Inc.
|
||||
* @link https://trac.cakephp.org/wiki/Developement/TestSuite CakePHP(tm) Tests
|
||||
* @package cake.tests
|
||||
* @subpackage cake.tests.cases.libs.controller.components.dbacl.models
|
||||
* @since CakePHP(tm) v 1.2.0.4206
|
||||
* @version $Revision$
|
||||
* @modifiedby $LastChangedBy$
|
||||
* @lastmodified $Date$
|
||||
* @license http://www.opensource.org/licenses/opengroup.php The Open Group Test Suite License
|
||||
*/
|
||||
if (!defined('CAKEPHP_UNIT_TEST_EXECUTION')) {
|
||||
define('CAKEPHP_UNIT_TEST_EXECUTION', 1);
|
||||
}
|
||||
require_once LIBS.'model'.DS.'model.php';
|
||||
require_once LIBS.'controller'.DS.'components'.DS.'dbacl'.DS.'models'.DS.'aclnode.php';
|
||||
require_once LIBS.'controller'.DS.'components'.DS.'dbacl'.DS.'models'.DS.'aco.php';
|
||||
require_once LIBS.'controller'.DS.'components'.DS.'dbacl'.DS.'models'.DS.'aro.php';
|
||||
require_once LIBS.'controller'.DS.'components'.DS.'dbacl'.DS.'models'.DS.'aros_aco.php';
|
||||
/**
|
||||
* Short description for class.
|
||||
*
|
||||
* @package cake.tests
|
||||
* @subpackage cake.tests.cases.libs.controller.components.dbacl.models
|
||||
*/
|
||||
class AclNodeTest extends UnitTestCase {
|
||||
|
||||
function setUp() {
|
||||
$this->aro =& new Aro();
|
||||
}
|
||||
|
||||
function testNodeNesting() {
|
||||
$this->aro->create(1, null, 'Food');
|
||||
$this->aro->create(2, null, 'Fruit');
|
||||
$this->aro->create(3, null, 'Red');
|
||||
$this->aro->create(4, null, 'Cherry');
|
||||
$this->aro->create(5, null, 'Yellow');
|
||||
$this->aro->create(6, null, 'Banana');
|
||||
$this->aro->create(7, null, 'Meat');
|
||||
$this->aro->create(8, null, 'Beef');
|
||||
$this->aro->create(9, null, 'Pork');
|
||||
|
||||
$this->aro->setParent('Food', 'Meat');
|
||||
$this->aro->setParent('Food', 'Fruit');
|
||||
|
||||
$this->aro->setParent('Fruit', 'Yellow');
|
||||
$this->aro->setParent('Yellow', 'Banana');
|
||||
$this->aro->setParent('Fruit', 'Red');
|
||||
$this->aro->setParent('Red', 'Cherry');
|
||||
|
||||
$this->aro->setParent('Meat', 'Pork');
|
||||
$this->aro->setParent('Meat', 'Beef');
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
268
cake/tests/cases/libs/model/datasources/dbo_source.test.php
Normal file
268
cake/tests/cases/libs/model/datasources/dbo_source.test.php
Normal file
|
@ -0,0 +1,268 @@
|
|||
<?php
|
||||
/* SVN FILE: $Id$ */
|
||||
/**
|
||||
* Short description for file.
|
||||
*
|
||||
* Long description for file
|
||||
*
|
||||
* PHP versions 4 and 5
|
||||
*
|
||||
* CakePHP(tm) Tests <https://trac.cakephp.org/wiki/Developement/TestSuite>
|
||||
* Copyright 2005-2007, Cake Software Foundation, Inc.
|
||||
* 1785 E. Sahara Avenue, Suite 490-204
|
||||
* Las Vegas, Nevada 89104
|
||||
*
|
||||
* Licensed under The Open Group Test Suite License
|
||||
* Redistributions of files must retain the above copyright notice.
|
||||
*
|
||||
* @filesource
|
||||
* @copyright Copyright 2005-2007, Cake Software Foundation, Inc.
|
||||
* @link https://trac.cakephp.org/wiki/Developement/TestSuite CakePHP(tm) Tests
|
||||
* @package cake.tests
|
||||
* @subpackage cake.tests.cases.libs.model.datasources
|
||||
* @since CakePHP(tm) v 1.2.0.4206
|
||||
* @version $Revision$
|
||||
* @modifiedby $LastChangedBy$
|
||||
* @lastmodified $Date$
|
||||
* @license http://www.opensource.org/licenses/opengroup.php The Open Group Test Suite License
|
||||
*/
|
||||
if (!defined('CAKEPHP_UNIT_TEST_EXECUTION')) {
|
||||
define('CAKEPHP_UNIT_TEST_EXECUTION', 1);
|
||||
}
|
||||
require_once LIBS.'model'.DS.'model.php';
|
||||
require_once LIBS.'model'.DS.'datasources'.DS.'datasource.php';
|
||||
require_once LIBS.'model'.DS.'datasources'.DS.'dbo_source.php';
|
||||
require_once LIBS.'model'.DS.'datasources'.DS.'dbo'.DS.'dbo_mysql.php';
|
||||
/**
|
||||
* Short description for class.
|
||||
*
|
||||
* @package cake.tests
|
||||
* @subpackage cake.tests.cases.libs.model.datasources
|
||||
*/
|
||||
class TestModel extends Model {
|
||||
|
||||
var $name = 'TestModel';
|
||||
var $useTable = false;
|
||||
|
||||
function find($conditions = null, $fields = null, $order = null, $recursive = null) {
|
||||
return $conditions;
|
||||
}
|
||||
|
||||
function loadInfo() {
|
||||
return new Set(array(
|
||||
array('name' => 'id', 'type' => 'integer', 'null' => '', 'default' => '', 'length' => '8'),
|
||||
array('name' => 'client_id', 'type' => 'integer', 'null' => '', 'default' => '0', 'length' => '11'),
|
||||
array('name' => 'name', 'type' => 'string', 'null' => '', 'default' => '', 'length' => '255'),
|
||||
array('name' => 'login', 'type' => 'string', 'null' => '', 'default' => '', 'length' => '255'),
|
||||
array('name' => 'passwd', 'type' => 'string', 'null' => '1', 'default' => '', 'length' => '255'),
|
||||
array('name' => 'addr_1', 'type' => 'string', 'null' => '1', 'default' => '', 'length' => '255'),
|
||||
array('name' => 'addr_2', 'type' => 'string', 'null' => '1', 'default' => '', 'length' => '25'),
|
||||
array('name' => 'zip_code', 'type' => 'string', 'null' => '1', 'default' => '', 'length' => '155'),
|
||||
array('name' => 'city', 'type' => 'string', 'null' => '1', 'default' => '', 'length' => '155'),
|
||||
array('name' => 'country', 'type' => 'string', 'null' => '1', 'default' => '', 'length' => '155'),
|
||||
array('name' => 'phone', 'type' => 'string', 'null' => '1', 'default' => '', 'length' => '155'),
|
||||
array('name' => 'fax', 'type' => 'string', 'null' => '1', 'default' => '', 'length' => '155'),
|
||||
array('name' => 'url', 'type' => 'string', 'null' => '1', 'default' => '', 'length' => '255'),
|
||||
array('name' => 'email', 'type' => 'string', 'null' => '1', 'default' => '', 'length' => '155'),
|
||||
array('name' => 'comments', 'type' => 'text', 'null' => '1', 'default' => '', 'length' => ''),
|
||||
array('name' => 'last_login', 'type' => 'datetime', 'null' => '1', 'default' => '', 'length' => ''),
|
||||
array('name' => 'created', 'type' => 'date', 'null' => '1', 'default' => '', 'length' => ''),
|
||||
array('name' => 'updated', 'type' => 'datetime', 'null' => '1', 'default' => '', 'length' => null)
|
||||
));
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Short description for class.
|
||||
*
|
||||
* @package cake.tests
|
||||
* @subpackage cake.tests.cases.libs.model.datasources
|
||||
*/
|
||||
class TestModel2 extends Model {
|
||||
|
||||
var $name = 'TestModel2';
|
||||
var $useTable = false;
|
||||
}
|
||||
/**
|
||||
* Short description for class.
|
||||
*
|
||||
* @package cake.tests
|
||||
* @subpackage cake.tests.cases.libs.model.datasources
|
||||
*/
|
||||
class TestModel3 extends Model {
|
||||
|
||||
var $name = 'TestModel2';
|
||||
var $useTable = false;
|
||||
}
|
||||
/**
|
||||
* Short description for class.
|
||||
*
|
||||
* @package cake.tests
|
||||
* @subpackage cake.tests.cases.libs.model.datasources
|
||||
*/
|
||||
class DboTest extends DboMysql {
|
||||
|
||||
var $simulated = array();
|
||||
|
||||
function _execute($sql) {
|
||||
$this->simulated[] = $sql;
|
||||
return null;
|
||||
}
|
||||
|
||||
function getLastQuery() {
|
||||
return $this->simulated[count($this->simulated) - 1];
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Short description for class.
|
||||
*
|
||||
* @package cake.tests
|
||||
* @subpackage cake.tests.cases.libs.model.datasources
|
||||
*/
|
||||
class DboSourceTest extends UnitTestCase {
|
||||
|
||||
function setUp() {
|
||||
require_once r('//', '/', APP) . 'config/database.php';
|
||||
$config = new DATABASE_CONFIG();
|
||||
$this->db =& new DboTest($config->default);
|
||||
$this->model = new TestModel();
|
||||
}
|
||||
|
||||
function testStringConditionsParsing() {
|
||||
$result = $this->db->conditions("Candy.name LIKE 'a' AND HardCandy.name LIKE 'c'");
|
||||
$expected = " WHERE `Candy`.`name` LIKE 'a' AND `HardCandy`.`name` LIKE 'c'";
|
||||
$this->assertEqual($result, $expected, "Error quoting field names in DboSource::conditions(), expected '{$expected}', got '{$result}'.");
|
||||
|
||||
$result = $this->db->conditions("HardCandy.name LIKE 'a' AND Candy.name LIKE 'c'");
|
||||
$expected = " WHERE `HardCandy`.`name` LIKE 'a' AND `Candy`.`name` LIKE 'c'";
|
||||
$this->assertEqual($result, $expected, "Error quoting field names in DboSource::conditions(), expected '{$expected}', got '{$result}'.");
|
||||
|
||||
$result = $this->db->conditions("Post.title = '1.1'");
|
||||
$expected = " WHERE `Post`.`title` = '1.1'";
|
||||
$this->assertEqual($result, $expected, "Error quoting field names in DboSource::conditions(), expected '{$expected}', got '{$result}'.");
|
||||
|
||||
$result = $this->db->conditions("SUM(Post.comments_count) > 500");
|
||||
$expected = " WHERE SUM( `Post`.`comments_count`) > 500";
|
||||
$this->assertEqual($result, $expected, "Error quoting field names in DboSource::conditions(), expected '{$expected}', got '{$result}'.");
|
||||
|
||||
$result = $this->db->conditions("(Post.created < '" . date('Y-m-d H:i:s') . "') GROUP BY YEAR(Post.created), MONTH(Post.created)");
|
||||
$expected = " WHERE ( `Post`.`created` < '" . date('Y-m-d H:i:s') . "') GROUP BY YEAR( `Post`.`created`), MONTH( `Post`.`created`)";
|
||||
$this->assertEqual($result, $expected, "Error quoting field names in DboSource::conditions(), expected '{$expected}', got '{$result}'.");
|
||||
|
||||
$result = $this->db->conditions("score BETWEEN 90.1 AND 95.7");
|
||||
$expected = " WHERE score BETWEEN 90.1 AND 95.7";
|
||||
$this->assertEqual($result, $expected, "Error quoting field names in DboSource::conditions(), expected '{$expected}', got '{$result}'.");
|
||||
|
||||
$result = $this->db->conditions("Aro.rght = Aro.lft + 1.1");
|
||||
$expected = " WHERE `Aro`.`rght` = `Aro`.`lft` + 1.1";
|
||||
$this->assertEqual($result, $expected, "Error quoting field names in DboSource::conditions(), expected '{$expected}', got '{$result}'.");
|
||||
|
||||
$result = $this->db->conditions("(Post.created < '" . date('Y-m-d H:i:s') . "') GROUP BY YEAR(Post.created), MONTH(Post.created)");
|
||||
$expected = " WHERE ( `Post`.`created` < '" . date('Y-m-d H:i:s') . "') GROUP BY YEAR( `Post`.`created`), MONTH( `Post`.`created`)";
|
||||
$this->assertEqual($result, $expected, "Error quoting field names in DboSource::conditions(), expected '{$expected}', got '{$result}'.");
|
||||
|
||||
$result = $this->db->conditions('Sportstaette.sportstaette LIKE "%ru%" AND Sportstaette.sportstaettenart_id = 2');
|
||||
$expected = ' WHERE `Sportstaette`.`sportstaette` LIKE "%ru%" AND `Sportstaette`.`sportstaettenart_id` = 2';
|
||||
$this->assertEqual($result, $expected, "Error quoting field names in DboSource::conditions(), expected '" . r('%', '_', $expected) . "', got '" . r('%', '_', $result) . "'.");
|
||||
|
||||
$result = $this->db->conditions('Sportstaette.sportstaettenart_id = 2 AND Sportstaette.sportstaette LIKE "%ru%"');
|
||||
$expected = ' WHERE `Sportstaette`.`sportstaettenart_id` = 2 AND `Sportstaette`.`sportstaette` LIKE "%ru%"';
|
||||
$this->assertEqual($result, $expected, "Error quoting field names in DboSource::conditions(), expected '" . r('%', '_', $expected) . "', got '" . r('%', '_', $result) . "'.");
|
||||
|
||||
$result = $this->db->conditions('SUM(Post.comments_count) > 500 AND NOT Post.title IS NULL AND NOT Post.extended_title IS NULL');
|
||||
$expected = ' WHERE SUM( `Post`.`comments_count`) > 500 AND NOT `Post`.`title` IS NULL AND NOT `Post`.`extended_title` IS NULL';
|
||||
$this->assertEqual($result, $expected, "Error quoting field names in DboSource::conditions(), expected '{$expected}', got '{$result}'.");
|
||||
|
||||
$result = $this->db->conditions('NOT Post.title IS NULL AND NOT Post.extended_title IS NULL AND SUM(Post.comments_count) > 500');
|
||||
$expected = ' WHERE NOT `Post`.`title` IS NULL AND NOT `Post`.`extended_title` IS NULL AND SUM( `Post`.`comments_count`) > 500';
|
||||
$this->assertEqual($result, $expected, "Error quoting field names in DboSource::conditions(), expected '{$expected}', got '{$result}'.");
|
||||
|
||||
$result = $this->db->conditions('NOT Post.extended_title IS NULL AND NOT Post.title IS NULL AND Post.title != "" AND SPOON(SUM(Post.comments_count) + 1.1) > 500');
|
||||
$expected = ' WHERE NOT `Post`.`extended_title` IS NULL AND NOT `Post`.`title` IS NULL AND `Post`.`title` != "" AND SPOON(SUM( `Post`.`comments_count`) + 1.1) > 500';
|
||||
$this->assertEqual($result, $expected, "Error quoting field names in DboSource::conditions(), expected '{$expected}', got '{$result}'.");
|
||||
|
||||
$result = $this->db->conditions('NOT Post.title_extended IS NULL AND NOT Post.title IS NULL AND Post.title_extended != Post.title');
|
||||
$expected = ' WHERE NOT `Post`.`title_extended` IS NULL AND NOT `Post`.`title` IS NULL AND `Post`.`title_extended` != `Post`.`title`';
|
||||
$this->assertEqual($result, $expected, "Error quoting field names in DboSource::conditions(), expected '{$expected}', got '{$result}'.");
|
||||
}
|
||||
|
||||
function testArrayConditionsParsing() {
|
||||
$result = $this->db->conditions(array('Candy.name' => 'LIKE a', 'HardCandy.name' => 'LIKE c'));
|
||||
$expected = " WHERE `Candy`.`name` LIKE 'a' AND `HardCandy`.`name` LIKE 'c'";
|
||||
$this->assertEqual($result, $expected, "Error quoting field names in DboSource::conditions(), expected '{$expected}', got '{$result}'.");
|
||||
|
||||
$result = $this->db->conditions(array('HardCandy.name' => 'LIKE a', 'Candy.name' => 'LIKE c'));
|
||||
$expected = " WHERE `HardCandy`.`name` LIKE 'a' AND `Candy`.`name` LIKE 'c'";
|
||||
$this->assertEqual($result, $expected, "Error quoting field names in DboSource::conditions(), expected '{$expected}', got '{$result}'.");
|
||||
|
||||
$result = $this->db->conditions(array('score' => 'BETWEEN 90.1 AND 95.7'));
|
||||
$expected = " WHERE `score` BETWEEN '90.1' AND '95.7'";
|
||||
$this->assertEqual($result, $expected, "Error quoting field names in DboSource::conditions(), expected '{$expected}', got '{$result}'.");
|
||||
|
||||
$result = $this->db->conditions(array('Post.title' => 1.1));
|
||||
$expected = " WHERE `Post`.`title` = 1.1";
|
||||
$this->assertEqual($result, $expected, "Error quoting field names in DboSource::conditions(), expected '{$expected}', got '{$result}'.");
|
||||
|
||||
$result = $this->db->conditions(array('SUM(Post.comments_count)' => '> 500'));
|
||||
$expected = " WHERE SUM(`Post`.`comments_count`) > 500";
|
||||
$this->assertEqual($result, $expected, "Error quoting field names in DboSource::conditions(), expected '{$expected}', got '{$result}'.");
|
||||
}
|
||||
|
||||
function testFieldParsing() {
|
||||
$result = $this->db->fields($this->model, 'Post', "CONCAT(REPEAT(' ', COUNT(Parent.name) - 1), Node.name) AS name, Node.created");
|
||||
$expected = array("CONCAT(REPEAT(' ', COUNT(`Parent`.`name`) - 1), Node.name) AS name", "`Node`.`created`");
|
||||
$this->assertEqual($result, $expected, "Error quoting field names in DboSource::fields(), expected '{$expected[0]}', got '{$result[0]}'.");
|
||||
|
||||
$result = $this->db->fields($this->model, 'Post', "Node.created, CONCAT(REPEAT(' ', COUNT(Parent.name) - 1), Node.name) AS name");
|
||||
$expected = array("`Node`.`created`", "CONCAT(REPEAT(' ', COUNT(`Parent`.`name`) - 1), Node.name) AS name");
|
||||
$this->assertEqual($result, $expected, "Error quoting field names in DboSource::fields(), expected '{$expected[0]}', got '{$result[0]}'.");
|
||||
|
||||
$result = $this->db->fields($this->model, 'Post', "2.2,COUNT(*), SUM(Something.else) as sum, Node.created, CONCAT(REPEAT(' ', COUNT(Parent.name) - 1), Node.name) AS name,Post.title,Post.1,1.1");
|
||||
$expected = array(
|
||||
'2.2', 'COUNT(*)', 'SUM(`Something`.`else`) as sum', '`Node`.`created`',
|
||||
"CONCAT(REPEAT(' ', COUNT(`Parent`.`name`) - 1), Node.name) AS name", '`Post`.`title`', '`Post`.`1`', '1.1'
|
||||
);
|
||||
$this->assertEqual($result, $expected, "Error quoting field names in DboSource::fields(), expected '{$expected[0]}', got '{$result[0]}'.");
|
||||
}
|
||||
|
||||
function testMagicMethodQuerying() {
|
||||
$result = $this->db->query('findByFieldName', array('value'), $this->model);
|
||||
$expected = array('TestModel.field_name' => '= value');
|
||||
$this->assertEqual($result, $expected, "Error computing conditions from magic method.");
|
||||
|
||||
$result = $this->db->query('findByFieldName', array(array('value1', 'value2', 'value3')), $this->model);
|
||||
$expected = array('TestModel.field_name' => array('value1', 'value2', 'value3'));
|
||||
$this->assertEqual($result, $expected, "Error computing conditions from magic method with array value.");
|
||||
|
||||
$result = $this->db->query('findByFieldName', array(null), $this->model);
|
||||
$expected = array('TestModel.field_name' => null);
|
||||
$this->assertEqual($result, $expected, "Error computing conditions from magic method with null value.");
|
||||
|
||||
$result = $this->db->query('findByFieldName', array('= a'), $this->model);
|
||||
$expected = array('TestModel.field_name' => '= = a');
|
||||
$this->assertEqual($result, $expected, "Error computing conditions from magic method with string value.");
|
||||
}
|
||||
|
||||
function testSomething() {
|
||||
$this->model->Test2 = new TestModel2();
|
||||
$this->model->hasAndBelongsToMany = array('Test2' => array(
|
||||
// 'with' => 'Testship',
|
||||
'className' => 'TestModel2',
|
||||
'joinTable' => 'tests',
|
||||
'foreignKey' => 'contact_id',
|
||||
'associationForeignKey' => 'project_id',
|
||||
'conditions' => null,
|
||||
'fields' => null,
|
||||
'order' => null,
|
||||
'limit' => null,
|
||||
'offset' => null,
|
||||
'unique' => null,
|
||||
'finderQuery' => null,
|
||||
'deleteQuery' => null,
|
||||
'insertQuery' => null
|
||||
));
|
||||
|
||||
//generateAssociationQuery($this->model, $this->model->Test2, $type, $association = null, $assocData = array(), &$queryData, $external = false, &$resultSet)
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
54
cake/tests/cases/libs/model/model.test.php
Normal file
54
cake/tests/cases/libs/model/model.test.php
Normal file
|
@ -0,0 +1,54 @@
|
|||
<?php
|
||||
/* SVN FILE: $Id$ */
|
||||
/**
|
||||
* Short description for file.
|
||||
*
|
||||
* Long description for file
|
||||
*
|
||||
* PHP versions 4 and 5
|
||||
*
|
||||
* CakePHP(tm) Tests <https://trac.cakephp.org/wiki/Developement/TestSuite>
|
||||
* Copyright 2005-2007, Cake Software Foundation, Inc.
|
||||
* 1785 E. Sahara Avenue, Suite 490-204
|
||||
* Las Vegas, Nevada 89104
|
||||
*
|
||||
* Licensed under The Open Group Test Suite License
|
||||
* Redistributions of files must retain the above copyright notice.
|
||||
*
|
||||
* @filesource
|
||||
* @copyright Copyright 2005-2007, Cake Software Foundation, Inc.
|
||||
* @link https://trac.cakephp.org/wiki/Developement/TestSuite CakePHP(tm) Tests
|
||||
* @package cake.tests
|
||||
* @subpackage cake.tests.cases.libs.model
|
||||
* @since CakePHP(tm) v 1.2.0.4206
|
||||
* @version $Revision$
|
||||
* @modifiedby $LastChangedBy$
|
||||
* @lastmodified $Date$
|
||||
* @license http://www.opensource.org/licenses/opengroup.php The Open Group Test Suite License
|
||||
*/
|
||||
if (!defined('CAKEPHP_UNIT_TEST_EXECUTION')) {
|
||||
define('CAKEPHP_UNIT_TEST_EXECUTION', 1);
|
||||
}
|
||||
require_once LIBS.'model'.DS.'model.php';
|
||||
|
||||
class Test extends Model { var $useTable = false; }
|
||||
/**
|
||||
* Short description for class.
|
||||
*
|
||||
* @package cake.tests
|
||||
* @subpackage cake.tests.cases.libs.model
|
||||
*/
|
||||
class ModelTest extends UnitTestCase {
|
||||
|
||||
function setUp() {
|
||||
$this->test =& new Test();
|
||||
}
|
||||
|
||||
function testIdentity() {
|
||||
$result = $this->test->name;
|
||||
$expected = 'Test';
|
||||
$this->assertEqual($result, $expected, "Identity test failed, got {$result}, expected {$expected}.");
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
146
cake/tests/cases/libs/router.test.php
Normal file
146
cake/tests/cases/libs/router.test.php
Normal file
|
@ -0,0 +1,146 @@
|
|||
<?php
|
||||
/* SVN FILE: $Id$ */
|
||||
/**
|
||||
* Short description for file.
|
||||
*
|
||||
* Long description for file
|
||||
*
|
||||
* PHP versions 4 and 5
|
||||
*
|
||||
* CakePHP(tm) Tests <https://trac.cakephp.org/wiki/Developement/TestSuite>
|
||||
* Copyright 2005-2007, Cake Software Foundation, Inc.
|
||||
* 1785 E. Sahara Avenue, Suite 490-204
|
||||
* Las Vegas, Nevada 89104
|
||||
*
|
||||
* Licensed under The Open Group Test Suite License
|
||||
* Redistributions of files must retain the above copyright notice.
|
||||
*
|
||||
* @filesource
|
||||
* @copyright Copyright 2005-2007, Cake Software Foundation, Inc.
|
||||
* @link https://trac.cakephp.org/wiki/Developement/TestSuite CakePHP(tm) Tests
|
||||
* @package cake.tests
|
||||
* @subpackage cake.tests.cases.libs
|
||||
* @since CakePHP(tm) v 1.2.0.4206
|
||||
* @version $Revision$
|
||||
* @modifiedby $LastChangedBy$
|
||||
* @lastmodified $Date$
|
||||
* @license http://www.opensource.org/licenses/opengroup.php The Open Group Test Suite License
|
||||
*/
|
||||
require_once LIBS.'router.php';
|
||||
/**
|
||||
* Short description for class.
|
||||
*
|
||||
* @package cake.tests
|
||||
* @subpackage cake.tests.cases.libs
|
||||
*/
|
||||
class RouterTest extends UnitTestCase {
|
||||
|
||||
function testReturnedInstanceReference() {
|
||||
$router =& Router::getInstance();
|
||||
$router->testVar = 'test';
|
||||
$this->assertIdentical($router, Router::getInstance(), "Instantiated Router object not referrentially equal to result of Router::getInstance()");
|
||||
unset($router->testVar);
|
||||
}
|
||||
|
||||
function testRouteWriting() {
|
||||
$router =& Router::getInstance();
|
||||
|
||||
$router->routes = array();
|
||||
$router->connect('/');
|
||||
$this->assertEqual($router->routes[0][0], '/', "Route map error for \"/\": expected '/', got '" . $router->routes[0][0] . "'");
|
||||
$this->assertEqual($router->routes[0][1], '/^[\/]*$/', "Route map error for \"/\": expected '/^[\/]*$/', got '" . $router->routes[0][1] . "'");
|
||||
$this->assertEqual($router->routes[0][2], array(), "Route map error for \"/\"");
|
||||
|
||||
$router->routes = array();
|
||||
$router->connect('/', array('controller' => 'testing'));
|
||||
$this->assertTrue(is_array($router->routes[0][3]) && !empty($router->routes[0][3]), '/', "Route map error for \"/\" with default controller");
|
||||
$this->assertEqual($router->routes[0][3]['controller'], 'testing', "Route map error for \"/\" with default controller");
|
||||
$this->assertEqual($router->routes[0][3]['action'], 'index', "Route map error for \"/\" with default controller");
|
||||
$this->assertEqual(count($router->routes[0][3]), 3, "Route map error for \"/\" with default controller: defaults array length is ".count($router->routes[0][3]).', expected 2');
|
||||
|
||||
$router->routes = array();
|
||||
$router->connect('/:controller', array('controller' => 'testing2'));
|
||||
$this->assertTrue(is_array($router->routes[0][3]) && !empty($router->routes[0][3]), '/', "Route map error for \"/:controller\" with default controller");
|
||||
$this->assertEqual($router->routes[0][3]['controller'], 'testing2', "Route map error for \"/:controller\" with default controller");
|
||||
$this->assertEqual($router->routes[0][3]['action'], 'index', "Route map error for \"/:controller\" with default controller");
|
||||
$this->assertEqual(count($router->routes[0][3]), 3, "Route map error for \"/:controller\" with default controller: defaults array length is ".count($router->routes[0][3]).', expected 2');
|
||||
|
||||
$router->routes = array();
|
||||
$router->connect('/:controller/:action', array('controller' => 'testing3'));
|
||||
$this->assertEqual($router->routes[0][0], '/:controller/:action', "Route map error for \"/:controller/:action\" with default controller");
|
||||
$this->assertEqual($router->routes[0][1], '#^(?:\/([^\/]+))?(?:\/([^\/]+))?[\/]*$#', "Route map error for \"/:controller/:action\" with default controller");
|
||||
$this->assertEqual($router->routes[0][2], array('controller', 'action'), "Route map error for \"/:controller\" with default controller: defaults array length is ".count($router->routes[0][3]).', expected 2');
|
||||
$this->assertEqual($router->routes[0][3], array('controller' => 'testing3', 'action' => 'index', 'plugin' => null), "Route map error for \"/:controller/:action\" with default controller");
|
||||
|
||||
$router->routes = array();
|
||||
$router->connect('/:controller/:action/:id', array('controller' => 'testing4', 'id' => null), array('id' => $router->__named['ID']));
|
||||
$this->assertEqual($router->routes[0][0], '/:controller/:action/:id', "Route map error for \"/:controller/:action/:id\" with default controller and ID not required");
|
||||
$this->assertEqual($router->routes[0][1], '#^(?:\/([^\/]+))?(?:\/([^\/]+))?(?:\/([0-9]+))?[\/]*$#', "Route map error for \"/:controller/:action/:id\" with default controller and ID not required");
|
||||
$this->assertEqual($router->routes[0][2], array('controller', 'action', 'id'), "Route map error for \"/:controller/:action/:id\" with default controller");
|
||||
|
||||
$router->routes = array();
|
||||
$router->connect('/:controller/:action/:id', array('controller' => 'testing4'), array('id' => $router->__named['ID']));
|
||||
$this->assertEqual($router->routes[0][1], '#^(?:\/([^\/]+))?(?:\/([^\/]+))?(?:\/([0-9]+))[\/]*$#', "Route map error for \"/:controller/:action/:id\" with default controller and ID required");
|
||||
}
|
||||
|
||||
function testRouterIdentity() {
|
||||
$router =& Router::getInstance();
|
||||
$this->vars = get_object_vars($router);
|
||||
|
||||
$router->routes = $router->__paths = $router->__params = $router->__currentRoute = array();
|
||||
$router->__parseExtensions = false;
|
||||
$router2 = new Router();
|
||||
$this->assertEqual(get_object_vars($router), get_object_vars($router2), "Router identity crisis");
|
||||
}
|
||||
|
||||
function testUrlGeneration() {
|
||||
$router =& Router::getInstance();
|
||||
foreach ($this->vars as $var => $val) {
|
||||
$router->{$var} = $val;
|
||||
}
|
||||
$router->routes = array();
|
||||
|
||||
$router->connect('/', array('controller'=>'pages', 'action'=>'display', 'home'));
|
||||
$out = $router->url(array('controller'=>'pages', 'action'=>'display', 'home'));
|
||||
$this->assertEqual($out, '/', "Router URL generation failed: expected '/', got '{$out}'");
|
||||
|
||||
$router->connect('/pages/*', array('controller'=>'pages', 'action'=>'display'));
|
||||
$out = $router->url(array('controller'=>'pages', 'action'=>'display', 'about'));
|
||||
$expected = '/pages/about';
|
||||
$this->assertEqual($out, $expected, "Router URL generation failed: expected '{$expected}' got '{$out}'");
|
||||
|
||||
|
||||
$router->connect('/:plugin/:controller/*', array('plugin'=>'cake_plugin', 'controller'=>'posts', 'action'=>'view', '1'));
|
||||
$out = $router->url(array('plugin'=>'cake_plugin', 'controller'=>'posts', '1'));
|
||||
$expected = '/cake_plugin/posts/';
|
||||
$this->assertEqual($out, $expected, "Router URL generation failed: expected '{$expected}' got '{$out}'");
|
||||
|
||||
$router->connect('/:controller/:action/:id', array(), array('id' => '1'));
|
||||
$out = $router->url(array('controller'=>'posts', 'action'=>'view', '1'));
|
||||
$expected = '/posts/view/1';
|
||||
$this->assertEqual($out, $expected, "Router URL generation failed: expected '{$expected}' got '{$out}'");
|
||||
|
||||
$router->connect('/:controller/:id', array('action' => 'view'), array('id' => '1'));
|
||||
$out = $router->url(array('controller'=>'posts', '1'));
|
||||
$expected = '/posts/1';
|
||||
$this->assertEqual($out, $expected, "Router URL generation failed: expected '{$expected}' got '{$out}'");
|
||||
|
||||
$out = $router->url(array('controller' => 'posts', 'action'=>'index', '0'));
|
||||
$expected = '/posts/index/0';
|
||||
$this->assertEqual($out, $expected, "Router URL generation failed: expected '{$expected}' got '{$out}'");
|
||||
|
||||
}
|
||||
|
||||
function testExtensionParsingSetting() {
|
||||
if (PHP5) {
|
||||
$router = Router::getInstance();
|
||||
$router->reload();
|
||||
$this->assertFalse($router->__parseExtensions, "Router::__parseExtensions not defaulting correctly");
|
||||
|
||||
$router->parseExtensions();
|
||||
$this->assertTrue($router->__parseExtensions, "Router::parseExtensions() not enabling extension parsing");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
63
cake/tests/cases/libs/socket.test.php
Normal file
63
cake/tests/cases/libs/socket.test.php
Normal file
|
@ -0,0 +1,63 @@
|
|||
<?php
|
||||
/* SVN FILE: $Id$ */
|
||||
/**
|
||||
* Short description for file.
|
||||
*
|
||||
* Long description for file
|
||||
*
|
||||
* PHP versions 4 and 5
|
||||
*
|
||||
* CakePHP(tm) Tests <https://trac.cakephp.org/wiki/Developement/TestSuite>
|
||||
* Copyright 2005-2007, Cake Software Foundation, Inc.
|
||||
* 1785 E. Sahara Avenue, Suite 490-204
|
||||
* Las Vegas, Nevada 89104
|
||||
*
|
||||
* Licensed under The Open Group Test Suite License
|
||||
* Redistributions of files must retain the above copyright notice.
|
||||
*
|
||||
* @filesource
|
||||
* @copyright Copyright 2005-2007, Cake Software Foundation, Inc.
|
||||
* @link https://trac.cakephp.org/wiki/Developement/TestSuite CakePHP(tm) Tests
|
||||
* @package cake.tests
|
||||
* @subpackage cake.tests.cases.libs
|
||||
* @since CakePHP(tm) v 1.2.0.4206
|
||||
* @version $Revision$
|
||||
* @modifiedby $LastChangedBy$
|
||||
* @lastmodified $Date$
|
||||
* @license http://www.opensource.org/licenses/opengroup.php The Open Group Test Suite License
|
||||
*/
|
||||
require_once LIBS.'socket.php';
|
||||
/**
|
||||
* Short description for class.
|
||||
*
|
||||
* @package cake.tests
|
||||
* @subpackage cake.tests.cases.libs
|
||||
*/
|
||||
class SocketTest extends UnitTestCase {
|
||||
|
||||
function setUp() {
|
||||
$this->socket = new CakeSocket();
|
||||
}
|
||||
|
||||
function testSocketConnection() {
|
||||
$this->assertTrue($this->socket->connected, 'Socket connection error: socket not connected when it should be');
|
||||
$this->socket->disconnect();
|
||||
$this->assertFalse($this->socket->connected, 'Socket connection error: socket connected when it should not be');
|
||||
$this->socket->connect();
|
||||
$this->assertTrue($this->socket->connected, 'Socket connection error: socket not connected when it should be');
|
||||
}
|
||||
|
||||
function testSocketHost() {
|
||||
$this->assertEqual($this->socket->address(), '127.0.0.1', 'Socket address does not resolve to localhost IP (127.0.0.1)');
|
||||
$this->assertEqual($this->socket->addresses(), array('127.0.0.1'), 'Socket address group does not resolve to localhost IP (127.0.0.1)');
|
||||
$this->assertEqual($this->socket->host(), 'localhost', 'Socket host is not localhost');
|
||||
$this->assertEqual($this->socket->lastError(), null, 'Socket connection error, expected null');
|
||||
}
|
||||
|
||||
function testSocketWriting() {
|
||||
$request = "GET / HTTP/1.1\r\nConnection: close\r\n\r\n";
|
||||
$this->assertTrue($this->socket->write($request), 'Couldn\'t write to socket');
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
1242
cake/tests/cases/libs/validation.test.php
Normal file
1242
cake/tests/cases/libs/validation.test.php
Normal file
File diff suppressed because it is too large
Load diff
61
cake/tests/cases/libs/view/helpers/ajax.test.php
Normal file
61
cake/tests/cases/libs/view/helpers/ajax.test.php
Normal file
|
@ -0,0 +1,61 @@
|
|||
<?php
|
||||
/* SVN FILE: $Id$ */
|
||||
/**
|
||||
* Short description for file.
|
||||
*
|
||||
* Long description for file
|
||||
*
|
||||
* PHP versions 4 and 5
|
||||
*
|
||||
* CakePHP(tm) Tests <https://trac.cakephp.org/wiki/Developement/TestSuite>
|
||||
* Copyright 2005-2007, Cake Software Foundation, Inc.
|
||||
* 1785 E. Sahara Avenue, Suite 490-204
|
||||
* Las Vegas, Nevada 89104
|
||||
*
|
||||
* Licensed under The Open Group Test Suite License
|
||||
* Redistributions of files must retain the above copyright notice.
|
||||
*
|
||||
* @filesource
|
||||
* @copyright Copyright 2005-2007, Cake Software Foundation, Inc.
|
||||
* @link https://trac.cakephp.org/wiki/Developement/TestSuite CakePHP(tm) Tests
|
||||
* @package cake.tests
|
||||
* @subpackage cake.tests.cases.libs.view.helpers
|
||||
* @since CakePHP(tm) v 1.2.0.4206
|
||||
* @version $Revision$
|
||||
* @modifiedby $LastChangedBy$
|
||||
* @lastmodified $Date$
|
||||
* @license http://www.opensource.org/licenses/opengroup.php The Open Group Test Suite License
|
||||
*/
|
||||
require_once LIBS.'../app_helper.php';
|
||||
require_once LIBS.DS.'view'.DS.'helper.php';
|
||||
require_once LIBS.DS.'view'.DS.'helpers'.DS.'ajax.php';
|
||||
require_once LIBS.DS.'view'.DS.'helpers'.DS.'html.php';
|
||||
require_once LIBS.DS.'view'.DS.'helpers'.DS.'form.php';
|
||||
require_once LIBS.DS.'view'.DS.'helpers'.DS.'javascript.php';
|
||||
/**
|
||||
* Short description for class.
|
||||
*
|
||||
* @package cake.tests
|
||||
* @subpackage cake.tests.cases.libs.view.helpers
|
||||
*/
|
||||
class AjaxTest extends UnitTestCase {
|
||||
|
||||
function setUp() {
|
||||
$this->ajax = new AjaxHelper();
|
||||
$this->ajax->Html = new HtmlHelper();
|
||||
$this->ajax->Form = new FormHelper();
|
||||
$this->ajax->Javascript = new JavascriptHelper();
|
||||
}
|
||||
|
||||
function testDraggable() {
|
||||
$result = $this->ajax->drag('id', array('handle' => 'other_id'));
|
||||
$expected = '<script type="text/javascript">new Draggable(\'id\', {handle:\'other_id\'});</script>';
|
||||
$this->assertEqual($result, $expected, "Error generating script.aculo.us draggable object, expected '{$expected}', got '{$result}'.");
|
||||
}
|
||||
|
||||
function tearDown() {
|
||||
unset($this->ajax);
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
85
cake/tests/cases/libs/view/helpers/paginator.test.php
Normal file
85
cake/tests/cases/libs/view/helpers/paginator.test.php
Normal file
|
@ -0,0 +1,85 @@
|
|||
<?php
|
||||
/* SVN FILE: $Id$ */
|
||||
/**
|
||||
* Short description for file.
|
||||
*
|
||||
* Long description for file
|
||||
*
|
||||
* PHP versions 4 and 5
|
||||
*
|
||||
* CakePHP(tm) Tests <https://trac.cakephp.org/wiki/Developement/TestSuite>
|
||||
* Copyright 2005-2007, Cake Software Foundation, Inc.
|
||||
* 1785 E. Sahara Avenue, Suite 490-204
|
||||
* Las Vegas, Nevada 89104
|
||||
*
|
||||
* Licensed under The Open Group Test Suite License
|
||||
* Redistributions of files must retain the above copyright notice.
|
||||
*
|
||||
* @filesource
|
||||
* @copyright Copyright 2005-2007, Cake Software Foundation, Inc.
|
||||
* @link https://trac.cakephp.org/wiki/Developement/TestSuite CakePHP(tm) Tests
|
||||
* @package cake.tests
|
||||
* @subpackage cake.tests.cases.libs.view.helpers
|
||||
* @since CakePHP(tm) v 1.2.0.4206
|
||||
* @version $Revision$
|
||||
* @modifiedby $LastChangedBy$
|
||||
* @lastmodified $Date$
|
||||
* @license http://www.opensource.org/licenses/opengroup.php The Open Group Test Suite License
|
||||
*/
|
||||
require_once LIBS.'../app_helper.php';
|
||||
require_once LIBS.DS.'view'.DS.'helper.php';
|
||||
require_once LIBS.DS.'view'.DS.'helpers'.DS.'html.php';
|
||||
require_once LIBS.DS.'view'.DS.'helpers'.DS.'ajax.php';
|
||||
require_once LIBS.DS.'view'.DS.'helpers'.DS.'paginator.php';
|
||||
/**
|
||||
* Short description for class.
|
||||
*
|
||||
* @package cake.tests
|
||||
* @subpackage cake.tests.cases.libs.view.helpers
|
||||
*/
|
||||
class PaginatorTest extends UnitTestCase {
|
||||
|
||||
function setUp() {
|
||||
$this->paginator = new PaginatorHelper();
|
||||
$this->paginator->params['paging'] = array(
|
||||
'Article' => array(
|
||||
'current' => 9,
|
||||
'count' => 62,
|
||||
'prevPage' => false,
|
||||
'nextPage' => true,
|
||||
'pageCount' => 7,
|
||||
'defaults' => array(
|
||||
'order' => 'Article.date DESC',
|
||||
'limit' => 9,
|
||||
'conditions' => array()
|
||||
)
|
||||
),
|
||||
|
||||
'options' => array(
|
||||
'order' => 'Article.date DESC',
|
||||
'limit' => 9,
|
||||
'page' => 1
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
function testHasPrevious() {
|
||||
$this->assertIdentical($this->paginator->hasPrev(), false);
|
||||
$this->paginator->params['paging']['Article']['prevPage'] = true;
|
||||
$this->assertIdentical($this->paginator->hasPrev(), true);
|
||||
$this->paginator->params['paging']['Article']['prevPage'] = false;
|
||||
}
|
||||
|
||||
function testHasNext() {
|
||||
$this->assertIdentical($this->paginator->hasNext(), true);
|
||||
$this->paginator->params['paging']['Article']['nextPage'] = false;
|
||||
$this->assertIdentical($this->paginator->hasNext(), false);
|
||||
$this->paginator->params['paging']['Article']['nextPage'] = true;
|
||||
}
|
||||
|
||||
function tearDown() {
|
||||
unset($this->paginator);
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
42
cake/tests/groups/all_tests.group.php
Normal file
42
cake/tests/groups/all_tests.group.php
Normal file
|
@ -0,0 +1,42 @@
|
|||
<?php
|
||||
/* SVN FILE: $Id$ */
|
||||
/**
|
||||
* Short description for file.
|
||||
*
|
||||
* Long description for file
|
||||
*
|
||||
* PHP versions 4 and 5
|
||||
*
|
||||
* CakePHP(tm) Tests <https://trac.cakephp.org/wiki/Developement/TestSuite>
|
||||
* Copyright 2005-2007, Cake Software Foundation, Inc.
|
||||
* 1785 E. Sahara Avenue, Suite 490-204
|
||||
* Las Vegas, Nevada 89104
|
||||
*
|
||||
* Licensed under The Open Group Test Suite License
|
||||
* Redistributions of files must retain the above copyright notice.
|
||||
*
|
||||
* @filesource
|
||||
* @copyright Copyright 2005-2007, Cake Software Foundation, Inc.
|
||||
* @link https://trac.cakephp.org/wiki/Developement/TestSuite CakePHP(tm) Tests
|
||||
* @package cake.tests
|
||||
* @subpackage cake.tests.groups
|
||||
* @since CakePHP(tm) v 1.2.0.4206
|
||||
* @version $Revision$
|
||||
* @modifiedby $LastChangedBy$
|
||||
* @lastmodified $Date$
|
||||
* @license http://www.opensource.org/licenses/opengroup.php The Open Group Test Suite License
|
||||
*/
|
||||
/**
|
||||
* Short description for class.
|
||||
*
|
||||
* @package cake.tests
|
||||
* @subpackage cake.tests.groups
|
||||
*/
|
||||
class AllTests extends GroupTest {
|
||||
|
||||
function AllTests() {
|
||||
TestManager::addTestCasesFromDirectory($this, LIB_TESTS);
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
43
cake/tests/groups/lib.group.php
Normal file
43
cake/tests/groups/lib.group.php
Normal file
|
@ -0,0 +1,43 @@
|
|||
<?php
|
||||
/* SVN FILE: $Id$ */
|
||||
/**
|
||||
* Short description for file.
|
||||
*
|
||||
* Long description for file
|
||||
*
|
||||
* PHP versions 4 and 5
|
||||
*
|
||||
* CakePHP(tm) Tests <https://trac.cakephp.org/wiki/Developement/TestSuite>
|
||||
* Copyright 2005-2007, Cake Software Foundation, Inc.
|
||||
* 1785 E. Sahara Avenue, Suite 490-204
|
||||
* Las Vegas, Nevada 89104
|
||||
*
|
||||
* Licensed under The Open Group Test Suite License
|
||||
* Redistributions of files must retain the above copyright notice.
|
||||
*
|
||||
* @filesource
|
||||
* @copyright Copyright 2005-2007, Cake Software Foundation, Inc.
|
||||
* @link https://trac.cakephp.org/wiki/Developement/TestSuite CakePHP(tm) Tests
|
||||
* @package cake.tests
|
||||
* @subpackage cake.tests.groups
|
||||
* @since CakePHP(tm) v 1.2.0.4206
|
||||
* @version $Revision$
|
||||
* @modifiedby $LastChangedBy$
|
||||
* @lastmodified $Date$
|
||||
* @license http://www.opensource.org/licenses/opengroup.php The Open Group Test Suite License
|
||||
*/
|
||||
/** AllCoreLibGroupTest
|
||||
*
|
||||
* This test group will run all test in the cases/libs directory.
|
||||
*
|
||||
* @package cake.tests
|
||||
* @subpackage cake.tests.groups
|
||||
*/
|
||||
class AllCoreLibGroupTest extends GroupTest {
|
||||
|
||||
function AllCoreLibGroupTest() {
|
||||
$this->GroupTest('All cake/libs/*');
|
||||
TestManager::addTestCasesFromDirectory($this, CORE_TEST_CASES . DS . 'libs');
|
||||
}
|
||||
}
|
||||
?>
|
42
cake/tests/groups/lib_controller.group.php
Normal file
42
cake/tests/groups/lib_controller.group.php
Normal file
|
@ -0,0 +1,42 @@
|
|||
<?php
|
||||
/* SVN FILE: $Id$ */
|
||||
/**
|
||||
* Short description for file.
|
||||
*
|
||||
* Long description for file
|
||||
*
|
||||
* PHP versions 4 and 5
|
||||
*
|
||||
* CakePHP(tm) Tests <https://trac.cakephp.org/wiki/Developement/TestSuite>
|
||||
* Copyright 2005-2007, Cake Software Foundation, Inc.
|
||||
* 1785 E. Sahara Avenue, Suite 490-204
|
||||
* Las Vegas, Nevada 89104
|
||||
*
|
||||
* Licensed under The Open Group Test Suite License
|
||||
* Redistributions of files must retain the above copyright notice.
|
||||
*
|
||||
* @filesource
|
||||
* @copyright Copyright 2005-2007, Cake Software Foundation, Inc.
|
||||
* @link https://trac.cakephp.org/wiki/Developement/TestSuite CakePHP(tm) Tests
|
||||
* @package cake.tests
|
||||
* @subpackage cake.tests.groups
|
||||
* @since CakePHP(tm) v 1.2.0.4206
|
||||
* @version $Revision$
|
||||
* @modifiedby $LastChangedBy$
|
||||
* @lastmodified $Date$
|
||||
* @license http://www.opensource.org/licenses/opengroup.php The Open Group Test Suite License
|
||||
*/
|
||||
/**
|
||||
* Short description for class.
|
||||
*
|
||||
* @package cake.tests
|
||||
* @subpackage cake.tests.groups
|
||||
*/
|
||||
class LibControllerGroupTest extends GroupTest {
|
||||
|
||||
function LibControllerGroupTest() {
|
||||
$this->GroupTest('All cake/libs/controller/*');
|
||||
TestManager::addTestCasesFromDirectory($this, CORE_TEST_CASES . DS . 'libs' . DS . 'controller');
|
||||
}
|
||||
}
|
||||
?>
|
Loading…
Add table
Reference in a new issue