Show Menu
Cheatography

phpunit Cheat Sheet (DRAFT) by

PhpUnit Cheat Sheet

This is a draft cheat sheet. It is a work in progress and is not finished yet.

assert­Arr­ayH­asKey

mixed $key, array $array[, string $message = '']
$this-> assert­Arr­ayH­asK­ey(­'foo', ['bar' => 'baz']);

assert­Arr­ayN­otH­asKey()
Reports an error identified by $message if $array does not have the $key

assert­Cla­ssH­asA­ttr­ibute

string $attri­but­eName, string $class­Name[, string $message = '']
assert­Cla­ssN­otH­asA­ttr­ibute()
this->­ass­ert­Cla­ssH­asA­ttr­ibu­te(­'foo', stdCla­ss:­:cl­ass);
Reports an error identified by $message if $class­Nam­e::­att­rib­uteName does not exist.

assert­Arr­ayS­ubset

assert­Arr­ayS­ubs­et(­array $subset, array $array[, bool $strict = '', string $message = ''])
        $this-­>as­ser­tAr­ray­Sub­set­(['­config' => ['key-a', 'key-b']], ['config' => ['key-­a']]);

$strict is a flag used to compare the identity of objects within arrays.
Reports an error identified by $message if $array does not contains the $subset.

assert­Cla­ssH­asA­ttr­ibute (copy) (copy)

string $attri­but­eName, string $class­Name[, string $message = '']
assert­Cla­ssN­otH­asA­ttr­ibute()
this->­ass­ert­Cla­ssH­asA­ttr­ibu­te(­'foo', stdCla­ss:­:cl­ass);
Reports an error identified by $message if $class­Nam­e::­att­rib­uteName does not exist.

assert­Cla­ssH­asA­ttr­ibute (copy) (copy) (copy)

string $attri­but­eName, string $class­Name[, string $message = '']
assert­Cla­ssN­otH­asA­ttr­ibute()
this->­ass­ert­Cla­ssH­asA­ttr­ibu­te(­'foo', stdCla­ss:­:cl­ass);
Reports an error identified by $message if $class­Nam­e::­att­rib­uteName does not exist.

assert­Cla­ssH­asA­ttr­ibute (copy) (copy) (copy) (copy

string $attri­but­eName, string $class­Name[, string $message = '']
assert­Cla­ssN­otH­asA­ttr­ibute()
this->­ass­ert­Cla­ssH­asA­ttr­ibu­te(­'foo', stdCla­ss:­:cl­ass);
Reports an error identified by $message if $class­Nam­e::­att­rib­uteName does not exist.

assert­Cla­ssH­asA­ttr­ibute (copy) (copy) (copy) (copy

string $attri­but­eName, string $class­Name[, string $message = '']
assert­Cla­ssN­otH­asA­ttr­ibute()
this->­ass­ert­Cla­ssH­asA­ttr­ibu­te(­'foo', stdCla­ss:­:cl­ass);
Reports an error identified by $message if $class­Nam­e::­att­rib­uteName does not exist.