1. Go to this page and download the library: Download igarastudio/visit 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/ */
igarastudio / visit example snippets
use PHPUnit\Framework\TestCase;
use IgaraStudio\Visit;
use function IgaraStudio\visit;
// If this test is in /tests/ and your index.php file in /public/ dir
Visit::$shared_options = [ 'docroot' => __DIR__ . '/../public',
'script' => __DIR__ . '/../public/index.php' ];
class UserLoginTest extends TestCase
{
// Simulates a GET request to /login to check if the 'Login' text appears
// in the page.
public function testVisibleLoginButton(): void
{
visit('/login')->assertSee('Login');
}
// Simulates a POST request to /login with a specific form data, checks
public function testInvalidLogin(): void
{
visit()
->post('/login', ['username' => 'invalid',
'password' => 'invalid'])
->assertSee('Invalid user or password');
}
// This login works because we process Cookie and Set-Cookie to keep the PHP
// session in the same visit().
public function testValidLogin(): void
{
visit()
->post('/login', ['username' => 'valid-username',
'password' => 'valid-password'])
->assertSee('Dashboard');
}
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.