diff --git a/cake/tests/cases/dispatcher.test.php b/cake/tests/cases/dispatcher.test.php
new file mode 100644
index 000000000..a4aad97fc
--- /dev/null
+++ b/cake/tests/cases/dispatcher.test.php
@@ -0,0 +1,103 @@
+
+ * 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', "
Parsed URL shows controller is {$test['controller']} expected testcontroller" );
+ $this->assertIdentical($test['action'], 'testaction', "
Parsed URL shows action is {$test['action']} expected testaction" );
+ $this->assertIdentical($test['pass'][0], 'params1', "
Parsed URL shows action is {$test['pass'][0]} expected params1" );
+ $this->assertIdentical($test['pass'][1], 'params2', "
Parsed URL shows action is {$test['pass'][1]} expected params2" );
+ $this->assertIdentical($test['pass'][2], 'params3', "
Parsed URL shows action is {$test['pass'][2]} expected params3" );
+ $this->assertFalse(!empty($test['form']), "
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', "
Parsed URL shows controller is {$test['controller']} expected testcontroller" );
+ $this->assertIdentical($test['action'], 'testaction', "
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" );
+ }
+}
+?>
\ No newline at end of file
diff --git a/cake/tests/cases/libs/controller/components/dbacl/models/aclnode.test.php b/cake/tests/cases/libs/controller/components/dbacl/models/aclnode.test.php
new file mode 100644
index 000000000..5761de180
--- /dev/null
+++ b/cake/tests/cases/libs/controller/components/dbacl/models/aclnode.test.php
@@ -0,0 +1,73 @@
+
+ * 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');
+ }
+}
+
+?>
\ No newline at end of file
diff --git a/cake/tests/cases/libs/model/datasources/dbo_source.test.php b/cake/tests/cases/libs/model/datasources/dbo_source.test.php
new file mode 100644
index 000000000..a6a932c68
--- /dev/null
+++ b/cake/tests/cases/libs/model/datasources/dbo_source.test.php
@@ -0,0 +1,268 @@
+
+ * 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)
+ }
+}
+
+?>
\ No newline at end of file
diff --git a/cake/tests/cases/libs/model/model.test.php b/cake/tests/cases/libs/model/model.test.php
new file mode 100644
index 000000000..84e4da8ea
--- /dev/null
+++ b/cake/tests/cases/libs/model/model.test.php
@@ -0,0 +1,54 @@
+
+ * 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}.");
+ }
+}
+
+?>
\ No newline at end of file
diff --git a/cake/tests/cases/libs/router.test.php b/cake/tests/cases/libs/router.test.php
new file mode 100644
index 000000000..c60456c66
--- /dev/null
+++ b/cake/tests/cases/libs/router.test.php
@@ -0,0 +1,146 @@
+
+ * 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");
+ }
+ }
+}
+
+?>
diff --git a/cake/tests/cases/libs/socket.test.php b/cake/tests/cases/libs/socket.test.php
new file mode 100644
index 000000000..29e87ae13
--- /dev/null
+++ b/cake/tests/cases/libs/socket.test.php
@@ -0,0 +1,63 @@
+
+ * 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');
+ }
+}
+
+?>
\ No newline at end of file
diff --git a/cake/tests/cases/libs/validation.test.php b/cake/tests/cases/libs/validation.test.php
new file mode 100644
index 000000000..eacd94239
--- /dev/null
+++ b/cake/tests/cases/libs/validation.test.php
@@ -0,0 +1,1242 @@
+
+ * 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
+ */
+uses('Validation');
+/**
+ * Short description for class.
+ *
+ * @package cake.tests
+ * @subpackage cake.tests.cases.libs
+ */
+class ValidationTestCase extends UnitTestCase {
+
+ function testAlphaNumeric(){
+ $validation = new Validation();
+
+ $this->assertTrue($validation->alphaNumeric('frferrf'), 'Expected only letters');
+ $this->assertTrue($validation->alphaNumeric('12234'), 'Expected only integer');
+ $this->assertTrue($validation->alphaNumeric('1w2e2r3t4y'), 'Expected letters and integers');
+ $this->assertFalse($validation->alphaNumeric('12 234'), 'Expected integers mixed with spaces');
+ $this->assertFalse($validation->alphaNumeric('dfd 234'), 'Expected letters and integers with space');
+ $this->assertFalse($validation->alphaNumeric("\n"), 'Expected new line');
+ $this->assertFalse($validation->alphaNumeric("\t"), 'Expected tab');
+ $this->assertFalse($validation->alphaNumeric("\r"), 'Expected new line');
+ $this->assertFalse($validation->alphaNumeric(' '), 'Expected new space');
+ }
+
+ function testAlphaNumericPassedAsArray(){
+ $validation = new Validation();
+
+ $this->assertTrue($validation->alphaNumeric(array('check' => 'frferrf'), 'Expected only letters'));
+ $this->assertTrue($validation->alphaNumeric(array('check' => '12234'), 'Expected only integer'));
+ $this->assertTrue($validation->alphaNumeric(array('check' => '1w2e2r3t4y'), 'Expected letters and integers'));
+ $this->assertFalse($validation->alphaNumeric(array('check' => '12 234'), 'Expected integers mixed with spaces'));
+ $this->assertFalse($validation->alphaNumeric(array('check' => 'dfd 234'), 'Expected letters and integers with space'));
+ $this->assertFalse($validation->alphaNumeric(array('check' => "\n"), 'Expected new line'));
+ $this->assertFalse($validation->alphaNumeric(array('check' => "\t"), 'Expected tab'));
+ $this->assertFalse($validation->alphaNumeric(array('check' => "\r"), 'Expected new line'));
+ $this->assertFalse($validation->alphaNumeric(array('check' => ' '), 'Expected space'));
+ }
+
+ function testBetween(){
+ $validation = new Validation();
+ $this->assertTrue($validation->between('abcdefg', 1, 7), 'Expected string to be between 1 and 7 chars, 7 sent');
+ $this->assertTrue($validation->between('', 0, 7), 'Expected either empty string or up to 7 chars, empty string sent');
+ $this->assertFalse($validation->between('abcdefg', 1, 6), 'Expected 1 and 6 chars, 7 sent');
+ }
+
+ function testBlank(){
+ $validation = new Validation();
+ $this->assertTrue($validation->blank(''), 'Expected empty string');
+ $this->assertTrue($validation->blank(' '), 'Expected space');
+ $this->assertTrue($validation->blank("\n"), 'Expected new line');
+ $this->assertTrue($validation->blank("\t"), 'Expected tab');
+ $this->assertTrue($validation->blank("\r"), 'Expected new line');
+ $this->assertFalse($validation->blank(' Blank'), 'Expected empty string, Blank was sent');
+ $this->assertFalse($validation->blank('Blank'), 'Expected empty string, Blank was sent');
+ }
+
+ function testBlankAsArray(){
+ $validation = new Validation();
+ $this->assertTrue($validation->blank(array('check' => ''), 'Expected empty string'));
+ $this->assertTrue($validation->blank(array('check' => ' '), 'Expected space'));
+ $this->assertTrue($validation->blank(array('check' => "\n"), 'Expected new line'));
+ $this->assertTrue($validation->blank(array('check' => "\t"), 'Expected tab'));
+ $this->assertTrue($validation->blank(array('check' => "\r"), 'Expected new line'));
+ $this->assertFalse($validation->blank(array('check' => ' Blank'), 'Expected empty string, Blank was sent'));
+ $this->assertFalse($validation->blank(array('check' => 'Blank'), 'Expected empty string, Blank was sent'));
+ }
+
+ function testcc(){
+ $validation = new Validation();
+ //American Express
+ $this->assertTrue($validation->cc('370482756063980', array('amex')), 'Expected American Express');
+ $this->assertTrue($validation->cc('349106433773483', array('amex')), 'Expected American Express');
+ $this->assertTrue($validation->cc('344671486204764', array('amex')), 'Expected American Express');
+ $this->assertTrue($validation->cc('344042544509943', array('amex')), 'Expected American Express');
+ $this->assertTrue($validation->cc('377147515754475', array('amex')), 'Expected American Express');
+ $this->assertTrue($validation->cc('375239372816422', array('amex')), 'Expected American Express');
+ $this->assertTrue($validation->cc('376294341957707', array('amex')), 'Expected American Express');
+ $this->assertTrue($validation->cc('341779292230411', array('amex')), 'Expected American Express');
+ $this->assertTrue($validation->cc('341646919853372', array('amex')), 'Expected American Express');
+ $this->assertTrue($validation->cc('348498616319346', array('amex')), 'Expected American Express');
+ //BankCard
+ $this->assertTrue($validation->cc('5610745867413420', array('bankcard')), 'Expected BankCard');
+ $this->assertTrue($validation->cc('5610376649499352', array('bankcard')), 'Expected BankCard');
+ $this->assertTrue($validation->cc('5610091936000694', array('bankcard')), 'Expected BankCard');
+ $this->assertTrue($validation->cc('5602248780118788', array('bankcard')), 'Expected BankCard');
+ $this->assertTrue($validation->cc('5610631567676765', array('bankcard')), 'Expected BankCard');
+ $this->assertTrue($validation->cc('5602238211270795', array('bankcard')), 'Expected BankCard');
+ $this->assertTrue($validation->cc('5610173951215470', array('bankcard')), 'Expected BankCard');
+ $this->assertTrue($validation->cc('5610139705753702', array('bankcard')), 'Expected BankCard');
+ $this->assertTrue($validation->cc('5602226032150551', array('bankcard')), 'Expected BankCard');
+ $this->assertTrue($validation->cc('5602223993735777', array('bankcard')), 'Expected BankCard');
+ //Diners Club 14
+ $this->assertTrue($validation->cc('30155483651028', array('diners')), 'Expected Diners Club 14 digit');
+ $this->assertTrue($validation->cc('36371312803821', array('diners')), 'Expected Diners Club 14 digit');
+ $this->assertTrue($validation->cc('38801277489875', array('diners')), 'Expected Diners Club 14 digit');
+ $this->assertTrue($validation->cc('30348560464296', array('diners')), 'Expected Diners Club 14 digit');
+ $this->assertTrue($validation->cc('30349040317708', array('diners')), 'Expected Diners Club 14 digit');
+ $this->assertTrue($validation->cc('36567413559978', array('diners')), 'Expected Diners Club 14 digit');
+ $this->assertTrue($validation->cc('36051554732702', array('diners')), 'Expected Diners Club 14 digit');
+ $this->assertTrue($validation->cc('30391842198191', array('diners')), 'Expected Diners Club 14 digit');
+ $this->assertTrue($validation->cc('30172682197745', array('diners')), 'Expected Diners Club 14 digit');
+ $this->assertTrue($validation->cc('30162056566641', array('diners')), 'Expected Diners Club 14 digit');
+ $this->assertTrue($validation->cc('30085066927745', array('diners')), 'Expected Diners Club 14 digit');
+ $this->assertTrue($validation->cc('36519025221976', array('diners')), 'Expected Diners Club 14 digit');
+ $this->assertTrue($validation->cc('30372679371044', array('diners')), 'Expected Diners Club 14 digit');
+ $this->assertTrue($validation->cc('38913939150124', array('diners')), 'Expected Diners Club 14 digit');
+ $this->assertTrue($validation->cc('36852899094637', array('diners')), 'Expected Diners Club 14 digit');
+ $this->assertTrue($validation->cc('30138041971120', array('diners')), 'Expected Diners Club 14 digit');
+ $this->assertTrue($validation->cc('36184047836838', array('diners')), 'Expected Diners Club 14 digit');
+ $this->assertTrue($validation->cc('30057460264462', array('diners')), 'Expected Diners Club 14 digit');
+ $this->assertTrue($validation->cc('38980165212050', array('diners')), 'Expected Diners Club 14 digit');
+ $this->assertTrue($validation->cc('30356516881240', array('diners')), 'Expected Diners Club 14 digit');
+ $this->assertTrue($validation->cc('38744810033182', array('diners')), 'Expected Diners Club 14 digit');
+ $this->assertTrue($validation->cc('30173638706621', array('diners')), 'Expected Diners Club 14 digit');
+ $this->assertTrue($validation->cc('30158334709185', array('diners')), 'Expected Diners Club 14 digit');
+ $this->assertTrue($validation->cc('30195413721186', array('diners')), 'Expected Diners Club 14 digit');
+ $this->assertTrue($validation->cc('38863347694793', array('diners')), 'Expected Diners Club 14 digit');
+ $this->assertTrue($validation->cc('30275627009113', array('diners')), 'Expected Diners Club 14 digit');
+ $this->assertTrue($validation->cc('30242860404971', array('diners')), 'Expected Diners Club 14 digit');
+ $this->assertTrue($validation->cc('30081877595151', array('diners')), 'Expected Diners Club 14 digit');
+ $this->assertTrue($validation->cc('38053196067461', array('diners')), 'Expected Diners Club 14 digit');
+ $this->assertTrue($validation->cc('36520379984870', array('diners')), 'Expected Diners Club 14 digit');
+ //2004 MasterCard/Diners Club Alliance International 14
+ $this->assertTrue($validation->cc('36747701998969', array('diners')), 'Expected MasterCard/Diners Club International 14 digit');
+ $this->assertTrue($validation->cc('36427861123159', array('diners')), 'Expected MasterCard/Diners Club International 14 digit');
+ $this->assertTrue($validation->cc('36150537602386', array('diners')), 'Expected MasterCard/Diners Club International 14 digit');
+ $this->assertTrue($validation->cc('36582388820610', array('diners')), 'Expected MasterCard/Diners Club International 14 digit');
+ $this->assertTrue($validation->cc('36729045250216', array('diners')), 'Expected MasterCard/Diners Club International 14 digit');
+ //2004 MasterCard/Diners Club Alliance US & Canada 16
+ $this->assertTrue($validation->cc('5597511346169950', array('diners')), 'Expected MasterCard/Diners Club US & Canada 16 digit');
+ $this->assertTrue($validation->cc('5526443162217562', array('diners')), 'Expected MasterCard/Diners Club US & Canada 16 digit');
+ $this->assertTrue($validation->cc('5577265786122391', array('diners')), 'Expected MasterCard/Diners Club US & Canada 16 digit');
+ $this->assertTrue($validation->cc('5534061404676989', array('diners')), 'Expected MasterCard/Diners Club US & Canada 16 digit');
+ $this->assertTrue($validation->cc('5545313588374502', array('diners')), 'Expected MasterCard/Diners Club US & Canada 16 digit');
+ //Discover
+ $this->assertTrue($validation->cc('6011802876467237', array('disc')), 'Expected Discover');
+ $this->assertTrue($validation->cc('6506432777720955', array('disc')), 'Expected Discover');
+ $this->assertTrue($validation->cc('6011126265283942', array('disc')), 'Expected Discover');
+ $this->assertTrue($validation->cc('6502187151579252', array('disc')), 'Expected Discover');
+ $this->assertTrue($validation->cc('6506600836002298', array('disc')), 'Expected Discover');
+ $this->assertTrue($validation->cc('6504376463615189', array('disc')), 'Expected Discover');
+ $this->assertTrue($validation->cc('6011440907005377', array('disc')), 'Expected Discover');
+ $this->assertTrue($validation->cc('6509735979634270', array('disc')), 'Expected Discover');
+ $this->assertTrue($validation->cc('6011422366775856', array('disc')), 'Expected Discover');
+ $this->assertTrue($validation->cc('6500976374623323', array('disc')), 'Expected Discover');
+ //enRoute
+ $this->assertTrue($validation->cc('201496944158937', array('enroute')), 'Expected enRoute');
+ $this->assertTrue($validation->cc('214945833739665', array('enroute')), 'Expected enRoute');
+ $this->assertTrue($validation->cc('214982692491187', array('enroute')), 'Expected enRoute');
+ $this->assertTrue($validation->cc('214901395949424', array('enroute')), 'Expected enRoute');
+ $this->assertTrue($validation->cc('201480676269187', array('enroute')), 'Expected enRoute');
+ $this->assertTrue($validation->cc('214911922887807', array('enroute')), 'Expected enRoute');
+ $this->assertTrue($validation->cc('201485025457250', array('enroute')), 'Expected enRoute');
+ $this->assertTrue($validation->cc('201402662758866', array('enroute')), 'Expected enRoute');
+ $this->assertTrue($validation->cc('214981579370225', array('enroute')), 'Expected enRoute');
+ $this->assertTrue($validation->cc('201447595859877', array('enroute')), 'Expected enRoute');
+ //JCB 15 digit
+ $this->assertTrue($validation->cc('210034762247893', array('jcb')), 'Expected JCB 15 digit');
+ $this->assertTrue($validation->cc('180078671678892', array('jcb')), 'Expected JCB 15 digit');
+ $this->assertTrue($validation->cc('180010559353736', array('jcb')), 'Expected JCB 15 digit');
+ $this->assertTrue($validation->cc('210095474464258', array('jcb')), 'Expected JCB 15 digit');
+ $this->assertTrue($validation->cc('210006675562188', array('jcb')), 'Expected JCB 15 digit');
+ $this->assertTrue($validation->cc('210063299662662', array('jcb')), 'Expected JCB 15 digit');
+ $this->assertTrue($validation->cc('180032506857825', array('jcb')), 'Expected JCB 15 digit');
+ $this->assertTrue($validation->cc('210057919192738', array('jcb')), 'Expected JCB 15 digit');
+ $this->assertTrue($validation->cc('180031358949367', array('jcb')), 'Expected JCB 15 digit');
+ $this->assertTrue($validation->cc('180033802147846', array('jcb')), 'Expected JCB 15 digit');
+ //JCB 16 digit
+ $this->assertTrue($validation->cc('3096806857839939', array('jcb')), 'Expected JCB 16 digit');
+ $this->assertTrue($validation->cc('3158699503187091', array('jcb')), 'Expected JCB 16 digit');
+ $this->assertTrue($validation->cc('3112549607186579', array('jcb')), 'Expected JCB 16 digit');
+ $this->assertTrue($validation->cc('3112332922425604', array('jcb')), 'Expected JCB 16 digit');
+ $this->assertTrue($validation->cc('3112001541159239', array('jcb')), 'Expected JCB 16 digit');
+ $this->assertTrue($validation->cc('3112162495317841', array('jcb')), 'Expected JCB 16 digit');
+ $this->assertTrue($validation->cc('3337562627732768', array('jcb')), 'Expected JCB 16 digit');
+ $this->assertTrue($validation->cc('3337107161330775', array('jcb')), 'Expected JCB 16 digit');
+ $this->assertTrue($validation->cc('3528053736003621', array('jcb')), 'Expected JCB 16 digit');
+ $this->assertTrue($validation->cc('3528915255020360', array('jcb')), 'Expected JCB 16 digit');
+ $this->assertTrue($validation->cc('3096786059660921', array('jcb')), 'Expected JCB 16 digit');
+ $this->assertTrue($validation->cc('3528264799292320', array('jcb')), 'Expected JCB 16 digit');
+ $this->assertTrue($validation->cc('3096469164130136', array('jcb')), 'Expected JCB 16 digit');
+ $this->assertTrue($validation->cc('3112127443822853', array('jcb')), 'Expected JCB 16 digit');
+ $this->assertTrue($validation->cc('3096849995802328', array('jcb')), 'Expected JCB 16 digit');
+ $this->assertTrue($validation->cc('3528090735127407', array('jcb')), 'Expected JCB 16 digit');
+ $this->assertTrue($validation->cc('3112101006819234', array('jcb')), 'Expected JCB 16 digit');
+ $this->assertTrue($validation->cc('3337444428040784', array('jcb')), 'Expected JCB 16 digit');
+ $this->assertTrue($validation->cc('3088043154151061', array('jcb')), 'Expected JCB 16 digit');
+ $this->assertTrue($validation->cc('3088295969414866', array('jcb')), 'Expected JCB 16 digit');
+ $this->assertTrue($validation->cc('3158748843158575', array('jcb')), 'Expected JCB 16 digit');
+ $this->assertTrue($validation->cc('3158709206148538', array('jcb')), 'Expected JCB 16 digit');
+ $this->assertTrue($validation->cc('3158365159575324', array('jcb')), 'Expected JCB 16 digit');
+ $this->assertTrue($validation->cc('3158671691305165', array('jcb')), 'Expected JCB 16 digit');
+ $this->assertTrue($validation->cc('3528523028771093', array('jcb')), 'Expected JCB 16 digit');
+ $this->assertTrue($validation->cc('3096057126267870', array('jcb')), 'Expected JCB 16 digit');
+ $this->assertTrue($validation->cc('3158514047166834', array('jcb')), 'Expected JCB 16 digit');
+ $this->assertTrue($validation->cc('3528274546125962', array('jcb')), 'Expected JCB 16 digit');
+ $this->assertTrue($validation->cc('3528890967705733', array('jcb')), 'Expected JCB 16 digit');
+ $this->assertTrue($validation->cc('3337198811307545', array('jcb')), 'Expected JCB 16 digit');
+ //Maestro (debit card)
+ $this->assertTrue($validation->cc('5020147409985219', array('maestro')), 'Expected Maestro (debit card)');
+ $this->assertTrue($validation->cc('5020931809905616', array('maestro')), 'Expected Maestro (debit card)');
+ $this->assertTrue($validation->cc('5020412965470224', array('maestro')), 'Expected Maestro (debit card)');
+ $this->assertTrue($validation->cc('5020129740944022', array('maestro')), 'Expected Maestro (debit card)');
+ $this->assertTrue($validation->cc('5020024696747943', array('maestro')), 'Expected Maestro (debit card)');
+ $this->assertTrue($validation->cc('5020581514636509', array('maestro')), 'Expected Maestro (debit card)');
+ $this->assertTrue($validation->cc('5020695008411987', array('maestro')), 'Expected Maestro (debit card)');
+ $this->assertTrue($validation->cc('5020565359718977', array('maestro')), 'Expected Maestro (debit card)');
+ $this->assertTrue($validation->cc('6339931536544062', array('maestro')), 'Expected Maestro (debit card)');
+ $this->assertTrue($validation->cc('6465028615704406', array('maestro')), 'Expected Maestro (debit card)');
+ //Mastercard
+ $this->assertTrue($validation->cc('5580424361774366', array('mc')), 'Expected Mastercard)');
+ $this->assertTrue($validation->cc('5589563059318282', array('mc')), 'Expected Mastercard)');
+ $this->assertTrue($validation->cc('5387558333690047', array('mc')), 'Expected Mastercard)');
+ $this->assertTrue($validation->cc('5163919215247175', array('mc')), 'Expected Mastercard)');
+ $this->assertTrue($validation->cc('5386742685055055', array('mc')), 'Expected Mastercard)');
+ $this->assertTrue($validation->cc('5102303335960674', array('mc')), 'Expected Mastercard)');
+ $this->assertTrue($validation->cc('5526543403964565', array('mc')), 'Expected Mastercard)');
+ $this->assertTrue($validation->cc('5538725892618432', array('mc')), 'Expected Mastercard)');
+ $this->assertTrue($validation->cc('5119543573129778', array('mc')), 'Expected Mastercard)');
+ $this->assertTrue($validation->cc('5391174753915767', array('mc')), 'Expected Mastercard)');
+ $this->assertTrue($validation->cc('5510994113980714', array('mc')), 'Expected Mastercard)');
+ $this->assertTrue($validation->cc('5183720260418091', array('mc')), 'Expected Mastercard)');
+ $this->assertTrue($validation->cc('5488082196086704', array('mc')), 'Expected Mastercard)');
+ $this->assertTrue($validation->cc('5484645164161834', array('mc')), 'Expected Mastercard)');
+ $this->assertTrue($validation->cc('5171254350337031', array('mc')), 'Expected Mastercard)');
+ $this->assertTrue($validation->cc('5526987528136452', array('mc')), 'Expected Mastercard)');
+ $this->assertTrue($validation->cc('5504148941409358', array('mc')), 'Expected Mastercard)');
+ $this->assertTrue($validation->cc('5240793507243615', array('mc')), 'Expected Mastercard)');
+ $this->assertTrue($validation->cc('5162114693017107', array('mc')), 'Expected Mastercard)');
+ $this->assertTrue($validation->cc('5163104807404753', array('mc')), 'Expected Mastercard)');
+ $this->assertTrue($validation->cc('5590136167248365', array('mc')), 'Expected Mastercard)');
+ $this->assertTrue($validation->cc('5565816281038948', array('mc')), 'Expected Mastercard)');
+ $this->assertTrue($validation->cc('5467639122779531', array('mc')), 'Expected Mastercard)');
+ $this->assertTrue($validation->cc('5297350261550024', array('mc')), 'Expected Mastercard)');
+ $this->assertTrue($validation->cc('5162739131368058', array('mc')), 'Expected Mastercard)');
+ //Solo 16
+ $this->assertTrue($validation->cc('6767432107064987', array('solo')), 'Expected Solo 16 digit');
+ $this->assertTrue($validation->cc('6334667758225411', array('solo')), 'Expected Solo 16 digit');
+ $this->assertTrue($validation->cc('6767037421954068', array('solo')), 'Expected Solo 16 digit');
+ $this->assertTrue($validation->cc('6767823306394854', array('solo')), 'Expected Solo 16 digit');
+ $this->assertTrue($validation->cc('6334768185398134', array('solo')), 'Expected Solo 16 digit');
+ $this->assertTrue($validation->cc('6767286729498589', array('solo')), 'Expected Solo 16 digit');
+ $this->assertTrue($validation->cc('6334972104431261', array('solo')), 'Expected Solo 16 digit');
+ $this->assertTrue($validation->cc('6334843427400616', array('solo')), 'Expected Solo 16 digit');
+ $this->assertTrue($validation->cc('6767493947881311', array('solo')), 'Expected Solo 16 digit');
+ $this->assertTrue($validation->cc('6767194235798817', array('solo')), 'Expected Solo 16 digit');
+ //Solo 18
+ $this->assertTrue($validation->cc('676714834398858593', array('solo')), 'Expected Solo 18 digit');
+ $this->assertTrue($validation->cc('676751666435130857', array('solo')), 'Expected Solo 18 digit');
+ $this->assertTrue($validation->cc('676781908573924236', array('solo')), 'Expected Solo 18 digit');
+ $this->assertTrue($validation->cc('633488724644003240', array('solo')), 'Expected Solo 18 digit');
+ $this->assertTrue($validation->cc('676732252338067316', array('solo')), 'Expected Solo 18 digit');
+ $this->assertTrue($validation->cc('676747520084495821', array('solo')), 'Expected Solo 18 digit');
+ $this->assertTrue($validation->cc('633465488901381957', array('solo')), 'Expected Solo 18 digit');
+ $this->assertTrue($validation->cc('633487484858610484', array('solo')), 'Expected Solo 18 digit');
+ $this->assertTrue($validation->cc('633453764680740694', array('solo')), 'Expected Solo 18 digit');
+ $this->assertTrue($validation->cc('676768613295414451', array('solo')), 'Expected Solo 18 digit');
+ //Solo 19
+ $this->assertTrue($validation->cc('6767838565218340113', array('solo')), 'Expected Solo 19 digit');
+ $this->assertTrue($validation->cc('6767760119829705181', array('solo')), 'Expected Solo 19 digit');
+ $this->assertTrue($validation->cc('6767265917091593668', array('solo')), 'Expected Solo 19 digit');
+ $this->assertTrue($validation->cc('6767938856947440111', array('solo')), 'Expected Solo 19 digit');
+ $this->assertTrue($validation->cc('6767501945697390076', array('solo')), 'Expected Solo 19 digit');
+ $this->assertTrue($validation->cc('6334902868716257379', array('solo')), 'Expected Solo 19 digit');
+ $this->assertTrue($validation->cc('6334922127686425532', array('solo')), 'Expected Solo 19 digit');
+ $this->assertTrue($validation->cc('6334933119080706440', array('solo')), 'Expected Solo 19 digit');
+ $this->assertTrue($validation->cc('6334647959628261714', array('solo')), 'Expected Solo 19 digit');
+ $this->assertTrue($validation->cc('6334527312384101382', array('solo')), 'Expected Solo 19 digit');
+ //Switch 16
+ $this->assertTrue($validation->cc('5641829171515733', array('switch')), 'Expected Switch 16 digit');
+ $this->assertTrue($validation->cc('5641824852820809', array('switch')), 'Expected Switch 16 digit');
+ $this->assertTrue($validation->cc('6759129648956909', array('switch')), 'Expected Switch 16 digit');
+ $this->assertTrue($validation->cc('6759626072268156', array('switch')), 'Expected Switch 16 digit');
+ $this->assertTrue($validation->cc('5641822698388957', array('switch')), 'Expected Switch 16 digit');
+ $this->assertTrue($validation->cc('5641827123105470', array('switch')), 'Expected Switch 16 digit');
+ $this->assertTrue($validation->cc('5641823755819553', array('switch')), 'Expected Switch 16 digit');
+ $this->assertTrue($validation->cc('5641821939587682', array('switch')), 'Expected Switch 16 digit');
+ $this->assertTrue($validation->cc('4936097148079186', array('switch')), 'Expected Switch 16 digit');
+ $this->assertTrue($validation->cc('5641829739125009', array('switch')), 'Expected Switch 16 digit');
+ $this->assertTrue($validation->cc('5641822860725507', array('switch')), 'Expected Switch 16 digit');
+ $this->assertTrue($validation->cc('4936717688865831', array('switch')), 'Expected Switch 16 digit');
+ $this->assertTrue($validation->cc('6759487613615441', array('switch')), 'Expected Switch 16 digit');
+ $this->assertTrue($validation->cc('5641821346840617', array('switch')), 'Expected Switch 16 digit');
+ $this->assertTrue($validation->cc('5641825793417126', array('switch')), 'Expected Switch 16 digit');
+ $this->assertTrue($validation->cc('5641821302759595', array('switch')), 'Expected Switch 16 digit');
+ $this->assertTrue($validation->cc('6759784969918837', array('switch')), 'Expected Switch 16 digit');
+ $this->assertTrue($validation->cc('5641824910667036', array('switch')), 'Expected Switch 16 digit');
+ $this->assertTrue($validation->cc('6759139909636173', array('switch')), 'Expected Switch 16 digit');
+ $this->assertTrue($validation->cc('6333425070638022', array('switch')), 'Expected Switch 16 digit');
+ $this->assertTrue($validation->cc('5641823910382067', array('switch')), 'Expected Switch 16 digit');
+ $this->assertTrue($validation->cc('4936295218139423', array('switch')), 'Expected Switch 16 digit');
+ $this->assertTrue($validation->cc('6333031811316199', array('switch')), 'Expected Switch 16 digit');
+ $this->assertTrue($validation->cc('4936912044763198', array('switch')), 'Expected Switch 16 digit');
+ $this->assertTrue($validation->cc('4936387053303824', array('switch')), 'Expected Switch 16 digit');
+ $this->assertTrue($validation->cc('6759535838760523', array('switch')), 'Expected Switch 16 digit');
+ $this->assertTrue($validation->cc('6333427174594051', array('switch')), 'Expected Switch 16 digit');
+ $this->assertTrue($validation->cc('5641829037102700', array('switch')), 'Expected Switch 16 digit');
+ $this->assertTrue($validation->cc('5641826495463046', array('switch')), 'Expected Switch 16 digit');
+ $this->assertTrue($validation->cc('6333480852979946', array('switch')), 'Expected Switch 16 digit');
+ $this->assertTrue($validation->cc('5641827761302876', array('switch')), 'Expected Switch 16 digit');
+ $this->assertTrue($validation->cc('5641825083505317', array('switch')), 'Expected Switch 16 digit');
+ $this->assertTrue($validation->cc('6759298096003991', array('switch')), 'Expected Switch 16 digit');
+ $this->assertTrue($validation->cc('4936119165483420', array('switch')), 'Expected Switch 16 digit');
+ $this->assertTrue($validation->cc('4936190990500993', array('switch')), 'Expected Switch 16 digit');
+ $this->assertTrue($validation->cc('4903356467384927', array('switch')), 'Expected Switch 16 digit');
+ $this->assertTrue($validation->cc('6333372765092554', array('switch')), 'Expected Switch 16 digit');
+ $this->assertTrue($validation->cc('5641821330950570', array('switch')), 'Expected Switch 16 digit');
+ $this->assertTrue($validation->cc('6759841558826118', array('switch')), 'Expected Switch 16 digit');
+ $this->assertTrue($validation->cc('4936164540922452', array('switch')), 'Expected Switch 16 digit');
+ //Switch 18
+ $this->assertTrue($validation->cc('493622764224625174', array('switch')), 'Expected Switch 18 digit');
+ $this->assertTrue($validation->cc('564182823396913535', array('switch')), 'Expected Switch 18 digit');
+ $this->assertTrue($validation->cc('675917308304801234', array('switch')), 'Expected Switch 18 digit');
+ $this->assertTrue($validation->cc('675919890024220298', array('switch')), 'Expected Switch 18 digit');
+ $this->assertTrue($validation->cc('633308376862556751', array('switch')), 'Expected Switch 18 digit');
+ $this->assertTrue($validation->cc('564182377633208779', array('switch')), 'Expected Switch 18 digit');
+ $this->assertTrue($validation->cc('564182870014926787', array('switch')), 'Expected Switch 18 digit');
+ $this->assertTrue($validation->cc('675979788553829819', array('switch')), 'Expected Switch 18 digit');
+ $this->assertTrue($validation->cc('493668394358130935', array('switch')), 'Expected Switch 18 digit');
+ $this->assertTrue($validation->cc('493637431790930965', array('switch')), 'Expected Switch 18 digit');
+ $this->assertTrue($validation->cc('633321438601941513', array('switch')), 'Expected Switch 18 digit');
+ $this->assertTrue($validation->cc('675913800898840986', array('switch')), 'Expected Switch 18 digit');
+ $this->assertTrue($validation->cc('564182592016841547', array('switch')), 'Expected Switch 18 digit');
+ $this->assertTrue($validation->cc('564182428380440899', array('switch')), 'Expected Switch 18 digit');
+ $this->assertTrue($validation->cc('493696376827623463', array('switch')), 'Expected Switch 18 digit');
+ $this->assertTrue($validation->cc('675977939286485757', array('switch')), 'Expected Switch 18 digit');
+ $this->assertTrue($validation->cc('490302699502091579', array('switch')), 'Expected Switch 18 digit');
+ $this->assertTrue($validation->cc('564182085013662230', array('switch')), 'Expected Switch 18 digit');
+ $this->assertTrue($validation->cc('493693054263310167', array('switch')), 'Expected Switch 18 digit');
+ $this->assertTrue($validation->cc('633321755966697525', array('switch')), 'Expected Switch 18 digit');
+ $this->assertTrue($validation->cc('675996851719732811', array('switch')), 'Expected Switch 18 digit');
+ $this->assertTrue($validation->cc('493699211208281028', array('switch')), 'Expected Switch 18 digit');
+ $this->assertTrue($validation->cc('493697817378356614', array('switch')), 'Expected Switch 18 digit');
+ $this->assertTrue($validation->cc('675968224161768150', array('switch')), 'Expected Switch 18 digit');
+ $this->assertTrue($validation->cc('493669416873337627', array('switch')), 'Expected Switch 18 digit');
+ $this->assertTrue($validation->cc('564182439172549714', array('switch')), 'Expected Switch 18 digit');
+ $this->assertTrue($validation->cc('675926914467673598', array('switch')), 'Expected Switch 18 digit');
+ $this->assertTrue($validation->cc('564182565231977809', array('switch')), 'Expected Switch 18 digit');
+ $this->assertTrue($validation->cc('675966282607849002', array('switch')), 'Expected Switch 18 digit');
+ $this->assertTrue($validation->cc('493691609704348548', array('switch')), 'Expected Switch 18 digit');
+ $this->assertTrue($validation->cc('675933118546065120', array('switch')), 'Expected Switch 18 digit');
+ $this->assertTrue($validation->cc('493631116677238592', array('switch')), 'Expected Switch 18 digit');
+ $this->assertTrue($validation->cc('675921142812825938', array('switch')), 'Expected Switch 18 digit');
+ $this->assertTrue($validation->cc('633338311815675113', array('switch')), 'Expected Switch 18 digit');
+ $this->assertTrue($validation->cc('633323539867338621', array('switch')), 'Expected Switch 18 digit');
+ $this->assertTrue($validation->cc('675964912740845663', array('switch')), 'Expected Switch 18 digit');
+ $this->assertTrue($validation->cc('633334008833727504', array('switch')), 'Expected Switch 18 digit');
+ $this->assertTrue($validation->cc('493631941273687169', array('switch')), 'Expected Switch 18 digit');
+ $this->assertTrue($validation->cc('564182971729706785', array('switch')), 'Expected Switch 18 digit');
+ $this->assertTrue($validation->cc('633303461188963496', array('switch')), 'Expected Switch 18 digit');
+ //Switch 19
+ $this->assertTrue($validation->cc('6759603460617628716', array('switch')), 'Expected Switch 19 digit');
+ $this->assertTrue($validation->cc('4936705825268647681', array('switch')), 'Expected Switch 19 digit');
+ $this->assertTrue($validation->cc('5641829846600479183', array('switch')), 'Expected Switch 19 digit');
+ $this->assertTrue($validation->cc('6759389846573792530', array('switch')), 'Expected Switch 19 digit');
+ $this->assertTrue($validation->cc('4936189558712637603', array('switch')), 'Expected Switch 19 digit');
+ $this->assertTrue($validation->cc('5641822217393868189', array('switch')), 'Expected Switch 19 digit');
+ $this->assertTrue($validation->cc('4903075563780057152', array('switch')), 'Expected Switch 19 digit');
+ $this->assertTrue($validation->cc('4936510653566569547', array('switch')), 'Expected Switch 19 digit');
+ $this->assertTrue($validation->cc('4936503083627303364', array('switch')), 'Expected Switch 19 digit');
+ $this->assertTrue($validation->cc('4936777334398116272', array('switch')), 'Expected Switch 19 digit');
+ $this->assertTrue($validation->cc('5641823876900554860', array('switch')), 'Expected Switch 19 digit');
+ $this->assertTrue($validation->cc('6759619236903407276', array('switch')), 'Expected Switch 19 digit');
+ $this->assertTrue($validation->cc('6759011470269978117', array('switch')), 'Expected Switch 19 digit');
+ $this->assertTrue($validation->cc('6333175833997062502', array('switch')), 'Expected Switch 19 digit');
+ $this->assertTrue($validation->cc('6759498728789080439', array('switch')), 'Expected Switch 19 digit');
+ $this->assertTrue($validation->cc('4903020404168157841', array('switch')), 'Expected Switch 19 digit');
+ $this->assertTrue($validation->cc('6759354334874804313', array('switch')), 'Expected Switch 19 digit');
+ $this->assertTrue($validation->cc('6759900856420875115', array('switch')), 'Expected Switch 19 digit');
+ $this->assertTrue($validation->cc('5641827269346868860', array('switch')), 'Expected Switch 19 digit');
+ $this->assertTrue($validation->cc('5641828995047453870', array('switch')), 'Expected Switch 19 digit');
+ $this->assertTrue($validation->cc('6333321884754806543', array('switch')), 'Expected Switch 19 digit');
+ $this->assertTrue($validation->cc('6333108246283715901', array('switch')), 'Expected Switch 19 digit');
+ $this->assertTrue($validation->cc('6759572372800700102', array('switch')), 'Expected Switch 19 digit');
+ $this->assertTrue($validation->cc('4903095096797974933', array('switch')), 'Expected Switch 19 digit');
+ $this->assertTrue($validation->cc('6333354315797920215', array('switch')), 'Expected Switch 19 digit');
+ $this->assertTrue($validation->cc('6759163746089433755', array('switch')), 'Expected Switch 19 digit');
+ $this->assertTrue($validation->cc('6759871666634807647', array('switch')), 'Expected Switch 19 digit');
+ $this->assertTrue($validation->cc('5641827883728575248', array('switch')), 'Expected Switch 19 digit');
+ $this->assertTrue($validation->cc('4936527975051407847', array('switch')), 'Expected Switch 19 digit');
+ $this->assertTrue($validation->cc('5641823318396882141', array('switch')), 'Expected Switch 19 digit');
+ $this->assertTrue($validation->cc('6759123772311123708', array('switch')), 'Expected Switch 19 digit');
+ $this->assertTrue($validation->cc('4903054736148271088', array('switch')), 'Expected Switch 19 digit');
+ $this->assertTrue($validation->cc('4936477526808883952', array('switch')), 'Expected Switch 19 digit');
+ $this->assertTrue($validation->cc('4936433964890967966', array('switch')), 'Expected Switch 19 digit');
+ $this->assertTrue($validation->cc('6333245128906049344', array('switch')), 'Expected Switch 19 digit');
+ $this->assertTrue($validation->cc('4936321036970553134', array('switch')), 'Expected Switch 19 digit');
+ $this->assertTrue($validation->cc('4936111816358702773', array('switch')), 'Expected Switch 19 digit');
+ $this->assertTrue($validation->cc('4936196077254804290', array('switch')), 'Expected Switch 19 digit');
+ $this->assertTrue($validation->cc('6759558831206830183', array('switch')), 'Expected Switch 19 digit');
+ $this->assertTrue($validation->cc('5641827998830403137', array('switch')), 'Expected Switch 19 digit');
+ //VISA 13 digit
+ $this->assertTrue($validation->cc('4024007174754', array('visa')), 'Expected VISA 13 digit');
+ $this->assertTrue($validation->cc('4104816460717', array('visa')), 'Expected VISA 13 digit');
+ $this->assertTrue($validation->cc('4716229700437', array('visa')), 'Expected VISA 13 digit');
+ $this->assertTrue($validation->cc('4539305400213', array('visa')), 'Expected VISA 13 digit');
+ $this->assertTrue($validation->cc('4728260558665', array('visa')), 'Expected VISA 13 digit');
+ $this->assertTrue($validation->cc('4929100131792', array('visa')), 'Expected VISA 13 digit');
+ $this->assertTrue($validation->cc('4024007117308', array('visa')), 'Expected VISA 13 digit');
+ $this->assertTrue($validation->cc('4539915491024', array('visa')), 'Expected VISA 13 digit');
+ $this->assertTrue($validation->cc('4539790901139', array('visa')), 'Expected VISA 13 digit');
+ $this->assertTrue($validation->cc('4485284914909', array('visa')), 'Expected VISA 13 digit');
+ $this->assertTrue($validation->cc('4782793022350', array('visa')), 'Expected VISA 13 digit');
+ $this->assertTrue($validation->cc('4556899290685', array('visa')), 'Expected VISA 13 digit');
+ $this->assertTrue($validation->cc('4024007134774', array('visa')), 'Expected VISA 13 digit');
+ $this->assertTrue($validation->cc('4333412341316', array('visa')), 'Expected VISA 13 digit');
+ $this->assertTrue($validation->cc('4539534204543', array('visa')), 'Expected VISA 13 digit');
+ $this->assertTrue($validation->cc('4485640373626', array('visa')), 'Expected VISA 13 digit');
+ $this->assertTrue($validation->cc('4929911445746', array('visa')), 'Expected VISA 13 digit');
+ $this->assertTrue($validation->cc('4539292550806', array('visa')), 'Expected VISA 13 digit');
+ $this->assertTrue($validation->cc('4716523014030', array('visa')), 'Expected VISA 13 digit');
+ $this->assertTrue($validation->cc('4024007125152', array('visa')), 'Expected VISA 13 digit');
+ $this->assertTrue($validation->cc('4539758883311', array('visa')), 'Expected VISA 13 digit');
+ $this->assertTrue($validation->cc('4024007103258', array('visa')), 'Expected VISA 13 digit');
+ $this->assertTrue($validation->cc('4916933155767', array('visa')), 'Expected VISA 13 digit');
+ $this->assertTrue($validation->cc('4024007159672', array('visa')), 'Expected VISA 13 digit');
+ $this->assertTrue($validation->cc('4716935544871', array('visa')), 'Expected VISA 13 digit');
+ $this->assertTrue($validation->cc('4929415177779', array('visa')), 'Expected VISA 13 digit');
+ $this->assertTrue($validation->cc('4929748547896', array('visa')), 'Expected VISA 13 digit');
+ $this->assertTrue($validation->cc('4929153468612', array('visa')), 'Expected VISA 13 digit');
+ $this->assertTrue($validation->cc('4539397132104', array('visa')), 'Expected VISA 13 digit');
+ $this->assertTrue($validation->cc('4485293435540', array('visa')), 'Expected VISA 13 digit');
+ $this->assertTrue($validation->cc('4485799412720', array('visa')), 'Expected VISA 13 digit');
+ $this->assertTrue($validation->cc('4916744757686', array('visa')), 'Expected VISA 13 digit');
+ $this->assertTrue($validation->cc('4556475655426', array('visa')), 'Expected VISA 13 digit');
+ $this->assertTrue($validation->cc('4539400441625', array('visa')), 'Expected VISA 13 digit');
+ $this->assertTrue($validation->cc('4485437129173', array('visa')), 'Expected VISA 13 digit');
+ $this->assertTrue($validation->cc('4716253605320', array('visa')), 'Expected VISA 13 digit');
+ $this->assertTrue($validation->cc('4539366156589', array('visa')), 'Expected VISA 13 digit');
+ $this->assertTrue($validation->cc('4916498061392', array('visa')), 'Expected VISA 13 digit');
+ $this->assertTrue($validation->cc('4716127163779', array('visa')), 'Expected VISA 13 digit');
+ $this->assertTrue($validation->cc('4024007183078', array('visa')), 'Expected VISA 13 digit');
+ $this->assertTrue($validation->cc('4041553279654', array('visa')), 'Expected VISA 13 digit');
+ $this->assertTrue($validation->cc('4532380121960', array('visa')), 'Expected VISA 13 digit');
+ $this->assertTrue($validation->cc('4485906062491', array('visa')), 'Expected VISA 13 digit');
+ $this->assertTrue($validation->cc('4539365115149', array('visa')), 'Expected VISA 13 digit');
+ $this->assertTrue($validation->cc('4485146516702', array('visa')), 'Expected VISA 13 digit');
+ //VISA 16 digit
+ $this->assertTrue($validation->cc('4916375389940009', array('visa')), 'Expected VISA 16 digit');
+ $this->assertTrue($validation->cc('4929167481032610', array('visa')), 'Expected VISA 16 digit');
+ $this->assertTrue($validation->cc('4485029969061519', array('visa')), 'Expected VISA 16 digit');
+ $this->assertTrue($validation->cc('4485573845281759', array('visa')), 'Expected VISA 16 digit');
+ $this->assertTrue($validation->cc('4485669810383529', array('visa')), 'Expected VISA 16 digit');
+ $this->assertTrue($validation->cc('4929615806560327', array('visa')), 'Expected VISA 16 digit');
+ $this->assertTrue($validation->cc('4556807505609535', array('visa')), 'Expected VISA 16 digit');
+ $this->assertTrue($validation->cc('4532611336232890', array('visa')), 'Expected VISA 16 digit');
+ $this->assertTrue($validation->cc('4532201952422387', array('visa')), 'Expected VISA 16 digit');
+ $this->assertTrue($validation->cc('4485073797976290', array('visa')), 'Expected VISA 16 digit');
+ $this->assertTrue($validation->cc('4024007157580969', array('visa')), 'Expected VISA 16 digit');
+ $this->assertTrue($validation->cc('4053740470212274', array('visa')), 'Expected VISA 16 digit');
+ $this->assertTrue($validation->cc('4716265831525676', array('visa')), 'Expected VISA 16 digit');
+ $this->assertTrue($validation->cc('4024007100222966', array('visa')), 'Expected VISA 16 digit');
+ $this->assertTrue($validation->cc('4539556148303244', array('visa')), 'Expected VISA 16 digit');
+ $this->assertTrue($validation->cc('4532449879689709', array('visa')), 'Expected VISA 16 digit');
+ $this->assertTrue($validation->cc('4916805467840986', array('visa')), 'Expected VISA 16 digit');
+ $this->assertTrue($validation->cc('4532155644440233', array('visa')), 'Expected VISA 16 digit');
+ $this->assertTrue($validation->cc('4467977802223781', array('visa')), 'Expected VISA 16 digit');
+ $this->assertTrue($validation->cc('4539224637000686', array('visa')), 'Expected VISA 16 digit');
+ $this->assertTrue($validation->cc('4556629187064965', array('visa')), 'Expected VISA 16 digit');
+ $this->assertTrue($validation->cc('4532970205932943', array('visa')), 'Expected VISA 16 digit');
+ $this->assertTrue($validation->cc('4821470132041850', array('visa')), 'Expected VISA 16 digit');
+ $this->assertTrue($validation->cc('4916214267894485', array('visa')), 'Expected VISA 16 digit');
+ $this->assertTrue($validation->cc('4024007169073284', array('visa')), 'Expected VISA 16 digit');
+ $this->assertTrue($validation->cc('4716783351296122', array('visa')), 'Expected VISA 16 digit');
+ $this->assertTrue($validation->cc('4556480171913795', array('visa')), 'Expected VISA 16 digit');
+ $this->assertTrue($validation->cc('4929678411034997', array('visa')), 'Expected VISA 16 digit');
+ $this->assertTrue($validation->cc('4682061913519392', array('visa')), 'Expected VISA 16 digit');
+ $this->assertTrue($validation->cc('4916495481746474', array('visa')), 'Expected VISA 16 digit');
+ $this->assertTrue($validation->cc('4929007108460499', array('visa')), 'Expected VISA 16 digit');
+ $this->assertTrue($validation->cc('4539951357838586', array('visa')), 'Expected VISA 16 digit');
+ $this->assertTrue($validation->cc('4716482691051558', array('visa')), 'Expected VISA 16 digit');
+ $this->assertTrue($validation->cc('4916385069917516', array('visa')), 'Expected VISA 16 digit');
+ $this->assertTrue($validation->cc('4929020289494641', array('visa')), 'Expected VISA 16 digit');
+ $this->assertTrue($validation->cc('4532176245263774', array('visa')), 'Expected VISA 16 digit');
+ $this->assertTrue($validation->cc('4556242273553949', array('visa')), 'Expected VISA 16 digit');
+ $this->assertTrue($validation->cc('4481007485188614', array('visa')), 'Expected VISA 16 digit');
+ $this->assertTrue($validation->cc('4716533372139623', array('visa')), 'Expected VISA 16 digit');
+ $this->assertTrue($validation->cc('4929152038152632', array('visa')), 'Expected VISA 16 digit');
+ $this->assertTrue($validation->cc('4539404037310550', array('visa')), 'Expected VISA 16 digit');
+ $this->assertTrue($validation->cc('4532800925229140', array('visa')), 'Expected VISA 16 digit');
+ $this->assertTrue($validation->cc('4916845885268360', array('visa')), 'Expected VISA 16 digit');
+ $this->assertTrue($validation->cc('4394514669078434', array('visa')), 'Expected VISA 16 digit');
+ $this->assertTrue($validation->cc('4485611378115042', array('visa')), 'Expected VISA 16 digit');
+ //Visa Electron
+ $this->assertTrue($validation->cc('4175003346287100', array('electron')), 'Expected Visa Electron');
+ $this->assertTrue($validation->cc('4913042516577228', array('electron')), 'Expected Visa Electron');
+ $this->assertTrue($validation->cc('4917592325659381', array('electron')), 'Expected Visa Electron');
+ $this->assertTrue($validation->cc('4917084924450511', array('electron')), 'Expected Visa Electron');
+ $this->assertTrue($validation->cc('4917994610643999', array('electron')), 'Expected Visa Electron');
+ $this->assertTrue($validation->cc('4175005933743585', array('electron')), 'Expected Visa Electron');
+ $this->assertTrue($validation->cc('4175008373425044', array('electron')), 'Expected Visa Electron');
+ $this->assertTrue($validation->cc('4913119763664154', array('electron')), 'Expected Visa Electron');
+ $this->assertTrue($validation->cc('4913189017481812', array('electron')), 'Expected Visa Electron');
+ $this->assertTrue($validation->cc('4913085104968622', array('electron')), 'Expected Visa Electron');
+ $this->assertTrue($validation->cc('4175008803122021', array('electron')), 'Expected Visa Electron');
+ $this->assertTrue($validation->cc('4913294453962489', array('electron')), 'Expected Visa Electron');
+ $this->assertTrue($validation->cc('4175009797419290', array('electron')), 'Expected Visa Electron');
+ $this->assertTrue($validation->cc('4175005028142917', array('electron')), 'Expected Visa Electron');
+ $this->assertTrue($validation->cc('4913940802385364', array('electron')), 'Expected Visa Electron');
+ //Voyager
+ $this->assertTrue($validation->cc('869940697287073', array('voyager')), 'Expected Voyager');
+ $this->assertTrue($validation->cc('869934523596112', array('voyager')), 'Expected Voyager');
+ $this->assertTrue($validation->cc('869958670174621', array('voyager')), 'Expected Voyager');
+ $this->assertTrue($validation->cc('869921250068209', array('voyager')), 'Expected Voyager');
+ $this->assertTrue($validation->cc('869972521242198', array('voyager')), 'Expected Voyager');
+ }
+
+ function testLuhn(){
+ $validation = new Validation();
+ $validation->deep = true;
+
+ //American Express
+ $validation->check = '370482756063980';
+ $this->assertTrue($validation->_luhn(), 'Expected American Express');
+ //BankCard
+ $validation->check = '5610745867413420';
+ $this->assertTrue($validation->_luhn(), 'Expected BankCard');
+ //Diners Club 14
+ $validation->check = '30155483651028';
+ $this->assertTrue($validation->_luhn(), 'Expected Diners Club 14');
+ //2004 MasterCard/Diners Club Alliance International 14
+ $validation->check = '36747701998969';
+ $this->assertTrue($validation->_luhn(), 'Expected MasterCard/Diners Club International');
+ //2004 MasterCard/Diners Club Alliance US & Canada 16
+ $validation->check = '5597511346169950';
+ $this->assertTrue($validation->_luhn(), 'Expected MasterCard/Diners Club US & Canada');
+ //Discover
+ $validation->check = '6011802876467237';
+ $this->assertTrue($validation->_luhn(), 'Expected Discover');
+ //enRoute
+ $validation->check = '201496944158937';
+ $this->assertTrue($validation->_luhn(), 'Expected enRoute');
+ //JCB 15 digit
+ $validation->check = '210034762247893';
+ $this->assertTrue($validation->_luhn(), 'Expected JCB 15 digit');
+ //JCB 16 digit
+ $validation->check = '3096806857839939';
+ $this->assertTrue($validation->_luhn(), 'Expected JCB 16 digit');
+ //Maestro (debit card)
+ $validation->check = '5020147409985219';
+ $this->assertTrue($validation->_luhn(), 'Expected Maestro (debit card)');
+ //Mastercard
+ $validation->check = '5580424361774366';
+ $this->assertTrue($validation->_luhn(), 'Expected Mastercard)');
+ //Solo 16
+ $validation->check = '6767432107064987';
+ $this->assertTrue($validation->_luhn(), 'Expected Solo 16)');
+ //Solo 18
+ $validation->check = '676714834398858593';
+ $this->assertTrue($validation->_luhn(), 'Expected Solo 18)');
+ //Solo 19
+ $validation->check = '6767838565218340113';
+ $this->assertTrue($validation->_luhn(), 'Expected Solo 19)');
+ //Switch 16
+ $validation->check = '5641829171515733';
+ $this->assertTrue($validation->_luhn(), 'Expected Switch 16)');
+ //Switch 18
+ $validation->check = '493622764224625174';
+ $this->assertTrue($validation->_luhn(), 'Expected Switch 18');
+ //Switch 19
+ $validation->check = '6759603460617628716';
+ $this->assertTrue($validation->_luhn(), 'Expected Switch 19');
+ //VISA 13 digit
+ $validation->check = '4024007174754';
+ $this->assertTrue($validation->_luhn(), 'Expected VISA 13 digit');
+ //VISA 16 digit
+ $validation->check = '4916375389940009';
+ $this->assertTrue($validation->_luhn(), 'Expected VISA 16 digit');
+ //Visa Electron
+ $validation->check = '4175003346287100';
+ $this->assertTrue($validation->_luhn(), 'Expected Visa Electron');
+ //Voyager
+ $validation->check = '869940697287073';
+ $this->assertTrue($validation->_luhn(), 'Expected Voyager');
+
+ $validation->check = '0000000000000000';
+ $this->assertFalse($validation->_luhn(), 'All zeros');
+
+ $validation->check = '869940697287173';
+ $this->assertFalse($validation->_luhn(), 'Expected invalid match');
+ }
+
+ function testCustomRegexForCc() {
+ $validation = new Validation();
+ $this->assertTrue($validation->cc('12332105933743585', null, null, '/123321\\d{11}/'), 'Expected 17 digit');
+ $this->assertFalse($validation->cc('1233210593374358', null, null, '/123321\\d{11}/'), 'Expected 17 digit got 16');
+ $this->assertFalse($validation->cc('12312305933743585', null, null, '/123321\\d{11}/'), 'Expected 123321 in first 6 positions, got 123123');
+ }
+
+ function testCustomRegexForCcWithLuhnCheck() {
+ $validation = new Validation();
+ $this->assertTrue($validation->cc('12332110426226941', null, true, '/123321\\d{11}/'), 'Expected valid Luhn match');
+ $this->assertFalse($validation->cc('12332105933743585', null, true, '/123321\\d{11}/'), 'Expected invalid Luhn match');
+ $this->assertFalse($validation->cc('12332105933743587', null, true, '/123321\\d{11}/'), 'Expected invalid Luhn match');
+ $this->assertFalse($validation->cc('12312305933743585', null, true, '/123321\\d{11}/'), 'Expected invalid Luhn match');
+ }
+
+ function testFastCc() {
+ $validation = new Validation();
+ //American Express
+ $this->assertTrue($validation->cc('370482756063980'), 'Expected American Express');
+ //Diners Club 14
+ $this->assertTrue($validation->cc('30155483651028'), 'Expected Diners Club 14');
+ //2004 MasterCard/Diners Club Alliance International 14
+ $this->assertTrue($validation->cc('36747701998969'), 'Expected MasterCard/Diners Club International');
+ //2004 MasterCard/Diners Club Alliance US & Canada 16
+ $this->assertTrue($validation->cc('5597511346169950'), 'Expected MasterCard/Diners Club US & Canada');
+ //Discover
+ $this->assertTrue($validation->cc('6011802876467237'), 'Expected Discover');
+ //Mastercard
+ $this->assertTrue($validation->cc('5580424361774366'), 'Expected Mastercard)');
+ //VISA 13 digit
+ $this->assertTrue($validation->cc('4024007174754'), 'Expected VISA 13 digit');
+ //VISA 16 digit
+ $this->assertTrue($validation->cc('4916375389940009'), 'Expected VISA 16 digit');
+ //Visa Electron
+ $this->assertTrue($validation->cc('4175003346287100'), 'Expected Visa Electron');
+ }
+
+ function testAllCc() {
+ $validation = new Validation();
+ //American Express
+ $this->assertTrue($validation->cc('370482756063980', 'all'), 'Expected American Express');
+ //BankCard
+ $this->assertTrue($validation->cc('5610745867413420', 'all'), 'Expected BankCard');
+ //Diners Club 14
+ $this->assertTrue($validation->cc('30155483651028', 'all'), 'Expected Diners Club 14');
+ //2004 MasterCard/Diners Club Alliance International 14
+ $this->assertTrue($validation->cc('36747701998969', 'all'), 'Expected MasterCard/Diners Club International');
+ //2004 MasterCard/Diners Club Alliance US & Canada 16
+ $this->assertTrue($validation->cc('5597511346169950', 'all'), 'Expected MasterCard/Diners Club US & Canada');
+ //Discover
+ $this->assertTrue($validation->cc('6011802876467237', 'all'), 'Expected Discover');
+ //enRoute
+ $this->assertTrue($validation->cc('201496944158937', 'all'), 'Expected enRoute');
+ //JCB 15 digit
+ $this->assertTrue($validation->cc('210034762247893', 'all'), 'Expected JCB 15 digit');
+ //JCB 16 digit
+ $this->assertTrue($validation->cc('3096806857839939', 'all'), 'Expected JCB 16 digit');
+ //Maestro (debit card)
+ $this->assertTrue($validation->cc('5020147409985219', 'all'), 'Expected Maestro (debit card)');
+ //Mastercard
+ $this->assertTrue($validation->cc('5580424361774366', 'all'), 'Expected Mastercard)');
+ //Solo 16
+ $this->assertTrue($validation->cc('6767432107064987', 'all'), 'Expected Solo 16)');
+ //Solo 18
+ $this->assertTrue($validation->cc('676714834398858593', 'all'), 'Expected Solo 18)');
+ //Solo 19
+ $this->assertTrue($validation->cc('6767838565218340113', 'all'), 'Expected Solo 19)');
+ //Switch 16
+ $this->assertTrue($validation->cc('5641829171515733', 'all'), 'Expected Switch 16)');
+ //Switch 18
+ $this->assertTrue($validation->cc('493622764224625174', 'all'), 'Expected Switch 18');
+ //Switch 19
+ $this->assertTrue($validation->cc('6759603460617628716', 'all'), 'Expected Switch 19');
+ //VISA 13 digit
+ $this->assertTrue($validation->cc('4024007174754', 'all'), 'Expected VISA 13 digit');
+ //VISA 16 digit
+ $this->assertTrue($validation->cc('4916375389940009', 'all'), 'Expected VISA 16 digit');
+ //Visa Electron
+ $this->assertTrue($validation->cc('4175003346287100', 'all'), 'Expected Visa Electron');
+ //Voyager
+ $this->assertTrue($validation->cc('869940697287073', 'all'), 'Expected Voyager');
+ }
+
+ function testAllCcDeep() {
+ $validation = new Validation();
+ //American Express
+ $this->assertTrue($validation->cc('370482756063980', 'all', true), 'Expected American Express');
+ //BankCard
+ $this->assertTrue($validation->cc('5610745867413420', 'all', true), 'Expected BankCard');
+ //Diners Club 14
+ $this->assertTrue($validation->cc('30155483651028', 'all', true), 'Expected Diners Club 14');
+ //2004 MasterCard/Diners Club Alliance International 14
+ $this->assertTrue($validation->cc('36747701998969', 'all', true), 'Expected MasterCard/Diners Club International');
+ //2004 MasterCard/Diners Club Alliance US & Canada 16
+ $this->assertTrue($validation->cc('5597511346169950', 'all', true), 'Expected MasterCard/Diners Club US & Canada');
+ //Discover
+ $this->assertTrue($validation->cc('6011802876467237', 'all', true), 'Expected Discover');
+ //enRoute
+ $this->assertTrue($validation->cc('201496944158937', 'all', true), 'Expected enRoute');
+ //JCB 15 digit
+ $this->assertTrue($validation->cc('210034762247893', 'all', true), 'Expected JCB 15 digit');
+ //JCB 16 digit
+ $this->assertTrue($validation->cc('3096806857839939', 'all', true), 'Expected JCB 16 digit');
+ //Maestro (debit card)
+ $this->assertTrue($validation->cc('5020147409985219', 'all', true), 'Expected Maestro (debit card)');
+ //Mastercard
+ $this->assertTrue($validation->cc('5580424361774366', 'all', true), 'Expected Mastercard)');
+ //Solo 16
+ $this->assertTrue($validation->cc('6767432107064987', 'all', true), 'Expected Solo 16)');
+ //Solo 18
+ $this->assertTrue($validation->cc('676714834398858593', 'all', true), 'Expected Solo 18)');
+ //Solo 19
+ $this->assertTrue($validation->cc('6767838565218340113', 'all', true), 'Expected Solo 19)');
+ //Switch 16
+ $this->assertTrue($validation->cc('5641829171515733', 'all'), true, 'Expected Switch 16)');
+ //Switch 18
+ $this->assertTrue($validation->cc('493622764224625174', 'all', true), 'Expected Switch 18');
+ //Switch 19
+ $this->assertTrue($validation->cc('6759603460617628716', 'all', true), 'Expected Switch 19');
+ //VISA 13 digit
+ $this->assertTrue($validation->cc('4024007174754', 'all', true), 'Expected VISA 13 digit');
+ //VISA 16 digit
+ $this->assertTrue($validation->cc('4916375389940009', 'all', true), 'Expected VISA 16 digit');
+ //Visa Electron
+ $this->assertTrue($validation->cc('4175003346287100', 'all', true), 'Expected Visa Electron');
+ //Voyager
+ $this->assertTrue($validation->cc('869940697287073', 'all', true), 'Expected Voyager');
+ }
+
+ function testComparison() {
+ $validation = new Validation();
+ $this->assertTrue($validation->comparison(7, 'is greater', 6), 'Expected 7 greater than 6');
+ $this->assertTrue($validation->comparison(7, '>', 6), 'Expected 7 greater than 6');
+ $this->assertTrue($validation->comparison(6, 'is less', 7), 'Expected 6 less than 7');
+ $this->assertTrue($validation->comparison(6, '<', 7), 'Expected 6 less than 7');
+ $this->assertTrue($validation->comparison(7, 'greater or equal', 7), 'Expected 5 greater then or equal to 5');
+ $this->assertTrue($validation->comparison(7, '>=', 7), 'Expected 7 greater then or equal to 7');
+ $this->assertTrue($validation->comparison(7, 'greater or equal', 6), 'Expected 7 greater then or equal to 6');
+ $this->assertTrue($validation->comparison(7, '>=', 6), 'Expected 7 greater then or equal to 6');
+ $this->assertTrue($validation->comparison(6, 'less or equal', 7), 'Expected 6 less then or equal to 7');
+ $this->assertTrue($validation->comparison(6, '<=', 7), 'Expected 6 less then or equal to 7');
+ $this->assertTrue($validation->comparison(7, 'equal to', 7), 'Expected 7 equal to 7');
+ $this->assertTrue($validation->comparison(7, '==', 7), 'Expected 7 equal to 7');
+ $this->assertTrue($validation->comparison(7, 'not equal', 6), 'Expected 7 not equal 6');
+ $this->assertTrue($validation->comparison(7, '!=', 6), 'Expected 7 not equal 6');
+ $this->assertFalse($validation->comparison(6, 'is greater', 7), 'Expected 7 greater than 6');
+ $this->assertFalse($validation->comparison(6, '>', 7), 'Expected 7 greater than 6');
+ $this->assertFalse($validation->comparison(7, 'is less', 6), 'Expected 6 less than 7');
+ $this->assertFalse($validation->comparison(7, '<', 6), 'Expected 6 less than 7');
+ $this->assertFalse($validation->comparison(6, 'greater or equal', 7), 'Expected 5 greater then or equal to 5');
+ $this->assertFalse($validation->comparison(6, '>=', 7), 'Expected 7 greater then or equal to 7');
+ $this->assertFalse($validation->comparison(6, 'greater or equal', 7), 'Expected 7 greater then or equal to 6');
+ $this->assertFalse($validation->comparison(6, '>=', 7), 'Expected 7 greater then or equal to 6');
+ $this->assertFalse($validation->comparison(7, 'less or equal', 6), 'Expected 6 less then or equal to 7');
+ $this->assertFalse($validation->comparison(7, '<=', 6), 'Expected 6 less then or equal to 7');
+ $this->assertFalse($validation->comparison(7, 'equal to', 6), 'Expected 7 equal to 7');
+ $this->assertFalse($validation->comparison(7, '==', 6), 'Expected 7 equal to 7');
+ $this->assertFalse($validation->comparison(7, 'not equal', 7), 'Expected 7 not equal 6');
+ $this->assertFalse($validation->comparison(7, '!=', 7), 'Expected 7 not equal 6');
+ }
+
+ function testComparisonAsArray() {
+ $validation = new Validation();
+ $this->assertTrue($validation->comparison(array('check1' => 7, 'operator' => 'is greater', 'check2' => 6)), 'Expected 7 greater than 6');
+ $this->assertTrue($validation->comparison(array('check1' => 7, 'operator' => '>', 'check2' => 6)), 'Expected 7 greater than 6');
+ $this->assertTrue($validation->comparison(array('check1' => 6, 'operator' => 'is less', 'check2' => 7)), 'Expected 6 less than 7');
+ $this->assertTrue($validation->comparison(array('check1' => 6, 'operator' => '<', 'check2' => 7)), 'Expected 6 less than 7');
+ $this->assertTrue($validation->comparison(array('check1' => 7, 'operator' => 'greater or equal', 'check2' => 7)), 'Expected 5 greater then or equal to 5');
+ $this->assertTrue($validation->comparison(array('check1' => 7, 'operator' => '>=', 'check2' => 7)), 'Expected 7 greater then or equal to 7');
+ $this->assertTrue($validation->comparison(array('check1' => 7, 'operator' => 'greater or equal','check2' => 6)), 'Expected 7 greater then or equal to 6');
+ $this->assertTrue($validation->comparison(array('check1' => 7, 'operator' => '>=', 'check2' => 6)), 'Expected 7 greater then or equal to 6');
+ $this->assertTrue($validation->comparison(array('check1' => 6, 'operator' => 'less or equal', 'check2' => 7)), 'Expected 6 less then or equal to 7');
+ $this->assertTrue($validation->comparison(array('check1' => 6, 'operator' => '<=', 'check2' => 7)), 'Expected 6 less then or equal to 7');
+ $this->assertTrue($validation->comparison(array('check1' => 7, 'operator' => 'equal to', 'check2' => 7)), 'Expected 7 equal to 7');
+ $this->assertTrue($validation->comparison(array('check1' => 7, 'operator' => '==', 'check2' => 7)), 'Expected 7 equal to 7');
+ $this->assertTrue($validation->comparison(array('check1' => 7, 'operator' => 'not equal', 'check2' => 6)), 'Expected 7 not equal 6');
+ $this->assertTrue($validation->comparison(array('check1' => 7, 'operator' => '!=', 'check2' => 6)), 'Expected 7 not equal 6');
+ $this->assertFalse($validation->comparison(array('check1' => 6, 'operator' => 'is greater', 'check2' => 7)), 'Expected 7 greater than 6');
+ $this->assertFalse($validation->comparison(array('check1' => 6, 'operator' => '>', 'check2' => 7)), 'Expected 7 greater than 6');
+ $this->assertFalse($validation->comparison(array('check1' => 7, 'operator' => 'is less', 'check2' => 6)), 'Expected 6 less than 7');
+ $this->assertFalse($validation->comparison(array('check1' => 7, 'operator' => '<', 'check2' => 6)), 'Expected 6 less than 7');
+ $this->assertFalse($validation->comparison(array('check1' => 6, 'operator' => 'greater or equal', 'check2' => 7)), 'Expected 5 greater then or equal to 5');
+ $this->assertFalse($validation->comparison(array('check1' => 6, 'operator' => '>=', 'check2' => 7)), 'Expected 7 greater then or equal to 7');
+ $this->assertFalse($validation->comparison(array('check1' => 6, 'operator' => 'greater or equal', 'check2' => 7)), 'Expected 7 greater then or equal to 6');
+ $this->assertFalse($validation->comparison(array('check1' => 6, 'operator' => '>=', 'check2' => 7)), 'Expected 7 greater then or equal to 6');
+ $this->assertFalse($validation->comparison(array('check1' => 7, 'operator' => 'less or equal', 'check2' => 6)), 'Expected 6 less then or equal to 7');
+ $this->assertFalse($validation->comparison(array('check1' => 7, 'operator' => '<=', 'check2' => 6)), 'Expected 6 less then or equal to 7');
+ $this->assertFalse($validation->comparison(array('check1' => 7, 'operator' => 'equal to', 'check2' => 6)), 'Expected 7 equal to 7');
+ $this->assertFalse($validation->comparison(array('check1' => 7, 'operator' => '==','check2' => 6)), 'Expected 7 equal to 7');
+ $this->assertFalse($validation->comparison(array('check1' => 7, 'operator' => 'not equal', 'check2' => 7)), 'Expected 7 not equal 6');
+ $this->assertFalse($validation->comparison(array('check1' => 7, 'operator' => '!=', 'check2' => 7)), 'Expected 7 not equal 6');
+ }
+
+ function testCustom() {
+ $validation = new Validation();
+ $this->assertTrue($validation->custom('12345', '/(?assertFalse($validation->custom('Text', '/(?assertFalse($validation->custom('123.45', '/(?assertTrue($validation->custom(array('check' => '12345', 'regex' => '/(?assertFalse($validation->custom(array('check' => 'Text', 'regex' => '/(?assertFalse($validation->custom(array('check' => '123.45', 'regex' => '/(?assertTrue($validation->date('27-12-2006', array('dmy')), 'Expected valid dd/mm/yyyy date format');
+ $this->assertTrue($validation->date('27.12.2006', array('dmy')), 'Expected valid dd/mm/yyyy date format');
+ $this->assertTrue($validation->date('27/12/2006', array('dmy')), 'Expected valid dd/mm/yyyy date format');
+ $this->assertTrue($validation->date('27 12 2006', array('dmy')), 'Expected valid dd/mm/yyyy date format');
+ $this->assertFalse($validation->date('00-00-0000', array('dmy')), 'Expected invalid dd/mm/yyyy date format');
+ $this->assertFalse($validation->date('00.00.0000', array('dmy')), 'Expected invalid dd/mm/yyyy date format');
+ $this->assertFalse($validation->date('00/00/0000', array('dmy')), 'Expected invalid dd/mm/yyyy date format');
+ $this->assertFalse($validation->date('00 00 0000', array('dmy')), 'Expected invalid dd/mm/yyyy date format');
+ $this->assertFalse($validation->date('31-11-2006', array('dmy')), 'Expected invalid dd/mm/yyyy date format');
+ $this->assertFalse($validation->date('31.11.2006', array('dmy')), 'Expected invalid dd/mm/yyyy date format');
+ $this->assertFalse($validation->date('31/11/2006', array('dmy')), 'Expected invalid dd/mm/yyyy date format');
+ $this->assertFalse($validation->date('31 11 2006', array('dmy')), 'Expected invalid dd/mm/yyyy date format');
+ }
+
+ function testDateDdmmyyyyLeapYear() {
+ $validation = new Validation();
+ $this->assertTrue($validation->date('29-02-2004', array('dmy')), 'Expected valid leap year dd/mm/yyyy date format');
+ $this->assertTrue($validation->date('29.02.2004', array('dmy')), 'Expected valid leap year dd/mm/yyyy date format');
+ $this->assertTrue($validation->date('29/02/2004', array('dmy')), 'Expected valid leap year dd/mm/yyyy date format');
+ $this->assertTrue($validation->date('29 02 2004', array('dmy')), 'Expected valid leap year dd/mm/yyyy date format');
+ $this->assertFalse($validation->date('29-02-2006', array('dmy')), 'Expected invalid leap year dd/mm/yyyy date format');
+ $this->assertFalse($validation->date('29.02.2006', array('dmy')), 'Expected invalid leap year dd/mm/yyyy date format');
+ $this->assertFalse($validation->date('29/02/2006', array('dmy')), 'Expected invalid leap year dd/mm/yyyy date format');
+ $this->assertFalse($validation->date('29 02 2006', array('dmy')), 'Expected invalid leap year dd/mm/yyyy date format');
+ }
+
+ function testDateDdmmyy() {
+ $validation = new Validation();
+ $this->assertTrue($validation->date('27-12-06', array('dmy')), 'Expected valid dd/mm/yy date format');
+ $this->assertTrue($validation->date('27.12.06', array('dmy')), 'Expected valid dd/mm/yy date format');
+ $this->assertTrue($validation->date('27/12/06', array('dmy')), 'Expected valid dd/mm/yy date format');
+ $this->assertTrue($validation->date('27 12 06', array('dmy')), 'Expected valid dd/mm/yy date format');
+ $this->assertFalse($validation->date('00-00-00', array('dmy')), 'Expected invalid dd/mm/yy date format');
+ $this->assertFalse($validation->date('00.00.00', array('dmy')), 'Expected invalid dd/mm/yy date format');
+ $this->assertFalse($validation->date('00/00/00', array('dmy')), 'Expected invalid dd/mm/yy date format');
+ $this->assertFalse($validation->date('00 00 00', array('dmy')), 'Expected invalid dd/mm/yy date format');
+ $this->assertFalse($validation->date('31-11-06', array('dmy')), 'Expected invalid dd/mm/yy date format');
+ $this->assertFalse($validation->date('31.11.06', array('dmy')), 'Expected invalid dd/mm/yy date format');
+ $this->assertFalse($validation->date('31/11/06', array('dmy')), 'Expected invalid dd/mm/yy date format');
+ $this->assertFalse($validation->date('31 11 06', array('dmy')), 'Expected invalid dd/mm/yy date format');
+ }
+
+ function testDateDdmmyyLeapYear() {
+ $validation = new Validation();
+ $this->assertTrue($validation->date('29-02-04', array('dmy')), 'Expected valid leap year dd/mm/yy date format');
+ $this->assertTrue($validation->date('29.02.04', array('dmy')), 'Expected valid leap year dd/mm/yy date format');
+ $this->assertTrue($validation->date('29/02/04', array('dmy')), 'Expected valid leap year dd/mm/yy date format');
+ $this->assertTrue($validation->date('29 02 04', array('dmy')), 'Expected valid leap year dd/mm/yy date format');
+ $this->assertFalse($validation->date('29-02-06', array('dmy')), 'Expected invalid leap year dd/mm/yy date format');
+ $this->assertFalse($validation->date('29.02.06', array('dmy')), 'Expected invalid leap year dd/mm/yy date format');
+ $this->assertFalse($validation->date('29/02/06', array('dmy')), 'Expected invalid leap year dd/mm/yy date format');
+ $this->assertFalse($validation->date('29 02 06', array('dmy')), 'Expected invalid leap year dd/mm/yy date format');
+ }
+
+ function testDateDmyy() {
+ $validation = new Validation();
+ $this->assertTrue($validation->date('7-2-06', array('dmy')), 'Expected valid d/m/yy date format');
+ $this->assertTrue($validation->date('7.2.06', array('dmy')), 'Expected valid d/m/yy date format');
+ $this->assertTrue($validation->date('7/2/06', array('dmy')), 'Expected valid d/m/yy date format');
+ $this->assertTrue($validation->date('7 2 06', array('dmy')), 'Expected valid d/m/yy date format');
+ $this->assertFalse($validation->date('0-0-00', array('dmy')), 'Expected invalid d/m/yy date format');
+ $this->assertFalse($validation->date('0.0.00', array('dmy')), 'Expected invalid d/m/yy date format');
+ $this->assertFalse($validation->date('0/0/00', array('dmy')), 'Expected invalid d/m/yy date format');
+ $this->assertFalse($validation->date('0 0 00', array('dmy')), 'Expected invalid d/m/yy date format');
+ $this->assertFalse($validation->date('32-2-06', array('dmy')), 'Expected invalid d/m/yy date format');
+ $this->assertFalse($validation->date('32.2.06', array('dmy')), 'Expected invalid d/m/yy date format');
+ $this->assertFalse($validation->date('32/2/06', array('dmy')), 'Expected invalid d/m/yy date format');
+ $this->assertFalse($validation->date('32 2 06', array('dmy')), 'Expected invalid d/m/yy date format');
+ }
+
+ function testDateDmyyLeapYear() {
+ $validation = new Validation();
+ $this->assertTrue($validation->date('29-2-04', array('dmy')), 'Expected valid leap year d/m/yy date format');
+ $this->assertTrue($validation->date('29.2.04', array('dmy')), 'Expected valid leap year d/m/yy date format');
+ $this->assertTrue($validation->date('29/2/04', array('dmy')), 'Expected valid leap year d/m/yy date format');
+ $this->assertTrue($validation->date('29 2 04', array('dmy')), 'Expected valid leap year d/m/yy date format');
+ $this->assertFalse($validation->date('29-2-06', array('dmy')), 'Expected invalid leap year d/m/yy date format');
+ $this->assertFalse($validation->date('29.2.06', array('dmy')), 'Expected invalid leap year d/m/yy date format');
+ $this->assertFalse($validation->date('29/2/06', array('dmy')), 'Expected invalid leap year d/m/yy date format');
+ $this->assertFalse($validation->date('29 2 06', array('dmy')), 'Expected invalid leap year d/m/yy date format');
+ }
+
+ function testDateDmyyyy() {
+ $validation = new Validation();
+ $this->assertTrue($validation->date('7-2-2006', array('dmy')), 'Expected valid d/m/yyyy date format');
+ $this->assertTrue($validation->date('7.2.2006', array('dmy')), 'Expected valid d/m/yyyy date format');
+ $this->assertTrue($validation->date('7/2/2006', array('dmy')), 'Expected valid d/m/yyyy date format');
+ $this->assertTrue($validation->date('7 2 2006', array('dmy')), 'Expected valid d/m/yyyy date format');
+ $this->assertFalse($validation->date('0-0-0000', array('dmy')), 'Expected invalid d/m/yyyy date format');
+ $this->assertFalse($validation->date('0.0.0000', array('dmy')), 'Expected invalid d/m/yyyy date format');
+ $this->assertFalse($validation->date('0/0/0000', array('dmy')), 'Expected invalid d/m/yyyy date format');
+ $this->assertFalse($validation->date('0 0 0000', array('dmy')), 'Expected invalid d/m/yyyy date format');
+ $this->assertFalse($validation->date('32-2-2006', array('dmy')), 'Expected invalid d/m/yyyy date format');
+ $this->assertFalse($validation->date('32.2.2006', array('dmy')), 'Expected invalid d/m/yyyy date format');
+ $this->assertFalse($validation->date('32/2/2006', array('dmy')), 'Expected invalid d/m/yyyy date format');
+ $this->assertFalse($validation->date('32 2 2006', array('dmy')), 'Expected invalid d/m/yyyy date format');
+ }
+
+ function testDateDmyyyyLeapYear() {
+ $validation = new Validation();
+ $this->assertTrue($validation->date('29-2-2004', array('dmy')), 'Expected valid leap year d/m/yyyy date format');
+ $this->assertTrue($validation->date('29.2.2004', array('dmy')), 'Expected valid leap year d/m/yyyy date format');
+ $this->assertTrue($validation->date('29/2/2004', array('dmy')), 'Expected valid leap year d/m/yyyy date format');
+ $this->assertTrue($validation->date('29 2 2004', array('dmy')), 'Expected valid leap year d/m/yyyy date format');
+ $this->assertFalse($validation->date('29-2-2006', array('dmy')), 'Expected invalid leap year d/m/yyyy date format');
+ $this->assertFalse($validation->date('29.2.2006', array('dmy')), 'Expected invalid leap year d/m/yyyy date format');
+ $this->assertFalse($validation->date('29/2/2006', array('dmy')), 'Expected invalid leap year d/m/yyyy date format');
+ $this->assertFalse($validation->date('29 2 2006', array('dmy')), 'Expected invalid leap year d/m/yyyy date format');
+ }
+
+ function testDateMmddyyyy() {
+ $validation = new Validation();
+ $this->assertTrue($validation->date('12-27-2006', array('mdy')), 'Expected valid mm/dd/yyyy date format');
+ $this->assertTrue($validation->date('12.27.2006', array('mdy')), 'Expected valid mm/dd/yyyy date format');
+ $this->assertTrue($validation->date('12/27/2006', array('mdy')), 'Expected valid mm/dd/yyyy date format');
+ $this->assertTrue($validation->date('12 27 2006', array('mdy')), 'Expected valid mm/dd/yyyy date format');
+ $this->assertFalse($validation->date('00-00-0000', array('mdy')), 'Expected invalid mm/dd/yyyy date format');
+ $this->assertFalse($validation->date('00.00.0000', array('mdy')), 'Expected invalid mm/dd/yyyy date format');
+ $this->assertFalse($validation->date('00/00/0000', array('mdy')), 'Expected invalid mm/dd/yyyy date format');
+ $this->assertFalse($validation->date('00 00 0000', array('mdy')), 'Expected invalid mm/dd/yyyy date format');
+ $this->assertFalse($validation->date('11-31-2006', array('mdy')), 'Expected invalid mm/dd/yyyy date format');
+ $this->assertFalse($validation->date('11.31.2006', array('mdy')), 'Expected invalid mm/dd/yyyy date format');
+ $this->assertFalse($validation->date('11/31/2006', array('mdy')), 'Expected invalid mm/dd/yyyy date format');
+ $this->assertFalse($validation->date('11 31 2006', array('mdy')), 'Expected invalid mm/dd/yyyy date format');
+ }
+
+ function testDateMmddyyyyLeapYear() {
+ $validation = new Validation();
+ $this->assertTrue($validation->date('02-29-2004', array('mdy')), 'Expected valid leap year mm/dd/yyyy date format');
+ $this->assertTrue($validation->date('02.29.2004', array('mdy')), 'Expected valid leap year mm/dd/yyyy date format');
+ $this->assertTrue($validation->date('02/29/2004', array('mdy')), 'Expected valid leap year mm/dd/yyyy date format');
+ $this->assertTrue($validation->date('02 29 2004', array('mdy')), 'Expected valid leap year mm/dd/yyyy date format');
+ $this->assertFalse($validation->date('02-29-2006', array('mdy')), 'Expected invalid leap year mm/dd/yyyy date format');
+ $this->assertFalse($validation->date('02.29.2006', array('mdy')), 'Expected invalid leap year mm/dd/yyyy date format');
+ $this->assertFalse($validation->date('02/29/2006', array('mdy')), 'Expected invalid leap year mm/dd/yyyy date format');
+ $this->assertFalse($validation->date('02 29 2006', array('mdy')), 'Expected invalid leap year mm/dd/yyyy date format');
+ }
+
+ function testDateMmddyy() {
+ $validation = new Validation();
+ $this->assertTrue($validation->date('12-27-06', array('mdy')), 'Expected valid mm/dd/yy date format');
+ $this->assertTrue($validation->date('12.27.06', array('mdy')), 'Expected valid mm/dd/yy date format');
+ $this->assertTrue($validation->date('12/27/06', array('mdy')), 'Expected valid mm/dd/yy date format');
+ $this->assertTrue($validation->date('12 27 06', array('mdy')), 'Expected valid mm/dd/yy date format');
+ $this->assertFalse($validation->date('00-00-00', array('mdy')), 'Expected invalid mm/dd/yy date format');
+ $this->assertFalse($validation->date('00.00.00', array('mdy')), 'Expected invalid mm/dd/yy date format');
+ $this->assertFalse($validation->date('00/00/00', array('mdy')), 'Expected invalid mm/dd/yy date format');
+ $this->assertFalse($validation->date('00 00 00', array('mdy')), 'Expected invalid mm/dd/yy date format');
+ $this->assertFalse($validation->date('11-31-06', array('mdy')), 'Expected invalid mm/dd/yy date format');
+ $this->assertFalse($validation->date('11.31.06', array('mdy')), 'Expected invalid mm/dd/yy date format');
+ $this->assertFalse($validation->date('11/31/06', array('mdy')), 'Expected invalid mm/dd/yy date format');
+ $this->assertFalse($validation->date('11 31 06', array('mdy')), 'Expected invalid mm/dd/yy date format');
+ }
+
+ function testDateMmddyyLeapYear() {
+ $validation = new Validation();
+ $this->assertTrue($validation->date('02-29-04', array('mdy')), 'Expected valid leap year mm/dd/yy date format');
+ $this->assertTrue($validation->date('02.29.04', array('mdy')), 'Expected valid leap year mm/dd/yy date format');
+ $this->assertTrue($validation->date('02/29/04', array('mdy')), 'Expected valid leap year mm/dd/yy date format');
+ $this->assertTrue($validation->date('02 29 04', array('mdy')), 'Expected valid leap year mm/dd/yy date format');
+ $this->assertFalse($validation->date('02-29-06', array('mdy')), 'Expected invalid leap year mm/dd/yy date format');
+ $this->assertFalse($validation->date('02.29.06', array('mdy')), 'Expected invalid leap year mm/dd/yy date format');
+ $this->assertFalse($validation->date('02/29/06', array('mdy')), 'Expected invalid leap year mm/dd/yy date format');
+ $this->assertFalse($validation->date('02 29 06', array('mdy')), 'Expected invalid leap year mm/dd/yy date format');
+ }
+
+ function testDateMdyy() {
+ $validation = new Validation();
+ $this->assertTrue($validation->date('2-7-06', array('mdy')), 'Expected valid m/d/yy date format');
+ $this->assertTrue($validation->date('2.7.06', array('mdy')), 'Expected valid m/d/yy date format');
+ $this->assertTrue($validation->date('2/7/06', array('mdy')), 'Expected valid m/d/yy date format');
+ $this->assertTrue($validation->date('2 7 06', array('mdy')), 'Expected valid m/d/yy date format');
+ $this->assertFalse($validation->date('0-0-00', array('mdy')), 'Expected invalid m/d/yy date format');
+ $this->assertFalse($validation->date('0.0.00', array('mdy')), 'Expected invalid m/d/yy date format');
+ $this->assertFalse($validation->date('0/0/00', array('mdy')), 'Expected invalid m/d/yy date format');
+ $this->assertFalse($validation->date('0 0 00', array('mdy')), 'Expected invalid m/d/yy date format');
+ $this->assertFalse($validation->date('2-32-06', array('mdy')), 'Expected invalid m/d/yy date format');
+ $this->assertFalse($validation->date('2.32.06', array('mdy')), 'Expected invalid m/d/yy date format');
+ $this->assertFalse($validation->date('2/32/06', array('mdy')), 'Expected invalid m/d/yy date format');
+ $this->assertFalse($validation->date('2 32 06', array('mdy')), 'Expected invalid m/d/yy date format');
+ }
+
+ function testDateMdyyLeapYear() {
+ $validation = new Validation();
+ $this->assertTrue($validation->date('2-29-04', array('mdy')), 'Expected valid leap year m/d/yy date format');
+ $this->assertTrue($validation->date('2.29.04', array('mdy')), 'Expected valid leap year m/d/yy date format');
+ $this->assertTrue($validation->date('2/29/04', array('mdy')), 'Expected valid leap year m/d/yy date format');
+ $this->assertTrue($validation->date('2 29 04', array('mdy')), 'Expected valid leap year m/d/yy date format');
+ $this->assertFalse($validation->date('2-29-06', array('mdy')), 'Expected invalid leap year m/d/yy date format');
+ $this->assertFalse($validation->date('2.29.06', array('mdy')), 'Expected invalid leap year m/d/yy date format');
+ $this->assertFalse($validation->date('2/29/06', array('mdy')), 'Expected invalid leap year m/d/yy date format');
+ $this->assertFalse($validation->date('2 29 06', array('mdy')), 'Expected invalid leap year m/d/yy date format');
+ }
+
+ function testDateMdyyyy() {
+ $validation = new Validation();
+ $this->assertTrue($validation->date('2-7-2006', array('mdy')), 'Expected valid m/d/yyyy date format');
+ $this->assertTrue($validation->date('2.7.2006', array('mdy')), 'Expected valid m/d/yyyy date format');
+ $this->assertTrue($validation->date('2/7/2006', array('mdy')), 'Expected valid m/d/yyyy date format');
+ $this->assertTrue($validation->date('2 7 2006', array('mdy')), 'Expected valid m/d/yyyy date format');
+ $this->assertFalse($validation->date('0-0-0000', array('mdy')), 'Expected invalid m/d/yyyy date format');
+ $this->assertFalse($validation->date('0.0.0000', array('mdy')), 'Expected invalid m/d/yyyy date format');
+ $this->assertFalse($validation->date('0/0/0000', array('mdy')), 'Expected invalid m/d/yyyy date format');
+ $this->assertFalse($validation->date('0 0 0000', array('mdy')), 'Expected invalid m/d/yyyy date format');
+ $this->assertFalse($validation->date('2-32-2006', array('mdy')), 'Expected invalid m/d/yyyy date format');
+ $this->assertFalse($validation->date('2.32.2006', array('mdy')), 'Expected invalid m/d/yyyy date format');
+ $this->assertFalse($validation->date('2/32/2006', array('mdy')), 'Expected invalid m/d/yyyy date format');
+ $this->assertFalse($validation->date('2 32 2006', array('mdy')), 'Expected invalid m/d/yyyy date format');
+ }
+
+ function testDateMdyyyyLeapYear() {
+ $validation = new Validation();
+ $this->assertTrue($validation->date('2-29-2004', array('mdy')), 'Expected valid leap year m/d/yyyy date format');
+ $this->assertTrue($validation->date('2.29.2004', array('mdy')), 'Expected valid leap year m/d/yyyy date format');
+ $this->assertTrue($validation->date('2/29/2004', array('mdy')), 'Expected valid leap year m/d/yyyy date format');
+ $this->assertTrue($validation->date('2 29 2004', array('mdy')), 'Expected valid leap year m/d/yyyy date format');
+ $this->assertFalse($validation->date('2-29-2006', array('mdy')), 'Expected invalid leap year m/d/yyyy date format');
+ $this->assertFalse($validation->date('2.29.2006', array('mdy')), 'Expected invalid leap year m/d/yyyy date format');
+ $this->assertFalse($validation->date('2/29/2006', array('mdy')), 'Expected invalid leap year m/d/yyyy date format');
+ $this->assertFalse($validation->date('2 29 2006', array('mdy')), 'Expected invalid leap year m/d/yyyy date format');
+ }
+
+ function testDateYyyymmdd() {
+ $validation = new Validation();
+ $this->assertTrue($validation->date('2006-12-27', array('ymd')), 'Expected valid yyyy/mm/dd date format');
+ $this->assertTrue($validation->date('2006.12.27', array('ymd')), 'Expected valid yyyy/mm/dd date format');
+ $this->assertTrue($validation->date('2006/12/27', array('ymd')), 'Expected valid yyyy/mm/dd date format');
+ $this->assertTrue($validation->date('2006 12 27', array('ymd')), 'Expected valid yyyy/mm/dd date format');
+ $this->assertFalse($validation->date('2006-11-31', array('ymd')), 'Expected invalid yyyy/mm/dd date format');
+ $this->assertFalse($validation->date('2006.11.31', array('ymd')), 'Expected invalid yyyy/mm/dd date format');
+ $this->assertFalse($validation->date('2006/11/31', array('ymd')), 'Expected invalid yyyy/mm/dd date format');
+ $this->assertFalse($validation->date('2006 11 31', array('ymd')), 'Expected invalid yyyy/mm/dd date format');
+ }
+
+ function testDateYyyymmddLeapYear() {
+ $validation = new Validation();
+ $this->assertTrue($validation->date('2004-02-29', array('ymd')), 'Expected valid leap year yyyy/mm/dd date format');
+ $this->assertTrue($validation->date('2004.02.29', array('ymd')), 'Expected valid leap year yyyy/mm/dd date format');
+ $this->assertTrue($validation->date('2004/02/29', array('ymd')), 'Expected valid leap year yyyy/mm/dd date format');
+ $this->assertTrue($validation->date('2004 02 29', array('ymd')), 'Expected valid leap year yyyy/mm/dd date format');
+ $this->assertFalse($validation->date('2006-02-29', array('ymd')), 'Expected invalid leap year yyyy/mm/dd date format');
+ $this->assertFalse($validation->date('2006.02.29', array('ymd')), 'Expected invalid leap year yyyy/mm/dd date format');
+ $this->assertFalse($validation->date('2006/02/29', array('ymd')), 'Expected invalid leap year yyyy/mm/dd date format');
+ $this->assertFalse($validation->date('2006 02 29', array('ymd')), 'Expected invalid leap year yyyy/mm/dd date format');
+ }
+
+ function testDateYymmdd() {
+ $validation = new Validation();
+ $this->assertTrue($validation->date('06-12-27', array('ymd')), 'Expected valid yyyy/mm/dd date format');
+ $this->assertTrue($validation->date('06.12.27', array('ymd')), 'Expected valid yyyy/mm/dd date format');
+ $this->assertTrue($validation->date('06/12/27', array('ymd')), 'Expected valid yyyy/mm/dd date format');
+ $this->assertTrue($validation->date('06 12 27', array('ymd')), 'Expected valid yyyy/mm/dd date format');
+ $this->assertFalse($validation->date('12/27/2600', array('ymd')), 'Expected invalid yyyy/mm/dd date format');
+ $this->assertFalse($validation->date('12.27.2600', array('ymd')), 'Expected invalid yyyy/mm/dd date format');
+ $this->assertFalse($validation->date('12/27/2600', array('ymd')), 'Expected invalid yyyy/mm/dd date format');
+ $this->assertFalse($validation->date('12 27 2600', array('ymd')), 'Expected invalid yyyy/mm/dd date format');
+ $this->assertFalse($validation->date('06-11-31', array('ymd')), 'Expected invalid yyyy/mm/dd date format');
+ $this->assertFalse($validation->date('06.11.31', array('ymd')), 'Expected invalid yyyy/mm/dd date format');
+ $this->assertFalse($validation->date('06/11/31', array('ymd')), 'Expected invalid yyyy/mm/dd date format');
+ $this->assertFalse($validation->date('06 11 31', array('ymd')), 'Expected invalid yyyy/mm/dd date format');
+ }
+
+ function testDateYymmddLeapYear() {
+ $validation = new Validation();
+ $this->assertTrue($validation->date('2004-02-29', array('ymd')), 'Expected valid leap year yyyy/mm/dd date format');
+ $this->assertTrue($validation->date('2004.02.29', array('ymd')), 'Expected valid leap year yyyy/mm/dd date format');
+ $this->assertTrue($validation->date('2004/02/29', array('ymd')), 'Expected valid leap year yyyy/mm/dd date format');
+ $this->assertTrue($validation->date('2004 02 29', array('ymd')), 'Expected valid leap year yyyy/mm/dd date format');
+ $this->assertFalse($validation->date('2006-02-29', array('ymd')), 'Expected invalid leap year yyyy/mm/dd date format');
+ $this->assertFalse($validation->date('2006.02.29', array('ymd')), 'Expected invalid leap year yyyy/mm/dd date format');
+ $this->assertFalse($validation->date('2006/02/29', array('ymd')), 'Expected invalid leap year yyyy/mm/dd date format');
+ $this->assertFalse($validation->date('2006 02 29', array('ymd')), 'Expected invalid leap year yyyy/mm/dd date format');
+ }
+
+ function testDateDdMMMMyyyy() {
+ $validation = new Validation();
+ $this->assertTrue($validation->date('27 December 2006', array('dMy')), 'Expected valid dd/MMMM/yyyy date format');
+ $this->assertTrue($validation->date('27 Dec 2006', array('dMy')), 'Expected valid dd/MM/yyyy date format');
+ $this->assertFalse($validation->date('2006 Dec 27', array('dMy')), 'Expected invalid dd/MMM/yyyy date format');
+ $this->assertFalse($validation->date('2006 December 27', array('dMy')), 'Expected invalid dd/MMMM/yyyy date format');
+ }
+
+ function testDateDdMMMMyyyyLeapYear() {
+ $validation = new Validation();
+ $this->assertTrue($validation->date('29 February 2004', array('dMy')), 'Expected valid leap year dd/MMMM/yyyy date format');
+ $this->assertFalse($validation->date('29 February 2006', array('dMy')), 'Expected invalid leap yeay dd/MMMM/yyyy date format');
+ }
+
+ function testDateMmmmDdyyyy() {
+ $validation = new Validation();
+ $this->assertTrue($validation->date('December 27, 2006', array('Mdy')), 'Expected valid MMMM/dd/yyyy date format');
+ $this->assertTrue($validation->date('Dec 27, 2006', array('Mdy')), 'Expected valid MM/dd/yyyy date format');
+ $this->assertTrue($validation->date('December 27 2006', array('Mdy')), 'Expected valid MMMM/dd/yyyy date format');
+ $this->assertTrue($validation->date('Dec 27 2006', array('Mdy')), 'Expected valid MM/dd/yyyy date format');
+ $this->assertFalse($validation->date('27 Dec 2006', array('Mdy')), 'Expected invalid dd/MMM/yyyy date format');
+ $this->assertFalse($validation->date('2006 December 27', array('Mdy')), 'Expected invalid dd/MMMM/yyyy date format');
+ }
+
+ function testDateMmmmDdyyyyLeapYear() {
+ $validation = new Validation();
+ $this->assertTrue($validation->date('February 29, 2004', array('Mdy')), 'Expected valid leap year MMMM/dd/yyyy date format');
+ $this->assertTrue($validation->date('Feb 29, 2004', array('Mdy')), 'Expected valid leap year MMMM/dd/yyyy date format');
+ $this->assertTrue($validation->date('February 29 2004', array('Mdy')), 'Expected valid leap year MMMM/dd/yyyy date format');
+ $this->assertTrue($validation->date('Feb 29 2004', array('Mdy')), 'Expected valid leap year MMMM/dd/yyyy date format');
+ $this->assertFalse($validation->date('February 29, 2006', array('Mdy')), 'Expected invalid leap yeay MMMM/dd/yyyy date format');
+ }
+
+ function testDateMy() {
+ $validation = new Validation();
+ $this->assertTrue($validation->date('December 2006', array('My')), 'Expected valid MMMM/yyyy date format');
+ $this->assertTrue($validation->date('Dec 2006', array('My')), 'Expected valid MM/yyyyy date format');
+ $this->assertTrue($validation->date('December/2006', array('My')), 'Expected valid MMMM/yyyy date format');
+ $this->assertTrue($validation->date('Dec/2006', array('My')), 'Expected valid MM/yyyy date format');
+ }
+
+ function testDateMyNumeric() {
+ $validation = new Validation();
+ $this->assertTrue($validation->date('12/2006', array('my')), 'Expected valid mm/yyyy date format');
+ $this->assertTrue($validation->date('12-2006', array('my')), 'Expected valid mm/yyyy date format');
+ $this->assertTrue($validation->date('12.2006', array('my')), 'Expected valid mm/yyyy date format');
+ $this->assertTrue($validation->date('12 2006', array('my')), 'Expected valid MM/yyyy date format');
+ $this->assertFalse($validation->date('12/06', array('my')), 'Expected invalid mm/yy date format');
+ $this->assertFalse($validation->date('12-06', array('my')), 'Expected invalid mm/yy date format');
+ $this->assertFalse($validation->date('12.06', array('my')), 'Expected invalid mm/yy date format');
+ $this->assertFalse($validation->date('12 06', array('my')), 'Expected invalid MM/yy date format');
+ }
+
+ function testDateCustomRegx() {
+ $validation = new Validation();
+ $this->assertTrue($validation->date('2006-12-27', null, '%^(19|20)[0-9]{2}[- /.](0[1-9]|1[012])[- /.](0[1-9]|[12][0-9]|3[01])$%'), 'Expected valid custom regex to match date');
+ $this->assertFalse($validation->date('12-27-2006', null, '%^(19|20)[0-9]{2}[- /.](0[1-9]|1[012])[- /.](0[1-9]|[12][0-9]|3[01])$%'), 'Expected valid custom regex to match date');
+ }
+
+ function testDecimal() {
+ $validation = new Validation();
+ $this->assertTrue($validation->decimal('+1234.54321'), 'Expected valid decimal');
+ $this->assertTrue($validation->decimal('-1234.54321'), 'Expected valid decimal');
+ $this->assertTrue($validation->decimal('1234.54321'), 'Expected valid decimal');
+ $this->assertTrue($validation->decimal('+0123.45e6'), 'Expected valid decimal');
+ $this->assertTrue($validation->decimal('-0123.45e6'), 'Expected valid decimal');
+ $this->assertTrue($validation->decimal('0123.45e6'), 'Expected valid decimal');
+ $this->assertFalse($validation->decimal('string'), 'Expected invalid string');
+ $this->assertFalse($validation->decimal('1234'), 'Expected invalid integer');
+ $this->assertFalse($validation->decimal('-1234'), 'Expected invalid integer');
+ $this->assertFalse($validation->decimal('+1234'), 'Expected invalid integer');
+ }
+
+ function testDecimalWithPlaces() {
+ $validation = new Validation();
+ $this->assertTrue($validation->decimal('.27', '2'), 'Expected valid 2 decimal places');
+ $this->assertTrue($validation->decimal(.27, 2), 'Expected valid 2 decimal places');
+ $this->assertTrue($validation->decimal(-.27, 2), 'Expected valid 2 decimal places');
+ $this->assertTrue($validation->decimal(+.27, 2), 'Expected valid 2 decimal places');
+ $this->assertTrue($validation->decimal('.277', '3'), 'Expected valid 3 decimal places');
+ $this->assertTrue($validation->decimal(.277, 3), 'Expected valid 3 decimal places');
+ $this->assertTrue($validation->decimal(-.277, 3), 'Expected valid 3 decimal places');
+ $this->assertTrue($validation->decimal(+.277, 3), 'Expected valid 3 decimal places');
+ $this->assertTrue($validation->decimal('1234.5678', '4'), 'Expected valid 4 decimal places');
+ $this->assertTrue($validation->decimal(1234.5678, 4), 'Expected valid 4 decimal places');
+ $this->assertTrue($validation->decimal(-1234.5678, 4), 'Expected valid 4 decimal places');
+ $this->assertTrue($validation->decimal(+1234.5678, 4), 'Expected valid 4 decimal places');
+ $this->assertFalse($validation->decimal('1234.5678', '3'), 'Expected invalid 4 decimal places');
+ $this->assertFalse($validation->decimal(1234.5678, 3), 'Expected invalid 4 decimal places');
+ $this->assertFalse($validation->decimal(-1234.5678, 3), 'Expected invalid 4 decimal places');
+ $this->assertFalse($validation->decimal(+1234.5678, 3), 'Expected invalid 4 decimal places');
+ }
+
+ function testDecimalCustomRegex() {
+ $validation = new Validation();
+ $this->assertTrue($validation->decimal('1.54321', null, '/^[-+]?[0-9]+(\\.[0-9]+)?$/s'), 'Expected valid integer and decimal');
+ $this->assertFalse($validation->decimal('.54321', null, '/^[-+]?[0-9]+(\\.[0-9]+)?$/s'), 'Expected invalid decimal only');
+ }
+
+ function testEmail() {
+ $validation = new Validation();
+ $this->assertTrue($validation->email('abc.efg@domain.com'), 'Expected valid email');
+ $this->assertTrue($validation->email('efg@domain.com'), 'Expected valid email');
+ $this->assertTrue($validation->email('abc-efg@domain.com'), 'Expected valid email');
+ $this->assertTrue($validation->email('abc_efg@domain.com'), 'Expected valid email');
+ $this->assertFalse($validation->email('abc@efg@domain.com'), 'Expected valid email');
+ }
+/*
+ //Commented out because test is slow, but it does work
+ function testEmailDeep() {
+ $validation = new Validation();
+ $this->assertTrue($validation->email('abc.efg@cakephp.org', true), 'Expected valid email');
+ $this->assertFalse($validation->email('abc.efg@caphpkeinvalid.com', true), 'Expected valid email');
+ }
+*/
+ function testEmailCustomRegex() {
+ $validation = new Validation();
+ $this->assertTrue($validation->email('abc.efg@cakephp.org', null, '/^[A-Z0-9._%-]+@[A-Z0-9.-]+\\.[A-Z]{2,4}$/i'), 'Expected valid email');
+ $this->assertFalse($validation->email('abc.efg@com.caphpkeinvalid', null, '/^[A-Z0-9._%-]+@[A-Z0-9.-]+\\.[A-Z]{2,4}$/i'), 'Expected valid email');
+ }
+
+ function testIp() {
+ $validation = new Validation();
+ $this->assertTrue($validation->ip('0.0.0.0'), 'Expected valid IP address');
+ $this->assertTrue($validation->ip('255.255.255.255'), 'Expected valid IP address');
+ $this->assertFalse($validation->ip('127.0.0'), 'Expected invalid IP address');
+ $this->assertFalse($validation->ip('127.0.0.a'), 'Expected invalid IP address');
+ $this->assertFalse($validation->ip('127.0.0.256'), 'Expected invalid IP address');
+ }
+
+ function testMaxLength() {
+ $validation = new Validation();
+ $this->assertTrue($validation->maxLength('ab', 3), 'Expected valid length');
+ $this->assertTrue($validation->maxLength('abc', 3), 'Expected valid length');
+ $this->assertFalse($validation->maxLength('abcd', 3), 'Expected invalid length');
+ }
+
+ function testMinLength() {
+ $validation = new Validation();
+ $this->assertFalse($validation->minLength('ab', 3), 'Expected invalid length');
+ $this->assertTrue($validation->minLength('abc', 3), 'Expected valid length');
+ $this->assertTrue($validation->minLength('abcd', 3), 'Expected valid length');
+ }
+
+ function testUrl() {
+ $validation = new Validation();
+ $this->assertTrue($validation->url('https://my.gizmoproject.com/gizmo/app?class=MySip;proc=start'), 'Expected valid url');
+ }
+}
+?>
\ No newline at end of file
diff --git a/cake/tests/cases/libs/view/helpers/ajax.test.php b/cake/tests/cases/libs/view/helpers/ajax.test.php
new file mode 100644
index 000000000..177ce37f1
--- /dev/null
+++ b/cake/tests/cases/libs/view/helpers/ajax.test.php
@@ -0,0 +1,61 @@
+
+ * 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 = '';
+ $this->assertEqual($result, $expected, "Error generating script.aculo.us draggable object, expected '{$expected}', got '{$result}'.");
+ }
+
+ function tearDown() {
+ unset($this->ajax);
+ }
+}
+
+?>
\ No newline at end of file
diff --git a/cake/tests/cases/libs/view/helpers/paginator.test.php b/cake/tests/cases/libs/view/helpers/paginator.test.php
new file mode 100644
index 000000000..97e28a561
--- /dev/null
+++ b/cake/tests/cases/libs/view/helpers/paginator.test.php
@@ -0,0 +1,85 @@
+
+ * 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);
+ }
+}
+
+?>
\ No newline at end of file
diff --git a/cake/tests/groups/all_tests.group.php b/cake/tests/groups/all_tests.group.php
new file mode 100644
index 000000000..a951e49f9
--- /dev/null
+++ b/cake/tests/groups/all_tests.group.php
@@ -0,0 +1,42 @@
+
+ * 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);
+ }
+}
+
+?>
\ No newline at end of file
diff --git a/cake/tests/groups/lib.group.php b/cake/tests/groups/lib.group.php
new file mode 100644
index 000000000..003175197
--- /dev/null
+++ b/cake/tests/groups/lib.group.php
@@ -0,0 +1,43 @@
+
+ * 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');
+ }
+}
+?>
\ No newline at end of file
diff --git a/cake/tests/groups/lib_controller.group.php b/cake/tests/groups/lib_controller.group.php
new file mode 100644
index 000000000..bdf843cdc
--- /dev/null
+++ b/cake/tests/groups/lib_controller.group.php
@@ -0,0 +1,42 @@
+
+ * 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');
+ }
+}
+?>
\ No newline at end of file