PHP code example of meyfa / phpunit-assert-gd

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

    

meyfa / phpunit-assert-gd example snippets



use AssertGD\GDAssertTrait;

class ExampleTest extends PHPUnit\Framework\TestCase
{
    // this trait adds the assert methods to your test case
    use GDAssertTrait;

    public function testSomething()
    {
        $this->assertSimilarGD('./tests/expected.png', './tests/actual.png');
    }
}

$this->assertSimilarGD('./tests/img.png', './tests/same.png');
$this->assertNotSimilarGD('./tests/img.png', './tests/other.png');

$this->assertSimilarGD('./tests/img.png', './tests/similar.png', '', 0.2);

$img = imagecreatetruecolor(10, 10);
$this->assertSimilarGD('./tests/empty-10x10.png', $img);
imagedestroy($img);

$this->assertThat(
    './tests/actual.png',
    $this->isSimilarGD('./tests/expected.png')
);

use AssertGD\DiffCalculator\ScaledRgbChannels;

public function testImage()
{
    $this->assertSimilarGD(
        'expected.png',
        'actual.png',
        '',
        0,
        new ScaledRgbChannels()
    );
}