|
|
@@ -4,9 +4,9 @@ App::uses('MyCakeTestCase', 'Tools.TestSuite');
|
|
|
|
|
|
class MyModelTest extends MyCakeTestCase {
|
|
|
|
|
|
- public $Model;
|
|
|
+ public $Post;
|
|
|
|
|
|
- public $App;
|
|
|
+ public $User;
|
|
|
|
|
|
public $modelName = 'User';
|
|
|
|
|
|
@@ -15,25 +15,25 @@ class MyModelTest extends MyCakeTestCase {
|
|
|
public function setUp() {
|
|
|
parent::setUp();
|
|
|
|
|
|
- $this->Model = ClassRegistry::init('MyAppModelPost');
|
|
|
+ $this->Post = ClassRegistry::init('MyAppModelPost');
|
|
|
|
|
|
- $this->App = ClassRegistry::init('MyAppModelUser');
|
|
|
+ $this->User = ClassRegistry::init('MyAppModelUser');
|
|
|
}
|
|
|
|
|
|
public function testObject() {
|
|
|
- $this->Model = ClassRegistry::init('MyModel');
|
|
|
- $this->assertTrue(is_object($this->Model));
|
|
|
- $this->assertInstanceOf('MyModel', $this->Model);
|
|
|
+ $this->Post = ClassRegistry::init('MyModel');
|
|
|
+ $this->assertTrue(is_object($this->Post));
|
|
|
+ $this->assertInstanceOf('MyModel', $this->Post);
|
|
|
}
|
|
|
|
|
|
public function testGet() {
|
|
|
- $record = $this->Model->get(2);
|
|
|
+ $record = $this->Post->get(2);
|
|
|
$this->assertEquals(2, $record['Post']['id']);
|
|
|
|
|
|
- $record = $this->Model->get(2, array('fields' => 'id', 'created'));
|
|
|
+ $record = $this->Post->get(2, array('fields' => 'id', 'created'));
|
|
|
$this->assertEquals(2, count($record['Post']));
|
|
|
|
|
|
- $record = $this->Model->get(2, array('fields' => 'id', 'title', 'body'), array('Author'));
|
|
|
+ $record = $this->Post->get(2, array('fields' => 'id', 'title', 'body'), array('Author'));
|
|
|
$this->assertEquals(3, $record['Author']['id']);
|
|
|
}
|
|
|
|
|
|
@@ -60,8 +60,8 @@ class MyModelTest extends MyCakeTestCase {
|
|
|
* More tests in MyModel Test directly
|
|
|
*/
|
|
|
public function testGetFalse() {
|
|
|
- $this->App->order = array();
|
|
|
- $is = $this->App->get('xyz');
|
|
|
+ $this->User->order = array();
|
|
|
+ $is = $this->User->get('xyz');
|
|
|
$this->assertSame(array(), $is);
|
|
|
}
|
|
|
|
|
|
@@ -70,10 +70,10 @@ class MyModelTest extends MyCakeTestCase {
|
|
|
*/
|
|
|
public function testGetNextAutoIncrement() {
|
|
|
$this->out($this->_header(__FUNCTION__), true);
|
|
|
- $is = $this->App->getNextAutoIncrement();
|
|
|
+ $is = $this->User->getNextAutoIncrement();
|
|
|
$this->out(returns($is));
|
|
|
|
|
|
- $schema = $this->App->schema('id');
|
|
|
+ $schema = $this->User->schema('id');
|
|
|
if ($schema['length'] == 36) {
|
|
|
$this->assertFalse($is);
|
|
|
} else {
|
|
|
@@ -83,10 +83,10 @@ class MyModelTest extends MyCakeTestCase {
|
|
|
|
|
|
public function testDeconstruct() {
|
|
|
$data = array('year' => '2010', 'month' => '10', 'day' => 11);
|
|
|
- $res = $this->App->deconstruct('User.dob', $data);
|
|
|
+ $res = $this->User->deconstruct('User.dob', $data);
|
|
|
$this->assertEquals('2010-10-11', $res);
|
|
|
|
|
|
- $res = $this->App->deconstruct('User.dob', $data, 'datetime');
|
|
|
+ $res = $this->User->deconstruct('User.dob', $data, 'datetime');
|
|
|
$this->assertEquals('2010-10-11 00:00:00', $res);
|
|
|
}
|
|
|
|
|
|
@@ -94,26 +94,26 @@ class MyModelTest extends MyCakeTestCase {
|
|
|
* Test that strings are correctly escaped using '
|
|
|
*/
|
|
|
public function testEscapeValue() {
|
|
|
- $res = $this->App->escapeValue(4);
|
|
|
+ $res = $this->User->escapeValue(4);
|
|
|
$this->assertSame(4, $res);
|
|
|
|
|
|
- $res = $this->App->escapeValue('4');
|
|
|
+ $res = $this->User->escapeValue('4');
|
|
|
$this->assertSame('4', $res);
|
|
|
|
|
|
- $res = $this->App->escapeValue('a');
|
|
|
+ $res = $this->User->escapeValue('a');
|
|
|
$this->assertSame('\'a\'', $res);
|
|
|
|
|
|
- $res = $this->App->escapeValue(true);
|
|
|
+ $res = $this->User->escapeValue(true);
|
|
|
$this->assertSame(1, $res);
|
|
|
|
|
|
- $res = $this->App->escapeValue(false);
|
|
|
+ $res = $this->User->escapeValue(false);
|
|
|
$this->assertSame(0, $res);
|
|
|
|
|
|
- $res = $this->App->escapeValue(null);
|
|
|
+ $res = $this->User->escapeValue(null);
|
|
|
$this->assertSame(null, $res);
|
|
|
|
|
|
# comparison to cakes escapeField here (which use ` to escape)
|
|
|
- $res = $this->App->escapeField('dob');
|
|
|
+ $res = $this->User->escapeField('dob');
|
|
|
$this->assertSame('`User`.`dob`', $res);
|
|
|
}
|
|
|
|
|
|
@@ -122,13 +122,13 @@ class MyModelTest extends MyCakeTestCase {
|
|
|
array('title' => 'x', 'body' => 'bx'),
|
|
|
array('title' => 'y', 'body' => 'by'),
|
|
|
);
|
|
|
- $result = $this->App->saveAll($records);
|
|
|
+ $result = $this->User->saveAll($records);
|
|
|
$this->assertTrue($result);
|
|
|
|
|
|
- $result = $this->App->saveAll($records, array('atomic' => false));
|
|
|
+ $result = $this->User->saveAll($records, array('atomic' => false));
|
|
|
$this->assertTrue($result);
|
|
|
|
|
|
- $result = $this->App->saveAll($records, array('atomic' => false, 'returnArray' => true));
|
|
|
+ $result = $this->User->saveAll($records, array('atomic' => false, 'returnArray' => true));
|
|
|
$expected = array(true, true);
|
|
|
$this->assertSame($expected, $result);
|
|
|
}
|
|
|
@@ -139,14 +139,14 @@ class MyModelTest extends MyCakeTestCase {
|
|
|
* @return void
|
|
|
*/
|
|
|
public function testDeleteAllRaw() {
|
|
|
- $result = $this->App->deleteAllRaw(array('user !=' => 'foo', 'created <' => date(FORMAT_DB_DATE), 'id >' => 1));
|
|
|
+ $result = $this->User->deleteAllRaw(array('user !=' => 'foo', 'created <' => date(FORMAT_DB_DATE), 'id >' => 1));
|
|
|
$this->assertTrue($result);
|
|
|
- $result = $this->App->getAffectedRows();
|
|
|
+ $result = $this->User->getAffectedRows();
|
|
|
$this->assertIdentical(3, $result);
|
|
|
|
|
|
- $result = $this->App->deleteAllRaw();
|
|
|
+ $result = $this->User->deleteAllRaw();
|
|
|
$this->assertTrue($result);
|
|
|
- $result = $this->App->getAffectedRows();
|
|
|
+ $result = $this->User->getAffectedRows();
|
|
|
$this->assertIdentical(1, $result);
|
|
|
}
|
|
|
|
|
|
@@ -154,17 +154,17 @@ class MyModelTest extends MyCakeTestCase {
|
|
|
* Test truncate
|
|
|
*/
|
|
|
public function testTruncate() {
|
|
|
- $is = $this->App->find('count');
|
|
|
+ $is = $this->User->find('count');
|
|
|
$this->assertEquals(4, $is);
|
|
|
|
|
|
- $is = $this->App->getNextAutoIncrement();
|
|
|
+ $is = $this->User->getNextAutoIncrement();
|
|
|
$this->assertEquals(5, $is);
|
|
|
|
|
|
- $is = $this->App->truncate();
|
|
|
- $is = $this->App->find('count');
|
|
|
+ $is = $this->User->truncate();
|
|
|
+ $is = $this->User->find('count');
|
|
|
$this->assertEquals(0, $is);
|
|
|
|
|
|
- $is = $this->App->getNextAutoIncrement();
|
|
|
+ $is = $this->User->getNextAutoIncrement();
|
|
|
$this->assertEquals(1, $is);
|
|
|
}
|
|
|
|
|
|
@@ -220,26 +220,26 @@ class MyModelTest extends MyCakeTestCase {
|
|
|
|
|
|
public function testValidateIdentical() {
|
|
|
$this->out($this->_header(__FUNCTION__), true);
|
|
|
- $this->App->data = array($this->App->alias => array('y' => 'efg'));
|
|
|
- $is = $this->App->validateIdentical(array('x' => 'efg'), 'y');
|
|
|
+ $this->User->data = array($this->User->alias => array('y' => 'efg'));
|
|
|
+ $is = $this->User->validateIdentical(array('x' => 'efg'), 'y');
|
|
|
$this->assertTrue($is);
|
|
|
|
|
|
- $this->App->data = array($this->App->alias => array('y' => '2'));
|
|
|
- $is = $this->App->validateIdentical(array('x' => 2), 'y');
|
|
|
+ $this->User->data = array($this->User->alias => array('y' => '2'));
|
|
|
+ $is = $this->User->validateIdentical(array('x' => 2), 'y');
|
|
|
$this->assertFalse($is);
|
|
|
|
|
|
- $this->App->data = array($this->App->alias => array('y' => '3'));
|
|
|
- $is = $this->App->validateIdentical(array('x' => 3), 'y', array('cast' => 'int'));
|
|
|
+ $this->User->data = array($this->User->alias => array('y' => '3'));
|
|
|
+ $is = $this->User->validateIdentical(array('x' => 3), 'y', array('cast' => 'int'));
|
|
|
$this->assertTrue($is);
|
|
|
|
|
|
- $this->App->data = array($this->App->alias => array('y' => '3'));
|
|
|
- $is = $this->App->validateIdentical(array('x' => 3), 'y', array('cast' => 'string'));
|
|
|
+ $this->User->data = array($this->User->alias => array('y' => '3'));
|
|
|
+ $is = $this->User->validateIdentical(array('x' => 3), 'y', array('cast' => 'string'));
|
|
|
$this->assertTrue($is);
|
|
|
}
|
|
|
|
|
|
public function testValidateKey() {
|
|
|
$this->out($this->_header(__FUNCTION__), true);
|
|
|
- //$this->App->data = array($this->App->alias=>array('y'=>'efg'));
|
|
|
+ //$this->User->data = array($this->User->alias=>array('y'=>'efg'));
|
|
|
$testModel = new AppTestModel();
|
|
|
|
|
|
$is = $testModel->validateKey(array('id' => '2'));
|
|
|
@@ -284,7 +284,7 @@ class MyModelTest extends MyCakeTestCase {
|
|
|
|
|
|
public function testValidateEnum() {
|
|
|
$this->out($this->_header(__FUNCTION__), true);
|
|
|
- //$this->App->data = array($this->App->alias=>array('y'=>'efg'));
|
|
|
+ //$this->User->data = array($this->User->alias=>array('y'=>'efg'));
|
|
|
$testModel = new AppTestModel();
|
|
|
$is = $testModel->validateEnum(array('x' => '1'), true);
|
|
|
$this->assertTrue($is);
|
|
|
@@ -301,16 +301,16 @@ class MyModelTest extends MyCakeTestCase {
|
|
|
|
|
|
public function testGuaranteeFields() {
|
|
|
$this->out($this->_header(__FUNCTION__), true);
|
|
|
- $res = $this->App->guaranteeFields(array());
|
|
|
+ $res = $this->User->guaranteeFields(array());
|
|
|
//debug($res);
|
|
|
$this->assertTrue(empty($res));
|
|
|
|
|
|
- $res = $this->App->guaranteeFields(array('x', 'y'));
|
|
|
+ $res = $this->User->guaranteeFields(array('x', 'y'));
|
|
|
//debug($res);
|
|
|
$this->assertTrue(!empty($res));
|
|
|
$this->assertEquals($res, array($this->modelName => array('x' => '', 'y' => '')));
|
|
|
|
|
|
- $res = $this->App->guaranteeFields(array('x', 'OtherModel.y'));
|
|
|
+ $res = $this->User->guaranteeFields(array('x', 'OtherModel.y'));
|
|
|
//debug($res);
|
|
|
$this->assertTrue(!empty($res));
|
|
|
$this->assertEquals($res, array($this->modelName => array('x' => ''), 'OtherModel' => array('y' => '')));
|
|
|
@@ -319,14 +319,14 @@ class MyModelTest extends MyCakeTestCase {
|
|
|
public function testSet() {
|
|
|
$this->out($this->_header(__FUNCTION__), true);
|
|
|
$data = array($this->modelName => array('x' => 'hey'), 'OtherModel' => array('y' => ''));
|
|
|
- $this->App->data = array();
|
|
|
+ $this->User->data = array();
|
|
|
|
|
|
- $res = $this->App->set($data, null, array('x', 'z'));
|
|
|
+ $res = $this->User->set($data, null, array('x', 'z'));
|
|
|
$this->out($res);
|
|
|
$this->assertTrue(!empty($res));
|
|
|
$this->assertEquals($res, array($this->modelName => array('x' => 'hey', 'z' => ''), 'OtherModel' => array('y' => '')));
|
|
|
|
|
|
- $res = $this->App->data;
|
|
|
+ $res = $this->User->data;
|
|
|
$this->out($res);
|
|
|
$this->assertTrue(!empty($res));
|
|
|
$this->assertEquals($res, array($this->modelName => array('x' => 'hey', 'z' => ''), 'OtherModel' => array('y' => '')));
|
|
|
@@ -336,12 +336,12 @@ class MyModelTest extends MyCakeTestCase {
|
|
|
$this->out($this->_header(__FUNCTION__), true);
|
|
|
$data = array($this->modelName => array('x' => 'hey'), 'OtherModel' => array('y' => ''));
|
|
|
|
|
|
- $data = $this->App->guaranteeFields(array('x', 'z'), $data);
|
|
|
+ $data = $this->User->guaranteeFields(array('x', 'z'), $data);
|
|
|
$this->out($data);
|
|
|
$this->assertTrue(!empty($data));
|
|
|
$this->assertEquals(array($this->modelName => array('x' => 'hey', 'z' => ''), 'OtherModel' => array('y' => '')), $data);
|
|
|
|
|
|
- $res = $this->App->set($data);
|
|
|
+ $res = $this->User->set($data);
|
|
|
$this->out($res);
|
|
|
$this->assertTrue(!empty($res));
|
|
|
$this->assertEquals($res, array($this->modelName => array('x' => 'hey', 'z' => ''), 'OtherModel' => array('y' => '')));
|
|
|
@@ -353,9 +353,9 @@ class MyModelTest extends MyCakeTestCase {
|
|
|
$this->out($this->_header(__FUNCTION__), true);
|
|
|
$data = array($this->modelName => array('name' => 'e', 'x' => 'hey'), 'OtherModel' => array('y' => ''));
|
|
|
|
|
|
- $schema = $this->App->schema();
|
|
|
+ $schema = $this->User->schema();
|
|
|
|
|
|
- $data = $this->App->blacklist(array('x', 'z'));
|
|
|
+ $data = $this->User->blacklist(array('x', 'z'));
|
|
|
$this->out($data);
|
|
|
if (!empty($schema)) {
|
|
|
$this->assertTrue(!empty($data));
|
|
|
@@ -368,39 +368,39 @@ class MyModelTest extends MyCakeTestCase {
|
|
|
|
|
|
public function testInvalidate() {
|
|
|
$this->out($this->_header(__FUNCTION__), true);
|
|
|
- $this->App->create();
|
|
|
- $this->App->invalidate('fieldx', __('e %s f', 33));
|
|
|
- $res = $this->App->validationErrors;
|
|
|
+ $this->User->create();
|
|
|
+ $this->User->invalidate('fieldx', __('e %s f', 33));
|
|
|
+ $res = $this->User->validationErrors;
|
|
|
$this->out($res);
|
|
|
$this->assertTrue(!empty($res));
|
|
|
|
|
|
- $this->App->create();
|
|
|
- $this->App->invalidate('Model.fieldy', __('e %s f %s g', 33, 'xyz'));
|
|
|
- $res = $this->App->validationErrors;
|
|
|
+ $this->User->create();
|
|
|
+ $this->User->invalidate('Model.fieldy', __('e %s f %s g', 33, 'xyz'));
|
|
|
+ $res = $this->User->validationErrors;
|
|
|
$this->out($res);
|
|
|
$this->assertTrue(!empty($res) && $res['Model.fieldy'][0] === 'e 33 f xyz g');
|
|
|
|
|
|
- $this->App->create();
|
|
|
- $this->App->invalidate('fieldy', __('e %s f %s g %s', true, 'xyz', 55));
|
|
|
- $res = $this->App->validationErrors;
|
|
|
+ $this->User->create();
|
|
|
+ $this->User->invalidate('fieldy', __('e %s f %s g %s', true, 'xyz', 55));
|
|
|
+ $res = $this->User->validationErrors;
|
|
|
$this->out($res);
|
|
|
$this->assertTrue(!empty($res) && $res['fieldy'][0] === 'e 1 f xyz g 55');
|
|
|
|
|
|
- $this->App->create();
|
|
|
- $this->App->invalidate('fieldy', array('valErrMandatoryField'));
|
|
|
- $res = $this->App->validationErrors;
|
|
|
+ $this->User->create();
|
|
|
+ $this->User->invalidate('fieldy', array('valErrMandatoryField'));
|
|
|
+ $res = $this->User->validationErrors;
|
|
|
$this->out($res);
|
|
|
$this->assertTrue(!empty($res));
|
|
|
|
|
|
- $this->App->create();
|
|
|
- $this->App->invalidate('fieldy', 'valErrMandatoryField');
|
|
|
- $res = $this->App->validationErrors;
|
|
|
+ $this->User->create();
|
|
|
+ $this->User->invalidate('fieldy', 'valErrMandatoryField');
|
|
|
+ $res = $this->User->validationErrors;
|
|
|
$this->out($res);
|
|
|
$this->assertTrue(!empty($res));
|
|
|
|
|
|
- $this->App->create();
|
|
|
- $this->App->invalidate('fieldy', __('a %s b %s c %s %s %s %s %s h %s', 1, 2, 3, 4, 5, 6, 7, 8));
|
|
|
- $res = $this->App->validationErrors;
|
|
|
+ $this->User->create();
|
|
|
+ $this->User->invalidate('fieldy', __('a %s b %s c %s %s %s %s %s h %s', 1, 2, 3, 4, 5, 6, 7, 8));
|
|
|
+ $res = $this->User->validationErrors;
|
|
|
$this->out($res);
|
|
|
$this->assertTrue(!empty($res) && $res['fieldy'][0] === 'a 1 b 2 c 3 4 5 6 7 h 8');
|
|
|
}
|
|
|
@@ -408,78 +408,78 @@ class MyModelTest extends MyCakeTestCase {
|
|
|
public function testValidateDate() {
|
|
|
$this->out($this->_header(__FUNCTION__), true);
|
|
|
$data = array('field' => '2010-01-22');
|
|
|
- $res = $this->App->validateDate($data);
|
|
|
+ $res = $this->User->validateDate($data);
|
|
|
//debug($res);
|
|
|
$this->assertTrue($res);
|
|
|
|
|
|
$data = array('field' => '2010-02-29');
|
|
|
- $res = $this->App->validateDate($data);
|
|
|
+ $res = $this->User->validateDate($data);
|
|
|
//debug($res);
|
|
|
$this->assertFalse($res);
|
|
|
|
|
|
- $this->App->data = array($this->App->alias => array('after' => '2010-02-22'));
|
|
|
+ $this->User->data = array($this->User->alias => array('after' => '2010-02-22'));
|
|
|
$data = array('field' => '2010-02-23 11:11:11');
|
|
|
- $res = $this->App->validateDate($data, array('after' => 'after'));
|
|
|
+ $res = $this->User->validateDate($data, array('after' => 'after'));
|
|
|
//debug($res);
|
|
|
$this->assertTrue($res);
|
|
|
|
|
|
- $this->App->data = array($this->App->alias => array('after' => '2010-02-24 11:11:11'));
|
|
|
+ $this->User->data = array($this->User->alias => array('after' => '2010-02-24 11:11:11'));
|
|
|
$data = array('field' => '2010-02-23');
|
|
|
- $res = $this->App->validateDate($data, array('after' => 'after'));
|
|
|
+ $res = $this->User->validateDate($data, array('after' => 'after'));
|
|
|
//debug($res);
|
|
|
$this->assertFalse($res);
|
|
|
|
|
|
- $this->App->data = array($this->App->alias => array('after' => '2010-02-25'));
|
|
|
+ $this->User->data = array($this->User->alias => array('after' => '2010-02-25'));
|
|
|
$data = array('field' => '2010-02-25');
|
|
|
- $res = $this->App->validateDate($data, array('after' => 'after'));
|
|
|
+ $res = $this->User->validateDate($data, array('after' => 'after'));
|
|
|
//debug($res);
|
|
|
$this->assertTrue($res);
|
|
|
|
|
|
- $this->App->data = array($this->App->alias => array('after' => '2010-02-25'));
|
|
|
+ $this->User->data = array($this->User->alias => array('after' => '2010-02-25'));
|
|
|
$data = array('field' => '2010-02-25');
|
|
|
- $res = $this->App->validateDate($data, array('after' => 'after', 'min' => 1));
|
|
|
+ $res = $this->User->validateDate($data, array('after' => 'after', 'min' => 1));
|
|
|
//debug($res);
|
|
|
$this->assertFalse($res);
|
|
|
|
|
|
- $this->App->data = array($this->App->alias => array('after' => '2010-02-24'));
|
|
|
+ $this->User->data = array($this->User->alias => array('after' => '2010-02-24'));
|
|
|
$data = array('field' => '2010-02-25');
|
|
|
- $res = $this->App->validateDate($data, array('after' => 'after', 'min' => 2));
|
|
|
+ $res = $this->User->validateDate($data, array('after' => 'after', 'min' => 2));
|
|
|
//debug($res);
|
|
|
$this->assertFalse($res);
|
|
|
|
|
|
- $this->App->data = array($this->App->alias => array('after' => '2010-02-24'));
|
|
|
+ $this->User->data = array($this->User->alias => array('after' => '2010-02-24'));
|
|
|
$data = array('field' => '2010-02-25');
|
|
|
- $res = $this->App->validateDate($data, array('after' => 'after', 'min' => 1));
|
|
|
+ $res = $this->User->validateDate($data, array('after' => 'after', 'min' => 1));
|
|
|
//debug($res);
|
|
|
$this->assertTrue($res);
|
|
|
|
|
|
- $this->App->data = array($this->App->alias => array('after' => '2010-02-24'));
|
|
|
+ $this->User->data = array($this->User->alias => array('after' => '2010-02-24'));
|
|
|
$data = array('field' => '2010-02-25');
|
|
|
- $res = $this->App->validateDate($data, array('after' => 'after', 'min' => 2));
|
|
|
+ $res = $this->User->validateDate($data, array('after' => 'after', 'min' => 2));
|
|
|
//debug($res);
|
|
|
$this->assertFalse($res);
|
|
|
|
|
|
- $this->App->data = array($this->App->alias => array('before' => '2010-02-24'));
|
|
|
+ $this->User->data = array($this->User->alias => array('before' => '2010-02-24'));
|
|
|
$data = array('field' => '2010-02-24');
|
|
|
- $res = $this->App->validateDate($data, array('before' => 'before', 'min' => 1));
|
|
|
+ $res = $this->User->validateDate($data, array('before' => 'before', 'min' => 1));
|
|
|
//debug($res);
|
|
|
$this->assertFalse($res);
|
|
|
|
|
|
- $this->App->data = array($this->App->alias => array('before' => '2010-02-25'));
|
|
|
+ $this->User->data = array($this->User->alias => array('before' => '2010-02-25'));
|
|
|
$data = array('field' => '2010-02-24');
|
|
|
- $res = $this->App->validateDate($data, array('before' => 'before', 'min' => 1));
|
|
|
+ $res = $this->User->validateDate($data, array('before' => 'before', 'min' => 1));
|
|
|
//debug($res);
|
|
|
$this->assertTrue($res);
|
|
|
|
|
|
- $this->App->data = array($this->App->alias => array('before' => '2010-02-25'));
|
|
|
+ $this->User->data = array($this->User->alias => array('before' => '2010-02-25'));
|
|
|
$data = array('field' => '2010-02-24');
|
|
|
- $res = $this->App->validateDate($data, array('before' => 'before', 'min' => 2));
|
|
|
+ $res = $this->User->validateDate($data, array('before' => 'before', 'min' => 2));
|
|
|
//debug($res);
|
|
|
$this->assertFalse($res);
|
|
|
|
|
|
- $this->App->data = array($this->App->alias => array('before' => '2010-02-26'));
|
|
|
+ $this->User->data = array($this->User->alias => array('before' => '2010-02-26'));
|
|
|
$data = array('field' => '2010-02-24');
|
|
|
- $res = $this->App->validateDate($data, array('before' => 'before', 'min' => 2));
|
|
|
+ $res = $this->User->validateDate($data, array('before' => 'before', 'min' => 2));
|
|
|
//debug($res);
|
|
|
$this->assertTrue($res);
|
|
|
}
|
|
|
@@ -487,69 +487,69 @@ class MyModelTest extends MyCakeTestCase {
|
|
|
public function testValidateDatetime() {
|
|
|
$this->out($this->_header(__FUNCTION__), true);
|
|
|
$data = array('field' => '2010-01-22 11:11:11');
|
|
|
- $res = $this->App->validateDatetime($data);
|
|
|
+ $res = $this->User->validateDatetime($data);
|
|
|
//debug($res);
|
|
|
$this->assertTrue($res);
|
|
|
|
|
|
$data = array('field' => '2010-01-22 11:61:11');
|
|
|
- $res = $this->App->validateDatetime($data);
|
|
|
+ $res = $this->User->validateDatetime($data);
|
|
|
//debug($res);
|
|
|
$this->assertFalse($res);
|
|
|
|
|
|
$data = array('field' => '2010-02-29 11:11:11');
|
|
|
- $res = $this->App->validateDatetime($data);
|
|
|
+ $res = $this->User->validateDatetime($data);
|
|
|
//debug($res);
|
|
|
$this->assertFalse($res);
|
|
|
|
|
|
$data = array('field' => '');
|
|
|
- $res = $this->App->validateDatetime($data, array('allowEmpty' => true));
|
|
|
+ $res = $this->User->validateDatetime($data, array('allowEmpty' => true));
|
|
|
//debug($res);
|
|
|
$this->assertTrue($res);
|
|
|
|
|
|
$data = array('field' => '0000-00-00 00:00:00');
|
|
|
- $res = $this->App->validateDatetime($data, array('allowEmpty' => true));
|
|
|
+ $res = $this->User->validateDatetime($data, array('allowEmpty' => true));
|
|
|
//debug($res);
|
|
|
$this->assertTrue($res);
|
|
|
|
|
|
- $this->App->data = array($this->App->alias => array('after' => '2010-02-22 11:11:11'));
|
|
|
+ $this->User->data = array($this->User->alias => array('after' => '2010-02-22 11:11:11'));
|
|
|
$data = array('field' => '2010-02-23 11:11:11');
|
|
|
- $res = $this->App->validateDatetime($data, array('after' => 'after'));
|
|
|
+ $res = $this->User->validateDatetime($data, array('after' => 'after'));
|
|
|
//debug($res);
|
|
|
$this->assertTrue($res);
|
|
|
|
|
|
- $this->App->data = array($this->App->alias => array('after' => '2010-02-24 11:11:11'));
|
|
|
+ $this->User->data = array($this->User->alias => array('after' => '2010-02-24 11:11:11'));
|
|
|
$data = array('field' => '2010-02-23 11:11:11');
|
|
|
- $res = $this->App->validateDatetime($data, array('after' => 'after'));
|
|
|
+ $res = $this->User->validateDatetime($data, array('after' => 'after'));
|
|
|
//debug($res);
|
|
|
$this->assertFalse($res);
|
|
|
|
|
|
- $this->App->data = array($this->App->alias => array('after' => '2010-02-23 11:11:11'));
|
|
|
+ $this->User->data = array($this->User->alias => array('after' => '2010-02-23 11:11:11'));
|
|
|
$data = array('field' => '2010-02-23 11:11:11');
|
|
|
- $res = $this->App->validateDatetime($data, array('after' => 'after'));
|
|
|
+ $res = $this->User->validateDatetime($data, array('after' => 'after'));
|
|
|
//debug($res);
|
|
|
$this->assertFalse($res);
|
|
|
|
|
|
- $this->App->data = array($this->App->alias => array('after' => '2010-02-23 11:11:11'));
|
|
|
+ $this->User->data = array($this->User->alias => array('after' => '2010-02-23 11:11:11'));
|
|
|
$data = array('field' => '2010-02-23 11:11:11');
|
|
|
- $res = $this->App->validateDatetime($data, array('after' => 'after', 'min' => 1));
|
|
|
+ $res = $this->User->validateDatetime($data, array('after' => 'after', 'min' => 1));
|
|
|
//debug($res);
|
|
|
$this->assertFalse($res);
|
|
|
|
|
|
- $this->App->data = array($this->App->alias => array('after' => '2010-02-23 11:11:11'));
|
|
|
+ $this->User->data = array($this->User->alias => array('after' => '2010-02-23 11:11:11'));
|
|
|
$data = array('field' => '2010-02-23 11:11:11');
|
|
|
- $res = $this->App->validateDatetime($data, array('after' => 'after', 'min' => 0));
|
|
|
+ $res = $this->User->validateDatetime($data, array('after' => 'after', 'min' => 0));
|
|
|
//debug($res);
|
|
|
$this->assertTrue($res);
|
|
|
|
|
|
- $this->App->data = array($this->App->alias => array('after' => '2010-02-23 11:11:10'));
|
|
|
+ $this->User->data = array($this->User->alias => array('after' => '2010-02-23 11:11:10'));
|
|
|
$data = array('field' => '2010-02-23 11:11:11');
|
|
|
- $res = $this->App->validateDatetime($data, array('after' => 'after'));
|
|
|
+ $res = $this->User->validateDatetime($data, array('after' => 'after'));
|
|
|
//debug($res);
|
|
|
$this->assertTrue($res);
|
|
|
|
|
|
- $this->App->data = array($this->App->alias => array('after' => '2010-02-23 11:11:12'));
|
|
|
+ $this->User->data = array($this->User->alias => array('after' => '2010-02-23 11:11:12'));
|
|
|
$data = array('field' => '2010-02-23 11:11:11');
|
|
|
- $res = $this->App->validateDatetime($data, array('after' => 'after'));
|
|
|
+ $res = $this->User->validateDatetime($data, array('after' => 'after'));
|
|
|
//debug($res);
|
|
|
$this->assertFalse($res);
|
|
|
}
|
|
|
@@ -557,24 +557,24 @@ class MyModelTest extends MyCakeTestCase {
|
|
|
public function testValidateTime() {
|
|
|
$this->out($this->_header(__FUNCTION__), true);
|
|
|
$data = array('field' => '11:21:11');
|
|
|
- $res = $this->App->validateTime($data);
|
|
|
+ $res = $this->User->validateTime($data);
|
|
|
//debug($res);
|
|
|
$this->assertTrue($res);
|
|
|
|
|
|
$data = array('field' => '11:71:11');
|
|
|
- $res = $this->App->validateTime($data);
|
|
|
+ $res = $this->User->validateTime($data);
|
|
|
//debug($res);
|
|
|
$this->assertFalse($res);
|
|
|
|
|
|
- $this->App->data = array($this->App->alias => array('before' => '2010-02-23 11:11:12'));
|
|
|
+ $this->User->data = array($this->User->alias => array('before' => '2010-02-23 11:11:12'));
|
|
|
$data = array('field' => '2010-02-23 11:11:11');
|
|
|
- $res = $this->App->validateTime($data, array('before' => 'before'));
|
|
|
+ $res = $this->User->validateTime($data, array('before' => 'before'));
|
|
|
//debug($res);
|
|
|
$this->assertTrue($res);
|
|
|
|
|
|
- $this->App->data = array($this->App->alias => array('after' => '2010-02-23 11:11:12'));
|
|
|
+ $this->User->data = array($this->User->alias => array('after' => '2010-02-23 11:11:12'));
|
|
|
$data = array('field' => '2010-02-23 11:11:11');
|
|
|
- $res = $this->App->validateTime($data, array('after' => 'after'));
|
|
|
+ $res = $this->User->validateTime($data, array('after' => 'after'));
|
|
|
//debug($res);
|
|
|
$this->assertFalse($res);
|
|
|
}
|
|
|
@@ -582,66 +582,66 @@ class MyModelTest extends MyCakeTestCase {
|
|
|
public function testValidateUrl() {
|
|
|
$this->out($this->_header(__FUNCTION__), true);
|
|
|
$data = array('field' => 'www.dereuromark.de');
|
|
|
- $res = $this->App->validateUrl($data, array('allowEmpty' => true));
|
|
|
+ $res = $this->User->validateUrl($data, array('allowEmpty' => true));
|
|
|
$this->assertTrue($res);
|
|
|
|
|
|
$data = array('field' => 'www.xxxde');
|
|
|
- $res = $this->App->validateUrl($data, array('allowEmpty' => true));
|
|
|
+ $res = $this->User->validateUrl($data, array('allowEmpty' => true));
|
|
|
$this->assertFalse($res);
|
|
|
|
|
|
$data = array('field' => 'www.dereuromark.de');
|
|
|
- $res = $this->App->validateUrl($data, array('allowEmpty' => true, 'autoComplete' => false));
|
|
|
+ $res = $this->User->validateUrl($data, array('allowEmpty' => true, 'autoComplete' => false));
|
|
|
$this->assertFalse($res);
|
|
|
|
|
|
$data = array('field' => 'http://www.dereuromark.de');
|
|
|
- $res = $this->App->validateUrl($data, array('allowEmpty' => true, 'autoComplete' => false));
|
|
|
+ $res = $this->User->validateUrl($data, array('allowEmpty' => true, 'autoComplete' => false));
|
|
|
$this->assertTrue($res);
|
|
|
|
|
|
$data = array('field' => 'www.dereuromark.de');
|
|
|
- $res = $this->App->validateUrl($data, array('strict' => true));
|
|
|
+ $res = $this->User->validateUrl($data, array('strict' => true));
|
|
|
$this->assertTrue($res); # aha
|
|
|
|
|
|
$data = array('field' => 'http://www.dereuromark.de');
|
|
|
- $res = $this->App->validateUrl($data, array('strict' => false));
|
|
|
+ $res = $this->User->validateUrl($data, array('strict' => false));
|
|
|
$this->assertTrue($res);
|
|
|
|
|
|
$this->skipIf(empty($_SERVER['HTTP_HOST']), 'No HTTP_HOST');
|
|
|
|
|
|
$data = array('field' => 'http://xyz.de/some/link');
|
|
|
- $res = $this->App->validateUrl($data, array('deep' => false, 'sameDomain' => true));
|
|
|
+ $res = $this->User->validateUrl($data, array('deep' => false, 'sameDomain' => true));
|
|
|
$this->assertFalse($res);
|
|
|
|
|
|
$data = array('field' => '/some/link');
|
|
|
- $res = $this->App->validateUrl($data, array('deep' => false, 'autoComplete' => true));
|
|
|
+ $res = $this->User->validateUrl($data, array('deep' => false, 'autoComplete' => true));
|
|
|
$this->assertTrue($_SERVER['HTTP_HOST'] === 'localhost' ? !$res : $res);
|
|
|
|
|
|
$data = array('field' => 'http://' . $_SERVER['HTTP_HOST'] . '/some/link');
|
|
|
- $res = $this->App->validateUrl($data, array('deep' => false));
|
|
|
+ $res = $this->User->validateUrl($data, array('deep' => false));
|
|
|
$this->assertTrue($_SERVER['HTTP_HOST'] === 'localhost' ? !$res : $res);
|
|
|
|
|
|
$data = array('field' => '/some/link');
|
|
|
- $res = $this->App->validateUrl($data, array('deep' => false, 'autoComplete' => false));
|
|
|
+ $res = $this->User->validateUrl($data, array('deep' => false, 'autoComplete' => false));
|
|
|
$this->assertTrue((env('REMOTE_ADDR') !== '127.0.0.1') ? !$res : $res);
|
|
|
|
|
|
//$this->skipIf(strpos($_SERVER['HTTP_HOST'], '.') === false, 'No online HTTP_HOST');
|
|
|
|
|
|
$data = array('field' => '/some/link');
|
|
|
- $res = $this->App->validateUrl($data, array('deep' => false, 'sameDomain' => true));
|
|
|
+ $res = $this->User->validateUrl($data, array('deep' => false, 'sameDomain' => true));
|
|
|
$this->assertTrue($_SERVER['HTTP_HOST'] === 'localhost' ? !$res : $res);
|
|
|
|
|
|
$data = array('field' => 'https://github.com/');
|
|
|
- $res = $this->App->validateUrl($data, array('deep' => false));
|
|
|
+ $res = $this->User->validateUrl($data, array('deep' => false));
|
|
|
$this->assertTrue($res);
|
|
|
|
|
|
$data = array('field' => 'https://github.com/');
|
|
|
- $res = $this->App->validateUrl($data, array('deep' => true));
|
|
|
+ $res = $this->User->validateUrl($data, array('deep' => true));
|
|
|
$this->assertTrue($res);
|
|
|
}
|
|
|
|
|
|
public function testValidateUnique() {
|
|
|
$this->out($this->_header(__FUNCTION__), true);
|
|
|
|
|
|
- $this->Model->validate['title'] = array(
|
|
|
+ $this->Post->validate['title'] = array(
|
|
|
'validateUnique' => array(
|
|
|
'rule' => 'validateUnique',
|
|
|
'message' => 'valErrRecordTitleExists'
|
|
|
@@ -651,17 +651,17 @@ class MyModelTest extends MyCakeTestCase {
|
|
|
'title' => 'abc',
|
|
|
'published' => 'N'
|
|
|
);
|
|
|
- $this->Model->create($data);
|
|
|
- $res = $this->Model->validates();
|
|
|
+ $this->Post->create($data);
|
|
|
+ $res = $this->Post->validates();
|
|
|
$this->assertTrue($res);
|
|
|
- $res = $this->Model->save($res, false);
|
|
|
+ $res = $this->Post->save($res, false);
|
|
|
$this->assertTrue((bool)$res);
|
|
|
|
|
|
- $this->Model->create();
|
|
|
- $res = $this->Model->save($data);
|
|
|
+ $this->Post->create();
|
|
|
+ $res = $this->Post->save($data);
|
|
|
$this->assertFalse($res);
|
|
|
|
|
|
- $this->Model->validate['title'] = array(
|
|
|
+ $this->Post->validate['title'] = array(
|
|
|
'validateUnique' => array(
|
|
|
'rule' => array('validateUnique', array('published')),
|
|
|
'message' => 'valErrRecordTitleExists'
|
|
|
@@ -671,14 +671,14 @@ class MyModelTest extends MyCakeTestCase {
|
|
|
'title' => 'abc',
|
|
|
'published' => 'Y'
|
|
|
);
|
|
|
- $this->Model->create($data);
|
|
|
- $res = $this->Model->validates();
|
|
|
+ $this->Post->create($data);
|
|
|
+ $res = $this->Post->validates();
|
|
|
$this->assertTrue($res);
|
|
|
- $res = $this->Model->save($res, false);
|
|
|
+ $res = $this->Post->save($res, false);
|
|
|
$this->assertTrue((bool)$res);
|
|
|
|
|
|
- $this->Model->create();
|
|
|
- $res = $this->Model->save($data);
|
|
|
+ $this->Post->create();
|
|
|
+ $res = $this->Post->save($data);
|
|
|
$this->assertFalse($res);
|
|
|
}
|
|
|
|