我不知道这种方法是如何工作的。这是我尝试使用它的示例:
namespace spec;
use PhpSpec\ObjectBehavior;
class MyObjectSpec extends ObjectBehavior
{
/**
* @param SomeEvent $event
* @param SomeSubscriber $subscriber
*/
function it_formats_the_string_as_a_header_if_underline_with_single_dashes(
$event,
$subscriber
)
{
$subscriber->onChange($event)->shouldBeCalled(); //RIGHT HERE
// when
$this->addSubscriber($subscriber);
$this->doWhatever($event);
}
}
class SomeEvent {}
class SomeSubscriber
{
function onChange($event){}
function usesOnChange(){
$someEvent = new SomeEvent();
$this->onChange($someEvent);
}
}
命名空间是正确的,文件分别在 ObjectSpec.php 、 SomeEvent.php(in src folder) 和 SomeSubscriber.php(in src folder) 中。这给了我一个错误No Call has been match but at least one is expected为什么这不起作用?谢谢你。