PHP Classes

File: tests/eMapper/TypeHandlerTest.php

Recommend this page to a friend!
  Classes of Emmanuel Antico   eMapper   tests/eMapper/TypeHandlerTest.php   Download  
File: tests/eMapper/TypeHandlerTest.php
Role: Unit test script
Content type: text/plain
Description: Unit test script
Class: eMapper
Database abstraction layer that maps data types
Author: By
Last change:
Date: 10 years ago
Size: 1,409 bytes
 

Contents

Class file image Download
<?php
namespace eMapper;

use
Acme\Type\RGBColorTypeHandler;
use
Acme\RGBColor;

/**
 * Tests a custom type handler class
 *
 * @author emaphp
 * @group typehandler
 */
class TypeHandlerTest extends \PHPUnit_Framework_TestCase {
    public function
testSetParameter() {
       
$th = new RGBColorTypeHandler();
       
       
$color = new RGBColor(255, 0, 0);
       
$parameter = $th->setParameter($color);
       
$this->assertEquals('ff0000', $parameter);
       
       
$color = new RGBColor(0, 255, 0);
       
$parameter = $th->setParameter($color);
       
$this->assertEquals('00ff00', $parameter);
       
       
$color = new RGBColor(0, 0, 255);
       
$parameter = $th->setParameter($color);
       
$this->assertEquals('0000ff', $parameter);
    }
   
    public function
testGetValue() {
       
$th = new RGBColorTypeHandler();
       
       
$color = $th->getValue('FF0065');
       
$this->assertInstanceOf('Acme\\RGBColor', $color);
       
$this->assertEquals(255, $color->red);
       
$this->assertEquals(0, $color->green);
       
$this->assertEquals(101, $color->blue);
       
       
$color = $th->getValue('baFF00');
       
$this->assertInstanceOf('Acme\\RGBColor', $color);
       
$this->assertEquals(186, $color->red);
       
$this->assertEquals(255, $color->green);
       
$this->assertEquals(0, $color->blue);
       
       
$color = $th->getValue('0060FF');
       
$this->assertInstanceOf('Acme\\RGBColor', $color);
       
$this->assertEquals(0, $color->red);
       
$this->assertEquals(96, $color->green);
       
$this->assertEquals(255, $color->blue);
    }
}
?>