Prev | Next |
The attributes of the <phpunit>
element can
be used to configure PHPUnit's core functionality.
<phpunit backupGlobals="false" backupStaticAttributes="true" bootstrap="/path/to/bootstrap.php" colors="false" convertErrorsToExceptions="true" convertNoticesToExceptions="true" convertWarningsToExceptions="true" processIsolation="true" stopOnFailure="true" syntaxCheck="false" testSuiteLoaderClass="PHPUnit_Runner_StandardTestSuiteLoader" verbose="true" strict="true"> <!-- ... --> </phpunit>
The XML configuration above corresponds to invoking the TextUI test runner with the following switches:
--no-globals-backup
--static-backup
--bootstrap /path/to/bootstrap.php
--colors
--process-isolation
--stop-on-failure
--no-syntax-check
--loader PHPUnit_Runner_StandardTestSuiteLoader
--verbose
--strict
The convertErrorsToExceptions
,
convertNoticesToExceptions
, and
convertWarningsToExceptions
attributes have no
equivalent TextUI test runner switch.
The <testsuites>
element and its
one or more <testsuite>
children can be
used to compose a test suite out of test suites and test cases.
<testsuites> <testsuite name="My Test Suite"> <directory>/path/to/*Test.php files</directory> <file>/path/to/MyTest.php</file> </testsuite> </testsuites>
The <groups>
element and its
<include>
,
<exclude>
, and
<group>
children can be used to select
groups of tests from a suite of tests that should (not) be run.
<groups> <include> <group>name</group> </include> <exclude> <group>name</group> </exclude> </groups>
The XML configuration above corresponds to invoking the TextUI test runner with the following switches:
--group name
--exclude-group name
The <filter>
element and its children can
be used to configure the blacklist and whitelist for the code coverage
reporting.
<filter> <blacklist> <directory suffix=".php">/path/to/files</directory> <file>/path/to/file</file> <exclude> <directory suffix=".php">/path/to/files</directory> <file>/path/to/file</file> </exclude> </blacklist> <whitelist> <directory suffix=".php">/path/to/files</directory> <file>/path/to/file</file> <exclude> <directory suffix=".php">/path/to/files</directory> <file>/path/to/file</file> </exclude> </whitelist> </filter>
The XML configuration above corresponds to using the
PHP_CodeCoverage_Filter
class as follows:
PHP_CodeCoverage_Filter::getInstance()->addDirectoryToBlacklist( '/path/to/files', '.php' ); PHP_CodeCoverage_Filter::getInstance()->addFileToBlacklist('/path/to/file'); PHP_CodeCoverage_Filter::getInstance()->removeDirectoryFromBlacklist( '/path/to/files', '.php' ); PHP_CodeCoverage_Filter::getInstance()->removeFileFromBlacklist('/path/to/file'); PHP_CodeCoverage_Filter::getInstance()->addDirectoryToWhitelist( '/path/to/files', '.php' ); PHP_CodeCoverage_Filter::getInstance()->addFileToWhitelist('/path/to/file'); PHP_CodeCoverage_Filter::getInstance()->removeDirectoryFromWhitelist( '/path/to/files', '.php' ); PHP_CodeCoverage_Filter::getInstance()->removeFileFromWhitelist('/path/to/file');
The <logging>
element and its
<log>
children can be used to configure the
logging of the test execution.
<logging> <log type="coverage-html" target="/tmp/report" charset="UTF-8" yui="true" highlight="false" lowUpperBound="35" highLowerBound="70"/> <log type="coverage-xml" target="/tmp/coverage.xml"/> <log type="json" target="/tmp/logfile.json"/> <log type="tap" target="/tmp/logfile.tap"/> <log type="junit" target="/tmp/logfile.xml" logIncompleteSkipped="false"/> <log type="testdox-html" target="/tmp/testdox.html"/> <log type="testdox-text" target="/tmp/testdox.txt"/> </logging>
The XML configuration above corresponds to invoking the TextUI test runner with the following switches:
--coverage-html /tmp/report
--coverage-xml /tmp/coverage.xml
--log-json /tmp/logfile.json
> /tmp/logfile.txt
--log-tap /tmp/logfile.tap
--log-junit /tmp/logfile.xml
--testdox-html /tmp/testdox.html
--testdox-text /tmp/testdox.txt
The charset
, yui
,
highlight
, lowUpperBound
,
highLowerBound
, and logIncompleteSkipped
attributes have no equivalent TextUI test runner switch.
The <listeners>
element and its
<listener>
children can be used to attach
additional test listeners to the test execution.
<listeners> <listener class="MyListener" file="/optional/path/to/MyListener.php"> <arguments> <array> <element key="0"> <string>Sebastian</string> </element> </array> <integer>22</integer> <string>April</string> <double>19.78</double> <null/> <object class="stdClass"/> </arguments> </listener> </listeners>
The XML configuration above corresponds to attaching the
$listener
object (see below) to the test execution:
$listener = new MyListener( array('Sebastian'), 22, 'April', 19.78, NULL, new stdClass );
The <php>
element and its children can be
used to configure PHP settings, constants, and global variables. It can
also be used to prepend the include_path
.
<php> <includePath>.</includePath> <ini name="foo" value="bar"/> <const name="foo" value="bar"/> <var name="foo" value="bar"/> <env name="foo" value="bar"/> <post name="foo" value="bar"/> <get name="foo" value="bar"/> <cookie name="foo" value="bar"/> <server name="foo" value="bar"/> <files name="foo" value="bar"/> <request name="foo" value="bar"/> </php>
The XML configuration above corresponds to the following PHP code:
ini_set('foo', 'bar'); define('foo', 'bar'); $GLOBALS['foo'] = 'bar'; $_ENV['foo'] = 'bar'; $_POST['foo'] = 'bar'; $_GET['foo'] = 'bar'; $_COOKIE['foo'] = 'bar'; $_SERVER['foo'] = 'bar'; $_FILES['foo'] = 'bar'; $_REQUEST['foo'] = 'bar';
The <selenium>
element and its
<browser>
children can be used to
configure a list of Selenium RC servers.
<selenium> <browser name="Firefox on Linux" browser="*firefox /usr/lib/firefox/firefox-bin" host="my.linux.box" port="4444" timeout="30000"/> </selenium>
The XML configuration above corresponds to the following PHP code:
class WebTest extends PHPUnit_Extensions_SeleniumTestCase { public static $browsers = array( array( 'name' => 'Firefox on Linux', 'browser' => '*firefox /usr/lib/firefox/firefox-bin', 'host' => 'my.linux.box', 'port' => 4444, 'timeout' => 30000 ) ); // ... }
Prev | Next |
assertArrayHasKey()
assertClassHasAttribute()
assertClassHasStaticAttribute()
assertContains()
assertContainsOnly()
assertEmpty()
assertEqualXMLStructure()
assertEquals()
assertFalse()
assertFileEquals()
assertFileExists()
assertGreaterThan()
assertGreaterThanOrEqual()
assertInstanceOf()
assertInternalType()
assertLessThan()
assertLessThanOrEqual()
assertNull()
assertObjectHasAttribute()
assertRegExp()
assertStringMatchesFormat()
assertStringMatchesFormatFile()
assertSame()
assertSelectCount()
assertSelectEquals()
assertSelectRegExp()
assertStringEndsWith()
assertStringEqualsFile()
assertStringStartsWith()
assertTag()
assertThat()
assertTrue()
assertType()
assertXmlFileEqualsXmlFile()
assertXmlStringEqualsXmlFile()
assertXmlStringEqualsXmlString()
Copyright © 2005-2010 Sebastian Bergmann.