mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-18 02:26:17 +00:00
Fixing docbloc in Containable, fixing issue where no notices and invalid bindings were throwing PHP warnings, added tests, fixes #4683
git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@6938 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
parent
71790792d0
commit
775707838e
2 changed files with 13 additions and 3 deletions
|
@ -57,7 +57,7 @@ class ContainableBehavior extends ModelBehavior {
|
||||||
* disables this feature. DEFAULTS TO: true
|
* disables this feature. DEFAULTS TO: true
|
||||||
*
|
*
|
||||||
* - notices: (boolean, optional) issues E_NOTICES for bindings referenced in a
|
* - notices: (boolean, optional) issues E_NOTICES for bindings referenced in a
|
||||||
* containable call that are not valid. DEFAULTS TO: false
|
* containable call that are not valid. DEFAULTS TO: true
|
||||||
*
|
*
|
||||||
* - autoFields: (boolean, optional) auto-add needed fields to fetch requested
|
* - autoFields: (boolean, optional) auto-add needed fields to fetch requested
|
||||||
* bindings. DEFAULTS TO: true
|
* bindings. DEFAULTS TO: true
|
||||||
|
@ -297,8 +297,10 @@ class ContainableBehavior extends ModelBehavior {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($throwErrors && (!isset($Model->{$name}) || !is_object($Model->{$name}))) {
|
if (!isset($Model->{$name}) || !is_object($Model->{$name})) {
|
||||||
trigger_error(__(sprintf('Model "%s" is not associated with model "%s"', $Model->alias, $name), true), E_USER_WARNING);
|
if ($throwErrors) {
|
||||||
|
trigger_error(__(sprintf('Model "%s" is not associated with model "%s"', $Model->alias, $name), true), E_USER_WARNING);
|
||||||
|
}
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -87,6 +87,14 @@ class ContainableTest extends CakeTestCase {
|
||||||
$this->assertEqual(Set::extract('/ArticleFeatured/keep/Featured/fields', $r), array('id'));
|
$this->assertEqual(Set::extract('/ArticleFeatured/keep/Featured/fields', $r), array('id'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function testInvalidContainments() {
|
||||||
|
$this->expectError();
|
||||||
|
$r = $this->__containments($this->Article, array('Comment', 'InvalidBinding'));
|
||||||
|
|
||||||
|
$this->Article->Behaviors->attach('Containable', array('notices' => false));
|
||||||
|
$r = $this->__containments($this->Article, array('Comment', 'InvalidBinding'));
|
||||||
|
}
|
||||||
|
|
||||||
function testBeforeFind() {
|
function testBeforeFind() {
|
||||||
$r = $this->Article->find('all', array('contain' => array('Comment')));
|
$r = $this->Article->find('all', array('contain' => array('Comment')));
|
||||||
$this->assertFalse(Set::matches('/User', $r));
|
$this->assertFalse(Set::matches('/User', $r));
|
||||||
|
|
Loading…
Add table
Reference in a new issue