Skip to content
Permalink
Browse files

Fix unsetProperty() not clearing property cache.

  • Loading branch information...
markstory committed May 8, 2015
1 parent b896127 commit 84eba53f35d22d2ac6678edbd2a2161a0a349a9b
Showing with 21 additions and 0 deletions.
  1. +1 −0 src/Datasource/EntityTrait.php
  2. +20 −0 tests/TestCase/ORM/EntityTest.php
@@ -364,6 +364,7 @@ public function unsetProperty($property)
foreach ($property as $p) {
unset($this->_properties[$p]);
unset($this->_dirty[$p]);
unset($this->_mutated[$p]);
}
return $this;
@@ -258,6 +258,26 @@ public function testGetCustomGettersAfterSet()
$this->assertEquals('Dr. Mark', $entity->get('name'));
}
/**
* Tests that the get cache is cleared by unsetProperty.
*
* @return void
*/
public function testGetCacheClearedByUnset()
{
$entity = $this->getMock('\Cake\ORM\Entity', ['_getName']);
$entity->expects($this->any())->method('_getName')
->will($this->returnCallback(function ($name) {
return 'Dr. ' . $name;
}));
$entity->set('name', 'Jones');
$this->assertEquals('Dr. Jones', $entity->get('name'));
$entity->unsetProperty('name');
$this->assertEquals('Dr. ', $entity->get('name'));
}
/**
* Test magic property setting with no custom setter
*

2 comments on commit 84eba53

@lorenzo

This comment has been minimized.

Copy link
Member

lorenzo replied May 8, 2015

The fun thing is that I wake up this morning and realize that my last commit was not pushed. It is exactly this :D

Thanks for fixing my derp

@markstory

This comment has been minimized.

Copy link
Member Author

markstory replied May 8, 2015

I only saw it after merging and then thinking more about how to write the changelog comment related to this. 😄

Please sign in to comment.
You can’t perform that action at this time.