Phpunit issues full documentation

There is a description of what mocks is and how to work with them: http://www.phpunit.de/manual/current/en/test-doubles.html

But there is no comprehensive explanation of all the possible methods like $this->any() , $this->once() , $this->equalTo() , etc.

So I'm looking for a Mock Generation API

PS: yes, I know that I can see it in the sources, but I'm looking for an online API document

+7
source share
5 answers

There is no description of the API in one place, but the api part is described by the link you provided. Another part is available in "Writing Tests for PHPUnit"

+5
source

Sebastian Bergman’s book “Real-world solutions for developing high-quality PHP frameworks and applications” in more detail, but mainly with examples. The good thing about well-named methods is that they don't need full documentation. You just need to first understand the concepts of all this. Hint, equalTo () is often used inside custom statements, for example, $ this-> assertThat ($ foo, $ this-> logicalNot ($ this-> equalTo ($ bar))); or more usually inside expectations like → c ($ this-> equalTo ('something')) .

The basic concepts are well documented, I rarely had to delve into the source code. For example, with () "Specifies the statements made for the passed parameter. In the simplest cases, name it w / val, which you will use to call the method, in the same order. Params include: $ this-> anything (), $ this- > largeThan ($ n), $ this-> stringContains ($ str), isTrue (), isFalse (), isNull (), equalTo () etc. " Whereas once () is called from expectations () and expects () "registers a new wait, for example, how many times the method specified in the method () ($ count), once (), atLeastOnce (), never ( ), any () or at ($ index). "

+2
source

With this part of phpunit, ( documentation patches can be provided on github ), the source is documentation.

PHPUnit Claims List

List of all the functions you use in mock objects

All these functions return some type of PHPUnit_Framework_Constraint , which you can also use directly (although using the API is the preferred way). Basically, these are the same limitations that are described in "Writing Tests for PHPUnit" . The names are the same for most restrictions, such as → fileExists, but some are different (_or vs → logicalOr ()), but you can quickly find them in the source.

+2
source

I was wondering why the phpunit site itself does not publish full API documentation. Instead, they give only examples. So I downloaded the phpunit source and launched phpdoc. I published the generated API documentation at http://richardbrinkman.hol.es/phpunit/4.5.0/ so that others do not have to go through the same problems.

+2
source

I just generated PHPUnit API documentation with Sami and published on GitHub Pages using Travis .

+2
source

All Articles