1. Go to this page and download the library: Download jacobstr/matura 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/ */
jacobstr / matura example snippets
describe('Matura', function ($ctx){
it('should make writing tests fun', function ($ctx) {
expect($are_we_having_fun_yet)->to->eql(true);
});
});
describe('User', function ($ctx) {
describe('Authorization', function ($ctx){
describe('OAuth', function ($ctx) {});
});
});
describe('User Database', function ($ctx) {
foreach(range(1,5) as $repetition) {
it('should insert a user', function ($ctx){
$user = $ctx->db->findOne(array(
'username' => $ctx->username;
));
expect($user)->to->have->length(1);
});
it('should not accumulate users', function ($ctx){
$users = $ctx->db->find();
expect($users)->to->have->length(1);
});
}
// Executed once for each describe block.
before_all(function ($ctx){
$ctx->test_id = uniqid();
$ctx->test_db = 'DB_'.$ctx->test_id;
$ctx->db = new Database('localhost', $ctx->test_db);
});
// Executed prior to each test (including descendants).
before(function ($ctx){
$ctx->username = 'test_user'.$ctx->test_id.uniqid();
$ctx->db->insert(array('username' => $ctx->username));
});
// Executed after each test (including descendants);
after(function ($ctx) {
$ctx->db->delete(array('username' => $ctx->username));
});
// Executed once at the very end of this describe block.
after_all(function ($ctx) {
$ctx->db->drop($ctx->test_db);
});
});