0
私は自分自身に尋ねたなぜ存在しないsameThat
というPHPUNIT定数内のメソッド、次のピースコードはテストしたいのですか?定数は同じですか、同じですか?
$user = $this->em->getRepository('AppBundle:User')->findBy(1,1);
最後に、これは私のテストで:
$this->userRepository->expects($this->at(0))
->method('findBy')
->with(
$this->callback(function($arg) use ($test) {
$part = 'In the first call to findBy method, the first parameter: ';
$test->assertThat($arg, $this->logicalAnd(
$this->equalTo(1),
$this->isType('integer')
), $part .'it was found issues'
);//assertThat
return true;
}),
)
->willReturn($this->user);
上記の例では、あなたが見ることができるように、2 PHPUnitのがある==
とequalTo
compairsのでノー、equalTo
とisType
、私はそれを使用し、両方の定数===
だから、私はfindBy("1",1)
を代わりに変更します。テストに失敗しないので、確かにisType
定数を追加しました。テストが失敗しました。
assertSame()
と呼ばれるアサートがありますが、なぜPHPUNITの定数に等しくないのですか?たとえばsameThat
またはsameTo
です。
'$ test-> assertSame(1、$ arg);'? – xmike
'' equalTo() ''と '' isType() 'は[定数]ではない[インスタンスメソッド](http://php.net/manual/en/language.oop5.basic.php) /php.net/manual/en/language.oop5.constants.php) – axiac