PHP code example of peridot-php / peridot-httpkernel-plugin

1. Go to this page and download the library: Download peridot-php/peridot-httpkernel-plugin 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/ */

    

peridot-php / peridot-httpkernel-plugin example snippets



use Evenement\EventEmitterInterface;
use Peridot\Plugin\HttpKernel\HttpKernelPlugin;

return function(EventEmitterInterface $emitter) {
    //the second argument expects an HttpKernelInterface or a function that returns one
    HttpKernelPlugin::register($emitter, 


describe('Api', function() {
    describe('/info', function() {
        it('should return info about Peridot', function() {
            $this->client->request('GET', '/info');
            $response = $this->client->getResponse();
            $info = json_decode($response->getContent());
            assert($info->project == "Peridot", "project should be Peridot");
            assert($info->description == "Event driven testing framework", "description should describe Peridot");
            assert($info->styles == "BDD, TDD", "styles should be BDD, TDD");
        });
    });

    describe('/author', function() {
        it('should return info about the author', function() {
            $this->client->request('GET', '/author');
            $author = json_decode($this->client->getResponse()->getContent());
            assert($author->name == "Brian Scaturro", "author name should be on response");
            assert($author->likes == "pizza", "author should like pizza");
        });
    });
});


use Peridot\Plugin\HttpKernel\HttpKernelScope;

describe('Api', function() {

    //here we manually mixin the http kernel scope
    $scope = new HttpKernelScope(->request('GET', '/author');
            $author = json_decode($this->client->getResponse()->getContent());
            assert($author->name == "Brian Scaturro", "author name should be on response");
            assert($author->likes == "pizza", "author should like pizza");
        });
    });
});

HttpKernelPlugin::register($emitter, ation, "browser");


use Peridot\Plugin\HttpKernel\HttpKernelScope;

describe('Api', function() {

    describe('/author', function() {
        it('should return info about the author', function() {
            $this->browser->request('GET', '/author');
            $author = json_decode($this->browser->getResponse()->getContent());
            assert($author->name == "Brian Scaturro", "author name should be on response");
            assert($author->likes == "pizza", "author should like pizza");
        });
    });
});

$ composer 

$ vendor/bin/peridot -c app/peridot.php app/specs/api.spec.php