mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-19 11:06:15 +00:00
Fix issue with 0.Model.field inputs.
These inputs would be incorrectly prefixed with another Model name.
This commit is contained in:
parent
43df8d34e7
commit
24fd87398d
2 changed files with 16 additions and 3 deletions
|
@ -310,6 +310,19 @@ class HelperTest extends CakeTestCase {
|
||||||
$this->assertEquals('HelperTestComment', $this->Helper->model());
|
$this->assertEquals('HelperTestComment', $this->Helper->model());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test creating saveMany() compatible entities
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function testSetEntitySaveMany() {
|
||||||
|
$this->Helper->setEntity('HelperTestPost', true);
|
||||||
|
|
||||||
|
$this->Helper->setEntity('0.HelperTestPost.id');
|
||||||
|
$expected = array('0', 'HelperTestPost', 'id');
|
||||||
|
$this->assertEquals($expected, $this->Helper->entity());
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test that setEntity doesn't make CamelCase fields that are not associations an
|
* Test that setEntity doesn't make CamelCase fields that are not associations an
|
||||||
* associated model.
|
* associated model.
|
||||||
|
|
|
@ -444,9 +444,9 @@ class Helper extends Object {
|
||||||
$entity = $this->_modelScope . '.' . $entity;
|
$entity = $this->_modelScope . '.' . $entity;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 0.name, 0.created.month style inputs.
|
// 0.name, 0.created.month style inputs. Excludes inputs with the modelScope in them.
|
||||||
if (
|
if (
|
||||||
$count >= 2 && is_numeric($parts[0]) && !is_numeric($parts[1]) && $this->_modelScope
|
$count >= 2 && is_numeric($parts[0]) && !is_numeric($parts[1]) && $this->_modelScope && strpos($entity, $this->_modelScope) === false
|
||||||
) {
|
) {
|
||||||
$entity = $this->_modelScope . '.' . $entity;
|
$entity = $this->_modelScope . '.' . $entity;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue