Some (extra) Usage documentation
It took quite some time to figure out how to unit test a single (current) file.
e.g. edit src/Services/MyClass.php build/test -> test/MyClassTest.php
Netbeans uses a custom php file NetBeansSuite and extends PHPUnit_Framework_TestSuite (and then even does a recursive glob() into the test dir to find files :-/ )
Here is a solution with build-variant to quickly run phpunit against a single test file. i've put the tests in a single "test" directory.
in Sublime Text 3, Primary-B runs the last build-variant you have selected. (S3 Build system might change this). Press Primary-Shift-B to choose the variant.
If you do not want to generate coverage for every test run, you can configure coverage setting thru the build-variant or, for the whole project, thru the xml
project.sublime-project
{
"folders": [
{ "path": "/Users/gdmac/Sites/projectdir" }
],
"settings": {
"phpcoverage": {
"report_path": "build/logs/clover.xml",
}
},
"build_systems": [
{
"name": "PHPUnit",
"working_dir": "${project_path}",
"cmd": [
"/usr/local/php5/bin/php",
"/usr/local/bin/phpunit",
],
"variants": [
{
"name": "CurrentFile",
"cmd": [
"/usr/local/php5/bin/php",
"/usr/local/bin/phpunit",
// "--coverage-clover",
// "build/logs/clover.xml",
"test/${file_base_name}Test.php",
]
},
]
}
]
}
phpunit.xml
<?xml version="1.0"?>
<phpunit
bootstrap="vendor/autoload.php"
colors="true"
>
<filter>
<whitelist addUncoveredFilesFromWhitelist="true">
<directory suffix=".php">src</directory>
<exclude>
<!-- <directory suffix=".php">/path/to/files</directory> -->
<file>src/Application.php</file>
</exclude>
</whitelist>
</filter>
<testsuites>
<testsuite name="TestAll">
<directory suffix="Test.php">test</directory>
</testsuite>
</testsuites>
<logging>
<log type="coverage-clover" target="build/logs/clover.xml" />
</logging>
</phpunit>