You Are Here: Home » Documentation » Reports

Enhance PHP Unit Testing And Mocking Framework improve the quality

Reports

Enhance PHP has Command Line, HTML and XML reports. 

To get your preferred report, you just pass in the type of report you want:

\Enhance\Core::runTests('Html');

You can use the built-in constants rather than magic strings:

\Enhance\Core::runTests(\Enhance\TemplateType::Html);

The available options are:

Here are examples of the reports...

Command Line

If you run Enhance PHP from the command line, you will automatically get the command line version of the report - you can also get the command line output in your browser using:

\Enhance\Core::runTests(\Enhance\TemplateType::Cli);

Simply run the command from the folder containing your test file, calling the php program and passing in the file name of your test file.

These examples are from a Windows machine, but it works just as well on your Linux machine too.

C:\enhance\tests> C:\php\php5.3.0\php.exe MyTest.php

Enhance PHP Command Line

Html

\Enhance\Core::runTests(); // html is the default option

You can view a live HTML report here.

TAP

TAP (Test Anything Protocol) is a specific format that outputs test results in machine readable format.

1..3
ok 1 assertAreIdenticalWithIdenticalIntegers - Passed
ok 2 assertAreIdenticalWithDifferentIntegers - Passed
ok 3 assertAreIdenticalWithIdenticalStrings - Passed

Xml

You can opt for XML reports if you prefer, simply set XML as the output type when you call runTests:

\Enhance\Core::runTests(\Enhance\TemplateType::Xml);

Here is an example of the output.

<?xml version="1.0" encoding="UTF-8" ?>
	<enhance>
		<result>Test Failed</result>
		<testResults>
			<fail>AddTwoNumbersWith5and5Expect9Test - Failed</fail>
			<pass>AddTwoNumbersWith3and2Expect5Test - Passed</pass>
			<pass>AddTwoNumbersWith4and2Expect6Test - Passed</pass>
		</testResults>
		<codeCoverage>
			<method>
				<name>ExampleClass->AddTwoNumbers</name>
				<timesCalled>3</timesCalled>
			</method>
		</codeCoverage>
		<testRunDuration>0</testRunDuration>
	</enhance>