1. Go to this page and download the library: Download zfegg/expressive-test 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/ */
zfegg / expressive-test example snippets
use Psr\Http\Message\ResponseInterface;
use Zfegg\ExpressiveTest\AbstractActionTestCase;
class HomePageTest extends AbstractActionTestCase {
public function testHome() {
$response = $this->runApp(
'POST',
'/?test=1',
['body' => '2'],
['HTTP_CONTENT_TYPE' => 'application/json'],
'{"a":"b"}',
['cookie' => '3']
);
$this->assertInstanceOf(ResponseInterface::class, $response);
}
public function testPassMiddlewareOrMockService() {
$this->container->setService('some middleware', new PassMiddleware());
$mock = $this->createMock(SomeService::class);
$this->container->setService('mock some service', $mock);
$response = $this->runApp(
'POST',
'/?test=1',
['body' => '2'],
['HTTP_CONTENT_TYPE' => 'application/json'],
'{"a":"b"}',
['cookie' => '3']
);
$this->assertInstanceOf(ResponseInterface::class, $response);
}
}
use Psr\Http\Message\ResponseInterface;
use Zfegg\ExpressiveTest\AbstractActionTestCase;
use Zfegg\ExpressiveTest\PassMiddleware;
class HomePageTest extends AbstractActionTestCase {
public function testHome() {
// Pass a authentication middleware.
$this->container->setService(AuthenticationMiddleware::class, PassMiddleware::class);
$response = $this->getJson('/api/users');
$response->assertOk();
}
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.