1
ファンクションがジャスミンでどのように動作するかのようなパラメータのセットでコールされたかどうかをテストします。ジャスミンのようなPHPユニットテストでtoHaveBeenCalledWithはありますか?
PHPユニットテストでこれを行う方法はありますか?
ファンクションがジャスミンでどのように動作するかのようなパラメータのセットでコールされたかどうかをテストします。ジャスミンのようなPHPユニットテストでtoHaveBeenCalledWithはありますか?
PHPユニットテストでこれを行う方法はありますか?
phpunitには、ジャスミンの呼び出しがスパイするものはありません。しかし、あなたは
チェックアウト(などとどのような彼らは返す必要があります)クラスをモックと呼ばれるように、あなたがそのクラスのメソッドを期待してどのように期待を設定することができますphpunit manual example 9.11.
public function testObserversAreUpdated()
{
// Create a mock for the Observer class,
// only mock the update() method.
$observer = $this->getMockBuilder(Observer::class)
->setMethods(['update'])
->getMock();
// Set up the expectation for the update() method
// to be called only once and with the string 'something'
// as its parameter.
$observer->expects($this->once())
->method('update')
->with($this->equalTo('something'));
// Create a Subject object and attach the mocked
// Observer object to it.
$subject = new Subject('My subject');
$subject->attach($observer);
// Call the doSomething() method on the $subject object
// which we expect to call the mocked Observer object's
// update() method with the string 'something'.
$subject->doSomething();
}
あなたが行うことができますモックとします。https: //phpunit.de/manual/current/en/test-doubles.html – colburton