Could you provide your implementation of MyObject
? It will be helpful if you want to get a proper answer.
When you're trying to create mock of object method ->shouldBeCalled()
basically means that method onChange()
with parameter $event
should be called on object $subscriber
.
The message that you are getting means basically that method was not called and now is the step that you should implement it.
I've provided basic implementation of your class that gives successful result in PHPSpec run.
<?php
class MyObject
{
private $subscribers = array();
public function addSubscriber($subscriber)
{
$this->subscribers[] = $subscriber;
}
public function doWhatever($event)
{
foreach($this->subscribers as $subscriber) {
$subscriber->onChange($event);
}
}
}