PHP code example of tembra / pest-plugin-x-args

1. Go to this page and download the library: Download tembra/pest-plugin-x-args 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/ */

    

tembra / pest-plugin-x-args example snippets


use function Tembra\Pest\Plugins\XArgs\{hasXArg};
use function Tembra\Pest\Plugins\XArgs\{getXArg};

it('has --x-username and --x-password argument', function () {
    $hasUsername = hasXArg('username');
    $hasPassword = hasXArg('password');

    expect($hasUsername)->toBe(true)
        ->and($hasPassword)->toBe(true);
});

it('can login with valid credentials', function () {
    $username = getXArg('username');
    $password = getXArg('password');

    if (null === $username || null === $password) {
        $this->fail('You need to send valid username/password through command line.');
    }

    // try to login with $username and $password
    // and make expectations and/or assertions with result
});