Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Making all HasMany tests pass

  • Loading branch information...
commit 386394c2051bb27bdc38e731094ccc35c265db3d 1 parent 175fb3c
José Lorenzo Rodríguez lorenzo authored
10 Cake/ORM/Association/DependentDeleteTrait.php
View
@@ -39,15 +39,13 @@ public function cascadeDelete(Entity $entity, $options = []) {
return true;
}
$table = $this->target();
- $foreignKey = $this->foreignKey();
+ $foreignKey = (array)$this->foreignKey();
$primaryKey = $this->source()->primaryKey();
-
- $conditions = [
- $foreignKey => $entity->get($primaryKey)
- ];
+ $conditions = array_combine($foreignKey, $entity->extract($primaryKey));
if ($this->_cascadeCallbacks) {
- foreach ($this->find('all')->where($conditions) as $related) {
+ $query = $this->find('all')->where($conditions)->bufferResults(false);
+ foreach ($query as $related) {
$table->delete($related, $options);
}
return true;
4 Test/TestCase/ORM/Association/HasManyTest.php
View
@@ -661,6 +661,10 @@ public function testCascadeDeleteCallbacks() {
$query->expects($this->any())
->method('getIterator')
->will($this->returnValue($iterator));
+ $query->expects($this->once())
+ ->method('bufferResults')
+ ->with(false)
+ ->will($this->returnSelf());
$this->article->expects($this->once())
->method('find')
Please sign in to comment.
Something went wrong with that request. Please try again.