I want to mock some methods from an external dependency class without executing the original constructor for this external class. This external class is from somewhere else, imported to our project by composer for example.
Continue reading
Tag Archives: PHPUnit
How to show PHPUnit test results and test code coverage in TeamCity
First of all there is a useful article about integration between PHP and TeamCity in the documentation to TeamCity 8 called Getting started with PHP. It is worth to read it.
Continue reading
How to mock different methods of the same class and how to mock one method with different arguments
I want to mock different methods of the same class and mock one method with different argument values. Using standard PHPUnit.
Mocks in PHPUnit are being created using getMock() method. It belongs to PHPUnit_Framework_TestCase
class, that is described in .../PEAR/PHPUnit/Framework/TestCase.php
file. Continue reading
How to test in different browsers with PHPUnit-Selenium
PHPUnit v 3.7 documetation says that we can run same test in different browsers. We have to create a descendant class from PHPUnit_Extensions_SeleniumTestCase with a special variable called $browsers.
Continue reading
How to create mock for a method with reference parameters
While testing PHP we need sometimes to create a mock for a method with reference parameters. I use returnCallback() from PHPUnit framework to to this. returnCallback() will call a function that imitates functionality of the original method. The original method can be either public or protected.
Continue reading