PHP code example of phpfan / phpunit-patch

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

    

phpfan / phpunit-patch example snippets


class AssertionTest extends TestCase
{
    protected function callAssertSameReceivingClosure(\Closure $closure)
    {
        static::assertSame('aaa', 'bbb');
    }

    /**
     * @runInSeparateProcess
     * @preserveGlobalState disabled
     */
    public function testAssertionIncludingUnserializableTrace()
    {
        static::callAssertSameInClosure(function () {});
    }
}

class DataProviderTest extends TestCase
{
    public function provideAdditionTestParams()
    {
        return [
            'say hello' => [
                function ($mr) {
                    return "Hello, $mr!";
                }
            ],
            'hello arrow' => [fn($ms) => "Hello, $ms!"]
        ];
    }

    /**
     * @runInSeparateProcess
     * @preserveGlobalState disabled
     * @dataProvider provideAdditionTestParams
     */
    public function testUseClosureDataProviderTest($data)
    {
        self::assertSame('Hello, aaa!', $data('aaa'));
    }
}

Time: 00:00.213, Memory: 6.00 MB

OK (2 tests, 2 assertions)