Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/Model/Behavior/UploadBehavior.php
Original file line number Diff line number Diff line change
Expand Up @@ -156,9 +156,9 @@ public function beforeSave(EventInterface $event, EntityInterface $entity, Array
* @param \Cake\Event\EventInterface $event The afterDelete event that was fired
* @param \Cake\Datasource\EntityInterface $entity The entity that was deleted
* @param \ArrayObject $options the options passed to the delete method
* @return bool
* @return void
*/
public function afterDelete(EventInterface $event, EntityInterface $entity, ArrayObject $options): bool
public function afterDelete(EventInterface $event, EntityInterface $entity, ArrayObject $options): void
{
$result = true;

Expand Down Expand Up @@ -193,7 +193,7 @@ public function afterDelete(EventInterface $event, EntityInterface $entity, Arra
}
}

return $result;
$event->setResult($result);
}

/**
Expand Down
21 changes: 15 additions & 6 deletions tests/TestCase/Model/Behavior/UploadBehaviorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -460,8 +460,9 @@ public function testAfterDeleteOk()
$this->writer->expects($this->any())
->method('delete')
->will($this->returnValue([true]));

$this->assertTrue($behavior->afterDelete(new Event('fake.event'), $this->entity, new ArrayObject()));
$event = new Event('fake.event');
$behavior->afterDelete($event, $this->entity, new ArrayObject());
$this->assertTrue($event->getResult());
}

public function testAfterDeleteFail()
Expand All @@ -485,7 +486,9 @@ public function testAfterDeleteFail()
$this->writer->expects($this->any())
->method('delete')
->will($this->returnValue([false]));
$this->assertFalse($behavior->afterDelete(new Event('fake.event'), $this->entity, new ArrayObject()));
$event = new Event('fake.event');
$behavior->afterDelete($event, $this->entity, new ArrayObject());
$this->assertFalse($event->getResult());
}

public function testAfterDeleteSkip()
Expand All @@ -504,7 +507,9 @@ public function testAfterDeleteSkip()
->method('delete')
->will($this->returnValue([true]));

$this->assertTrue($behavior->afterDelete(new Event('fake.event'), $this->entity, new ArrayObject()));
$event = new Event('fake.event');
$behavior->afterDelete($event, $this->entity, new ArrayObject());
$this->assertTrue($event->getResult());
}

public function testAfterDeleteUsesPathProcessorToDetectPathToTheFile()
Expand Down Expand Up @@ -585,7 +590,9 @@ public function testAfterDeletePrefersStoredPathOverPathProcessor()
->with([$dir . $field])
->will($this->returnValue([true]));

$this->assertTrue($behavior->afterDelete(new Event('fake.event'), $this->entity, new ArrayObject()));
$event = new Event('fake.event');
$behavior->afterDelete($event, $this->entity, new ArrayObject());
$this->assertTrue($event->getResult());
}

public function testAfterDeleteNoDeleteCallback()
Expand Down Expand Up @@ -684,7 +691,9 @@ public function testAfterDeleteWithProtectedFieldName()
->method('delete')
->will($this->returnValue([true]));

$this->assertTrue($behavior->afterDelete(new Event('fake.event'), $this->entity, new ArrayObject()));
$event = new Event('fake.event');
$behavior->afterDelete($event, $this->entity, new ArrayObject());
$this->assertTrue($event->getResult());
}

public function testAfterDeleteWithNullableFileField()
Expand Down