PHP code example of volt-test / laravel-performance-testing

1. Go to this page and download the library: Download volt-test/laravel-performance-testing 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/ */

    

volt-test / laravel-performance-testing example snippets


class LoginTest implements VoltTestCase
{
    public function define(VoltTestManager $manager): void
    {
        $manager->target('http://localhost:8000');

        $scenario = $manager->scenario('Login Flow');

        $scenario->step('Get Login Page')
            ->get('/login')
            ->expectStatus(200)
            ->extractCsrfToken();

        $scenario->step('Submit Login')
            ->post('/login', [
                '_token' => '${csrf_token}',
                'email' => '[email protected]',
                'password' => 'password',
            ])
            ->expectStatus(302);
    }
}
bash
php artisan vendor:publish --tag=volttest-config
bash
php artisan volttest:make LoginTest
bash
php artisan volttest:run LoginTest --users=10 --duration=30s