/** * @param Process $process * * @return TestCase */ public function test(Process $process) { $process->run(); $testcase = new TestCase($process->getCommandLine(), 0); $testcase->incAssertions(); if ($process->getExitCode() != 0) { $testcase->setFailure(new TestFailure('exec', $process->getOutput())); return $testcase; } return $testcase; }
public function testWithTestSuite() { $master = TestSuite::create('master', null); $suite = TestSuite::create('myname', '/foo/bar.php', 'foo.bar', 'foo.bar'); $suite->addTestCase(TestCase::create('myname', 2, 0.345, 'stdClass', '/foo/bar.php', 12)); $suite->addTestCase(TestCase::create('foobar', 2, 0.345, 'stdClass', '/foo/bar.php', 25)); $master->addTestSuite($suite); $this->assertEquals(4, $suite->getAssertions()); }
public function testSave() { $suite = TestSuite::create('myname "', '/foo/bar.php', 'foo.bar', 'foo.bar'); $testcase = TestCase::create('myname "', 2, 0.345, 'stdClass', '/foo/bar.php', 12); $testcase->setError(new TestError('my "type', "</error> message ]]>")); $suite->addTestCase($testcase); $suite->addTestCase(TestCase::create('foobar', 2, 0.345, 'stdClass', '/foo/bar.php', 25)); $write = new JUnitWriter(); $write->save($suite, $resource = tmpfile()); fseek($resource, 0); $contents = fread($resource, 4096); fclose($resource); $xml = new \SimpleXMLElement($contents); $this->assertEquals(2, count($xml->xpath('//testcase'))); }
/** * @param TestCase $testCase */ public function addTestCase(TestCase $testCase) { $this->testCases[] = $testCase; $this->time += $testCase->getTime(); $this->assertions += $testCase->getAssertions(); $this->errors += $testCase->getError() ? 1 : 0; $this->failures += $testCase->getFailure() ? 1 : 0; }
public function testStaticMethod() { $message = TestCase::create('myname', 2, 0.345, 'stdClass', '/foo/bar.php', 12); $expected = '<testcase name="myname" class="stdClass" file="/foo/bar.php" line="12" assertions="2" time="0.345000"/>'; $this->assertEquals($expected, $message->toXml()); }