1. Go to this page and download the library: Download verdephp/verde 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/ */
verdephp / verde example snippets
use function Verde\expect;
test('the Answer to Everything', function() {
expect(getTheAnswer())->toBe(42);
});
// or with PHPUnit:
class SimpleTest extends TestCase
{
public function test_the_answer_to_everything()
{
expect(getTheAnswer())->toBe(42);
}
}
use function Verde\expect;
test('retrieves the ingredients first and then bake the pizza', function () {
$spyGetPizzaIngredients = spyOn('getPizzaIngredients');
$spyBakePizza = spyOn('bakePizza');
// We don't want to make the HTTP request
$spyGetPizzaIngredients->mockReturnValue(['Mozzarella', 'Pomodoro']);
makePizza('Margherita');
// Here we make sure that the functions are called in the right order
expect($spyGetPizzaIngredients)->toHaveBeenCalledBefore($spyBakePizza);
// We can also check the arguments passed
expect($spyGetPizzaIngredients)->toHaveBeenCalledWith('Margherita');
expect($spyBakePizza)->toHaveBeenCalledWith(['Mozzarella', 'Pomodoro']);
});
use \Verde\expect;
use \Verde\func;
function theAnswerToEverything(callable $callback) {
$callback(42);
}
test('the mock function is called with the correct argument', function() {
$mockFunction = func();
theAnswerToEverything($mockFunction->getCallable());
// We can spy on the mock to see if it has been called and with which argument
expect($mockFunction)->toHaveBeenCalledWith(42);
})
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.