mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +00:00
Edits to tests to cover the changes to Model::exists
This commit is contained in:
parent
90a77f6ce5
commit
fd198ce0fa
2 changed files with 39 additions and 10 deletions
|
@ -554,6 +554,44 @@ class ModelValidationTest extends BaseModelTest {
|
|||
$this->assertEquals($expected, $result);
|
||||
}
|
||||
|
||||
/**
|
||||
* test that validates() still performs correctly when useTable = false on the mode.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testValidatesWithNoTable() {
|
||||
$TestModel = new TheVoid();
|
||||
$TestModel->validate = array(
|
||||
'title' => array(
|
||||
'notEmpty' => array(
|
||||
'rule' => array('notBlank'),
|
||||
'required' => true,
|
||||
),
|
||||
'tooShort' => array(
|
||||
'rule' => array('minLength', 10),
|
||||
),
|
||||
),
|
||||
);
|
||||
$data = array(
|
||||
'TheVoid' => array(
|
||||
'title' => 'too short',
|
||||
),
|
||||
);
|
||||
$TestModel->create($data);
|
||||
$result = $TestModel->validates();
|
||||
$this->assertFalse($result);
|
||||
|
||||
$data = array(
|
||||
'TheVoid' => array(
|
||||
'id' => '1',
|
||||
'title' => 'A good title',
|
||||
),
|
||||
);
|
||||
$TestModel->create($data);
|
||||
$result = $TestModel->validates();
|
||||
$this->assertTrue($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* test that validates() checks all the 'with' associations as well for validation
|
||||
* as this can cause partial/wrong data insertion.
|
||||
|
|
|
@ -2785,18 +2785,9 @@ class ModelWriteTest extends BaseModelTest {
|
|||
|
||||
$TestModel = new TheVoid();
|
||||
$this->assertFalse($TestModel->exists());
|
||||
}
|
||||
|
||||
/**
|
||||
* testRecordExistsMissingTable method
|
||||
*
|
||||
* @expectedException PDOException
|
||||
* @return void
|
||||
*/
|
||||
public function testRecordExistsMissingTable() {
|
||||
$TestModel = new TheVoid();
|
||||
$TestModel->id = 5;
|
||||
$TestModel->exists();
|
||||
$this->assertTrue($TestModel->exists());
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in a new issue