PHP code example of eddiejaoude / phpunit-wrapper

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

    

eddiejaoude / phpunit-wrapper example snippets


    $this->assertEquals($expected, $actual);

    // or with custom message

    $this->assertEquals($expected, $actual, $message);

    $this->expectedValue('abc')
                ->equals('abc');

    // or with custom message

    $this->expectedValue('abc')
            ->setMessage('Failure, these are not equal!') // optional
            ->equals('abc');

    $this->assertNotEquals($expected, $actual, $message);

    $this->expectedValue('abc')
            ->notEquals('abcd');

    $this->assertContains($needle, $haystack);

    // or with custom message

    $this->assertContains($needle, $haystack, $message);

    $this->expectedValue($needle)
            ->existsIn($haystack);

    $this->expectedValue('b')
            ->existsIn(
                array('a', 'b', 'c')
            );

    // or with custom message

    $this->expectedValue('b')
            ->setMessage('Failure, does not exist!') // optional
            ->existsIn(
                array('a', 'b', 'c')
            );

    $this->assertNotContains($needle, $haystack);

    // or with custom message

    $this->assertNotContains($needle, $haystack, $message);

    $this->expectedValue($needle)
            ->notExistsIn($haystack);

    $this->expectedValue('b')
            ->notExistsIn(
                array('a', 'c')
            );

    // or with custom message

    $this->expectedValue('b')
            ->setMessage('Failure, does exist!') // optional
            ->notExistsIn(
                array('a', 'c')
            );


namespace EddieJaoude\PHPUnitWrapperTest;

use EddieJaoude\PHPUnitWrapper\Assert;

/**
 * Class ExampleTest
 *
 * @package EddieJaoude\PHPUnitWrapperTest
 */
class ExampleTest extends Assert
{

    /*
     * Example of 'assert' & 'equals'
     */
    public function testAssertEquals()
    {
        $this->expectedValue('abc')
            ->equals('abc');
    }

    /*
     * Example of 'assert' & 'equals'
     */
    public function testAssertNotEquals()
    {
        $this->expectedValue('abc')
            ->notEquals('abcd');
    }
}