Advertisement
Guest User

Untitled

a guest
Oct 30th, 2014
24
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.83 KB | None | 0 0
  1. <?php
  2.  
  3. namespace Tests\Etron\GFX;
  4.  
  5. use Etron\GFX\_I_Color;
  6. use Etron\GFX\Color;
  7. use PHPUnit_Framework_TestCase;
  8.  
  9. abstract class _I_ColorTest extends PHPUnit_Framework_TestCase
  10. {
  11.     /**
  12.      * @return _I_Color
  13.      */
  14.     abstract function getEmptyObj();
  15.  
  16.     /**
  17.      * @covers _I_Color::adjustBrightness()
  18.      */
  19.     function testAdjustBrightnessPositive()
  20.     {
  21.         $obj = $this->getEmptyObj()->setRGB(0, 0, 0);
  22.  
  23.         $modObj = $obj->adjustBrightness(100);
  24.        
  25.         $this->assertInstanceOf(_I_Color::class, $modObj);
  26.  
  27.         $this->assertEquals([100, 100, 100], $modObj->getRGB());
  28.     }
  29.  
  30.     /**
  31.      * @covers _I_Color::adjustBrightness()
  32.      */
  33.     function testAdjustBrightnessNegative()
  34.     {
  35.         $obj = $this->getEmptyObj()->setRGB(200, 200, 200);
  36.  
  37.         $modObj = $obj->adjustBrightness(-100);
  38.        
  39.         $this->assertInstanceOf(_I_Color::class, $modObj);
  40.  
  41.         $this->assertEquals([100, 100, 100], $modObj->getRGB());
  42.     }
  43.    
  44.     /**
  45.      * @covers _I_Color::adjustBrightness()
  46.      */
  47.     function testAdjustBrightnessUpperBoundary()
  48.     {
  49.         $obj = $this->getEmptyObj()->setRGB(0, 0, 0);
  50.  
  51.         $modObj = $obj->adjustBrightness(300);
  52.        
  53.         $this->assertInstanceOf(_I_Color::class, $modObj);
  54.  
  55.         $this->assertEquals([255, 255, 255], $modObj->getRGB());
  56.     }
  57.  
  58.     /**
  59.      * @covers _I_Color::adjustBrightness()
  60.      */
  61.     function testAdjustBrightnessLowerBoundary()
  62.     {
  63.         $obj = $this->getEmptyObj()->setRGB(100, 100, 100);
  64.  
  65.         $modObj = $obj->adjustBrightness(-300);
  66.        
  67.         $this->assertInstanceOf(_I_Color::class, $modObj);
  68.  
  69.         $this->assertEquals([0, 0, 0], $modObj->getRGB());
  70.     }
  71.  
  72. }
  73.  
  74. class ColorTest extends _I_ColorTest
  75. {
  76.     function getEmptyObj()
  77.     {
  78.         return new Color;
  79.     }
  80. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement