PHP Classes
elePHPant
Icontem

File: unit_test.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Tufan Baris YILDIRIM  >  Image Processor (CSS)  >  unit_test.php  >  Download  
File: unit_test.php
Role: Unit test script
Content type: text/plain
Description: Unit Test Script.
Class: Image Processor (CSS)
Draw images defined with CSS like properties
Author: By
Last change:
Date: 3 years ago
Size: 1,932 bytes
 

Contents

Class file image Download
<?php
   
include 'D3Image.php';


   
//I used only "Equal" assertation so you can test without PHPUnit Framework.
   
if(!class_exists('PHPUnit_Framework_TestCase'))
    {
        class
PHPUnit_Framework_TestCase
       
{
            public function
assertEquals($a,$b)
            {
               
var_dump($a == $b);
                echo
"\r\n";
            }
        }
    }



    class
ColorFunctionsTest extends PHPUnit_Framework_TestCase
   
{

        public function
testColorByName()
        {
           
$d3img = new D3Image('width:100;height:100');
           
$this->assertEquals($d3img->ColorByName('red'), 'FF0000');


        }

        public function
testColorAndHex()
        {
           
$d3img = new D3Image('width:100;height:100');
           
$rgb = $d3img->Color('FF0000',true);

           
$this->assertEquals($rgb['r'],255);
           
$this->assertEquals($rgb['g'],0);
           
$this->assertEquals($rgb['b'],0);

           
//re-hex
           
$hex = $d3img->rgb2Hex($rgb);
           
$this->assertEquals($rgb['b'],'FF0000');
        }
    }



    class
parserFunctionsTest extends PHPUnit_Framework_TestCase
   
{
        public function
testCssParse()
        {
           
$d3img = new D3Image('width:100;height:100');
           
$info = $d3img->CssInfo("width:100;height:50");
        
           
$this->assertEquals($info['width'],100);
           
$this->assertEquals($info['height'],50);
           
$this->assertEquals($info['DTImage'],'Css'); //this element will be created automaticly.
           
$this->assertEquals(count($info),3);

        }
    }

    echo
"<pre>\r\n Can You see 'bool(false)' ?\r\n";
   
$colorTest = new ColorFunctionsTest();
   
$colorTest->testColorAndHex();
   
$colorTest->testColorByName();

   
$parserTest = new parserFunctionsTest();
   
$parserTest->testCssParse();
?>