PHP code example of devel0pmenthero / crash

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

    

devel0pmenthero / crash example snippets


Crash::Create(Subject::class, true, false);

Crash::CreateFromPath("./targetdir", true, false);

Crash::Test("./targetdir");


declare(strict_types=1);

namespace Crash\Tests;

use Crash\Test\Skip;
use Crash\Test\Method;
use Crash\Test\Method\Repeat;
use Crash\Test\Method\Values;
use Crash\Test\Method\Crash;

#[Skip]
class MyTest extends \Crash\Test {

    private int $Repetitions = 0;

    #[Repeat(5)]
    public function Repeat() {
        $this->Repetitions++;
    }

    public function RepeatedEnough(): void{
        \assert($this->Repetitions === 5);
    }
    
    #[Method\Skip]
    public function FailsAnyway(): void {
        \assert(false);
    }
    
    #[Values("a", 12, true)]
    public function Values($A, $B, $C): void {
        \assert($A === "a");
        \assert($B === 12);
        \assert($C === true);
    }    
    
    #[Values(Random: 8)]
    public function RandomValues(...$Values): void {
        \assert(\count($Values) === 8);
    }    
    
    #[Crash(Amount: 1000000, Interval: 20)]
    public function Crash(...$Values): void {
        ClassToTest::Method(...$Values);
    }

}
bash
php Crash.php -c[--create] --class="Subject"