PHP code example of xepozz / test-it

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

    

xepozz / test-it example snippets




declare(strict_types=1);

namespace Xepozz\TestIt\Tests\Integration\OneParameter\src;

class UserController
{
    public function inverse(bool $value): bool
    {
        return !$value;
    }
}



declare(strict_types=1);

namespace Xepozz\TestIt\Tests\Integration\OneParameter\tests;

use Xepozz\TestIt\Tests\Integration\OneParameter\src\UserController;

final class UserControllerTest extends \PHPUnit\Framework\TestCase
{
    /**
     * @dataProvider dataProviderInverse
     */
    public function testInverse(bool $expectedValue, bool $valueValue): void
    {
        // arrange
        $userController = new UserController();

        // act
        $actualValue = $userController->inverse($valueValue);

        // assert
        $this->assertEquals($expectedValue, $actualValue);
    }


    public static function dataProviderInverse(): iterable
    {
        yield [false, true];
        yield [true, false];
    }
}



declare(strict_types=1);

use Xepozz\TestIt\Config;

return function (Config $config) {
    $config
        // disabled results substitution
        ->evaluateCases(false)
        // sets a directory to scan
        ->setSourceDirectory('src')
        // excludes particular files from scanning
        ->excludeFiles([
            __DIR__ . '/src/Kernel.php',
        ])
        // excludes particular directories and all child directories from scanning
        ->excludeDirectories([
            __DIR__ . '/src/Asset',
            __DIR__ . '/src/Controller',
            __DIR__ . '/src/View',
        ])
        //