1. Go to this page and download the library: Download cerbero/octane-testbench 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/ */
cerbero / octane-testbench example snippets
use Cerbero\OctaneTestbench\TestsOctaneApplication;
use Illuminate\Foundation\Testing\TestCase as BaseTestCase;
abstract class TestCase extends BaseTestCase
{
use TestsOctaneApplication;
}
Route::get('web-route', fn () => 123);
Octane::route('POST', '/octane-route', fn () => new Response('foo'));
public function test_web_route()
{
$this->get('web-route')->assertOk()->assertSee('123');
}
public function test_octane_route()
{
$this->post('octane-route')->assertOk()->assertSee('foo');
}
$this
->get('failing-route')
->dump() // dump the whole response/exception
->dump('original') // dump only a specific property
->dd() // dump-and-die the whole response/exception
->dd('headers'); // dump-and-die only a specific property
$this
->expectsConcurrencyException() // tasks fail due to a generic exception
->get('route');
$this
->expectsConcurrencyException(new Exception('message')) // tasks fail due to a specific exception
->get('route');
$this
->expectsConcurrencyTimeout() // tasks fail due to a timeout
->get('route');
$this
->assertOctaneCacheMissing($key) // assert the key is not set
->get('route')
->assertOctaneCacheHas($key) // assert the key is set
->assertOctaneCacheHas($key, $value); // assert the key has the given value
$this
->assertOctaneTableMissing($table, $row) // assert the row is not present in the table
->assertOctaneTableCount($table, 0) // assert the number of rows in the table
->get('route')
->assertOctaneTableHas($table, $row) // assert the row is present in the table
->assertOctaneTableHas($table, 'row.column' $value) // assert the column in the row has the given value
->assertOctaneTableCount($table, 1);