Reputation: 2811
I was ask myself Why doesn't exist a method called sameThat
inside PHPUNIT constants, the next piece code i want test.
$user = $this->em->getRepository('AppBundle:User')->findBy(1,1);
Finally this is my test:
$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);
the above example, As you can see, there is two PHPUNIT constants equalTo
and isType
, both I used it, because equalTo
compairs with ==
, no ===
, so, I change findBy("1",1)
instead, the test doesn't fail, so, I added isType
constant to be sure, so, the test fail now.
There is an assert called assertSame()
, why is there not one equal for PHPUNIT's constants ? for example sameThat
or sameTo
.
Upvotes: 0
Views: 75
Reputation: 8326
Assuming that you mean "constraint" when you write "constant" then you are looking for identicalTo()
. That is the constraint used by assertSame()
.
Upvotes: 3