PHP code example of jeroen-g / testassist

1. Go to this page and download the library: Download jeroen-g/testassist 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/ */

    

jeroen-g / testassist example snippets



use JeroenG\TestAssist\Assistants;

class MyTest {
    use Assistants;

    // ...
}


public function test_this()
{
    $this->assertIsCalled(UserHasSignedUp::class, function() {
        User::create([....]);
    });
}

use JeroenG\TestAssist\Browser\ClearCookiesBetweenTests;

protected function tearDown()
{
    parent::tearDown();
    $this->clearCookies();
}

$member = $this->create(User::class);
$member = $this->make(User::class);

$this->assertCreated('users', $member);
$this->assertUpdated('users', $member);
$this->assertDeleted('users', $member);

$this->AddRegexToSQLite();

// At the top of your class:
use JeroenG\TestAssist\Assistants;

// in setUp():
$this->runSeeder();

// If Concerns\SeedDatabase is used, go seed the database, but only once per class.
if (isset(static::$seedDatabase) && static::$seedDatabase != false) {
    $this->seedDatabase();
    static::$seedDatabase = false;
}

function test_filesystem() {
    $this->assertFileExistsOnDisk($filename); // Optionally pass the storage disk (defualt: local)
    $this->assertFileNotExistsOnDisk($filename);
    $this->assertFileExistsInZip($zipPath, $filename);
    $this->assertFileDoesntExistsInZip($zipPath, $filename);
}