1. Go to this page and download the library: Download habanero/spectre library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
habanero / spectre example snippets
function sum($a, $b)
{
return $a + $b;
}
ibe('sum()', function () {
it('sums two numbers', function () {
expect(sum(2, 2))->toBe(4);
});
});
\Spectre\Base::customMatchers('toBeCustomValue', function ($expected, $value) {
// test $value against $this->expected
// then return true or false
//
// or for custom messages:
//
// return array(
// 'result' => $expected === $value,
// 'negative' => "Expected '{subject}' {verb} '{value}', but it did not",
// 'positive' => "Did not expect '{subject}' {verb} '{value}', but it did",
// );
});