PHP Classes
elePHPant
Icontem

File: test/heavy/FlatDragonTest.php

Recommend this page to a friend!
  Classes of Patrick Van Bergen  >  Move Me GIF  >  test/heavy/FlatDragonTest.php  >  Download  
File: test/heavy/FlatDragonTest.php
Role: Unit test script
Content type: text/plain
Description: Unit test script
Class: Move Me GIF
Create animated GIF images in pure PHP
Author: By
Last change: Use imagegif to create compressed pixel data if possible, which is much faster.
Date: 2 years ago
Size: 1,319 bytes
 

Contents

Class file image Download
<?php

use movemegif\domain\GdCanvas;

require_once
__DIR__ . '/../../php/autoloader.php';

/**
 * @author Patrick van Bergen
 */
class FlatDragonTest extends PHPUnit_Framework_TestCase
{
    public function
testLargeImage()
    {
       
$builder = new \movemegif\GifBuilder(200, 100);

       
$canvas = new GdCanvas(200, 100);

       
$imagePath = __DIR__ . '/../resources/flat-dragon.gif';
       
$source = imagecreatefromgif($imagePath);
       
imagecopy($canvas->getResource(), $source, 0, 0, 0, 0, 200, 100);

       
$builder->addFrame()->setDuration(50)->setCanvas($canvas)->setUseGlobalColorTable();

       
$contents = $builder->getContents();

       
$this->assertSame($contents, file_get_contents($imagePath));
    }

    public function
testLargeImageUsingAccelleratedPixelDataProducer()
    {
       
$builder = new \movemegif\GifBuilder(200, 100);

       
$canvas = new GdCanvas(200, 100);

       
$imagePath = __DIR__ . '/../resources/local-dragon.gif';
       
$source = imagecreatefromgif($imagePath);
       
imagecopy($canvas->getResource(), $source, 0, 0, 0, 0, 200, 100);

       
$builder->addFrame()->setDuration(50)->setCanvas($canvas)->setUseLocalColorTable();

       
$contents = $builder->getContents();

       
$this->assertSame($contents, file_get_contents($imagePath));
    }

}