PHP code example of traviscarden / behat-table-comparison

1. Go to this page and download the library: Download traviscarden/behat-table-comparison 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/ */

    

traviscarden / behat-table-comparison example snippets




use Behat\Behat\Context\Context;
use Behat\Gherkin\Node\TableNode;
use TravisCarden\BehatTableComparison\TableEqualityAssertion;

class FeatureContext implements Context
{

    /**
     * @Then I should include the following characters in the Company of the Ring
     */
    public function iShouldIncludeTheFollowingCharactersInTheCompanyOfTheRing(TableNode $expected)
    {
        // Get the data from the application and create a table from it.
        $application_data = [
            ['name', 'race'],  // Header row (tual))
            ->expectHeader(['name', 'race'])
            ->ignoreRowOrder()
            ->setMissingRowsLabel('Missing characters')
            ->setUnexpectedRowsLabel('Unexpected characters')
            ->setDuplicateRowsLabel('Duplicate characters')
            ->assert();
    }

}

try {
    (new TableEqualityAssertion($expected, $actual))->assert();
} catch (UnequalTablesException $e) {
    match ($e->getCode()) {
        UnequalTablesException::HEADER_MISMATCH    => /* handle header issue */,
        UnequalTablesException::ROW_ORDER_MISMATCH => /* handle order issue */,
        default                                    => /* handle content issue */,
    };
}