0
我在问自己为什么不存在一个名为sameThat
的方法在phpunit常量里面,我想测试下一段代码。哪里是相同的或相同的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);
上面的例子中,你可以看到,在两个PHPUnit的常数equalTo
和isType
,无论我用它,因为equalTo
compairs与==
,无===
,所以,我改变了findBy("1",1)
,测试没有失败,所以,我加了isType
不变,所以现在测试失败了。
有一个称为assertSame()
的断言,为什么没有一个等于PHPUNIT的常量?例如sameThat
或sameTo
。
'$ test-> assertSame(1,$ arg);'? – xmike
'equalTo()'和'isType()'是[实例方法](http://php.net/manual/en/language.oop5.basic.php)(即函数)而不是[常量](http:///php.net/manual/en/language.oop5.constants.php) – axiac