PHP code example of keboola / datadir-tests

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

    

keboola / datadir-tests example snippets




declare(strict_types=1);

namespace MyComponent\Tests;

use Keboola\DatadirTests\DatadirTestCase;

class DatadirTest extends DatadirTestCase
{
}


public function testInvalidFile(): void
{
    // create specification manually
    $specification = new DatadirTestSpecification(
        __DIR__ . '/columns-auto/source/data',
        0,
        null,
        null,
        __DIR__ . '/columns-auto/expected/data/out'
    );
    
    // create temporary directory
    $tempDatadir = $this->getTempDatadir($specification);
    
    // modify temporary directory however you see fit
    file_put_contents($tempDatadir->getTmpFolder() . '/config.json', '{"parameters": []}');
    
    // run the script
    $process = $this->runScript($tempDatadir->getTmpFolder());
    
    // assert specification
    $this->assertMatchesSpecification($specification, $process, $tempDatadir->getTmpFolder());
}