Splunk SDK for PHP Unit tests

The Splunk SDK for PHP is deprecated. For more information, see Deprecation notice.

A great place to look for examples of how to use the Splunk® SDK for PHP is in the unit tests. These are the same tests that we used to validate the core SDK library and they are located in the /splunk-sdk-php/tests directory.

First, make sure you have installed the following requirements:

  • PHPUnit version 3.6 or higher
  • Xdebug version 2.0.5 or higher (for code coverage)

Then, in the /splunk-sdk-php/tests directory, make a copy of the settings.default.php file and name it settings.local.php. Update the Splunk login credentials with the credentials for your test server.

To run all unit tests, enter:

phpunit tests

You can also run tests individually. For example, to run the HttpTest test, enter the following:

phpunit tests/HttpTest

To run only fast unit tests, enter:

phpunit --exclude-group slow tests

To generate a code coverage report, enter:

phpunit --coverage-html coverage tests
open coverage/Splunk.html