PHP code example of anik / testbench-lumen
1. Go to this page and download the library: Download anik/testbench-lumen 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/ */
anik / testbench-lumen example snippets
protected function serviceProviders(): array
{
return [
// AppServiceProvider::class,
// FormRequestServiceProvider::class,
// AmqpServiceProvider::class,
];
}
protected function globalMiddlewares(Application $app): array
{
return [
// CorsMiddleware::class,
// NewrelicMiddleware::class,
];
}
protected function routeMiddlewares(Application $app): array
{
return [
// 'auth' => Authenticate::class,
// 'admin' => AdminMiddleware::class,
];
}
protected function routes(Router $router): void
{
$router->get('test-route', function () {
return response()->json([
'error' => false,
'message' => 'Test route is executed'
], 202);
});
}
protected function dontReportExceptions(): array
{
return [
// AuthenticationException::class,
];
}
protected function beforeServiceProviders(Application $app)
{
$app['config']->set(['my-package.enabled' => false]);
}
protected function firstCalled(Application $app)
{
$app->bind('value-should-be-found', function () {
return 'as-is';
});
}
protected function secondCalled(Application $app)
{
$app->bind('value-should-be-found', function () {
return 'modified';
});
}
/**
* @setup-before firstCalled
* @setup-before secondCalled
*/
public function testMultipleAnnotations()
{
$this->assertEquals('modified', $this->app->make('value-should-be-found'));
}
public function defineEnvironmentVariables(Application $app)
{
$app['config']->set(['testbench-lumen.enabled' => true]);
}
/**
* @pre-service-register defineEnvironmentVariables
*/
public function testDefineEnvAnnotation()
{
$this->assertEquals(true, $this->app['config']->get('testbench-lumen.enabled'));
}
xml
<phpunit>
// ...
<php>
<env name="APP_ENV" value="testing"/>
<env name="CACHE_DRIVER" value="array"/>
</php>
</phpunit>