PHP code example of schranz / test-generator

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

    

schranz / test-generator example snippets


public function setTitle(?string $title): void
{
    $this->title = $title;
}

public function getTitle(): void
{
    $this->title = $title;
}

public function testSetTitle(): void
{
    $model = $this->createInstance();
    $model->setTitle('Test');
    $this->assertSame('Test', $model->getTitle());
}

public function testSetTitleNull(): void
{
    $model = $this->createInstance();
    $model->setTitle(null);
    $this->assertNull($model->getTitle());
}



use Schranz\TestGenerator\Domain\Model\Config;

$config = new Config();
// add following hooks if you want to use `rector` or `php-cs-fixer` directly on the created test files
// $config->hooks[] = 'vendor/bin/rector process %s';
// $config->hooks[] = 'vendor/bin/php-cs-fixer fix %s';

return $config;
bash
vendor/bin/test-generator src/YourNameSpace/YourFile.php