I notice that when I use mock objects, PHPUnit will correctly report the number of tests performed, but it will incorrectly report the number of statements I make. In fact, every time I mock him, this is considered another statement. A test file with 6 tests, 7 statements and each test, scoffed once, reported 6 tests, 13 statements.
Here is a test file with only one test deleted (for illustration here), plus I presented another test that does not jam to track this problem. PHPUnit reports 2 tests, 3 statements. I delete the mannequin: 1 test, 2 statements.
require_once '..\src\AntProxy.php'; class AntProxyTest extends PHPUnit_Framework_TestCase { const sample_client_id = '495d179b94879240799f69e9fc868234'; const timezone = 'Australia/Sydney'; const stubbed_ant = "stubbed ant"; const date_format = "Y"; public function testBlankCategoryIfNoCacheExists() { $cat = ''; $cache_filename = $cat.'.xml'; if (file_exists($cache_filename)) unlink($cache_filename); $stub = $this->stub_Freshant($cat); $expected_output = self::stubbed_ant; $actual_output = $stub->getant(); $this->assertEquals($expected_output, $actual_output); } public function testDummyWithoutStubbing() { $nostub = new AntProxy(self::sample_client_id, '', self::timezone, self::date_format); $this->assertTrue(true); } private function stub_FreshAnt($cat) { $stub = $this->getMockBuilder('AntProxy') ->setMethods(array('getFreshAnt')) ->setConstructorArgs(array(self::sample_client_id, $cat, self::timezone, self::date_format)) ->getMock(); $stub->expects($this->any()) ->method('getFreshAnt') ->will($this->returnValue(self::stubbed_ant)); return $stub; } }
This is similar to the statement left in one of the standard methods of bullying. Is there a way to show each (passing) statement?
source share