about me about me
photography photography
software projects software projects
contact me contact me

I occasionally need the list of method parameter matchers when setting assertions via mocks using with(). A completely useless example:

$foo->expects($this->once())
    ->method('setter')
    ->with($this->isType('string'));


I can see a few documented in the examples but the most conclusive list I’ve come across is from slide 11 of these Advanced PHPUnit Testing slides. So I am posting them here, if only for my own use:

$this->anything()
$this->contains($value)
$this->arrayHasKey($key)
$this->equalTo($value, $delta, $maxDepth)
$this->classHasAttribute($attribute)
$this->greaterThan($value)
$this->isInstanceOf($className)
$this->isType($type)
$this->matchesRegularExpression($pattern)
$this->stringContains($string, $case)

comments

Mihailo Joksimovic // 24.Jun.2012 // 22:39

Thanks !

Thiago // 05.Dec.2012 // 20:55

Thanks +!

Andrew Zavadsky // 10.Jan.2013 // 15:43

Also you can use:

$this->logicalAnd();
$this->logicalOr();
$this->logicalNot();
$this->logicalXor();

Matt // 10.Oct.2013 // 14:53

Cheers

Alwin // 23.Jan.2014 // 09:25

a full List is available in the source code itself:
https://github.com/sebastianbergmann/phpunit/blob/master/src/Framework/Assert.php