PHP code example of icanhazstring / phpunit-faker-extension

1. Go to this page and download the library: Download icanhazstring/phpunit-faker-extension 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/ */

    

icanhazstring / phpunit-faker-extension example snippets


class AwesomeTest extends TestCase implements FakerAwareTest
{
    use FakerTrait;
    
    public function testAwesomeStuff(): void
    {
        $this->assertSame($this->fake()->name, $this->fake()->name);
    }
}
xml
<phpunit bootstrap="vendor/autoload.php">
...
    <listeners>
        <listener class="PHPUnitFaker\FakerTestListener" />
    </listeners>
</phpunit>
xml
<phpunit bootstrap="vendor/autoload.php">
    <!-- ... other suite configuration here ... -->

    <listeners>
        <listener class="PHPUnitFaker\FakerTestListener">
            <arguments>
                <array>
                    <element key="locale">
                        <string>de_DE</string>
                    </element>
                    <element key="fakerProviderProvider">
                        <string>Your\FakerProviderProvider</string>
                    </element>
                </array>
            </arguments>
        </listener>
    </listeners>
</phpunit>