Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Entity's fill method is not supporting key mapping #1567

Closed
hwiesmann opened this issue Dec 1, 2018 · 1 comment
Closed

Entity's fill method is not supporting key mapping #1567

hwiesmann opened this issue Dec 1, 2018 · 1 comment

Comments

@hwiesmann
Copy link

hwiesmann commented Dec 1, 2018


name: Bug report
about: Entity's fill method is not supporting key mapping


Describe the bug
The header already says it. While the magic method __set maps the key by $key = $this->mapProperty($key); this is not the case in the fill method.

PS: See also next bug report concerning magic methods __get and __set.

** TEST **
public function testFillWithMappedEntity()
{
$data = ['bar' => 'foo', 'orig' => 'simple'];

	$mappedEntity = $this->getMappedEntity();
	$mappedEntity->fill($data);
	$whatsnew = $mappedEntity->toArray(true);
	$expected = $data;
	$this->assertEquals($expected,$whatsnew);
}

CodeIgniter 4 version
CodeIgniter 4.0.0 Alpha 2 release

Affected module(s)
Entity

@lonnieezell
Copy link
Member

Good catch! I've fixed that up, though I couldn't use your test as is. The toArray doesn't bring back exactly what you're expecting. it's intended for use by the model, so does some weird things with the mapped properties to ensure that it gets the original field names. Plus the setter and getter for 'orig' add strings around it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants