Browse Source

small unit testing improvements, removing never accessed code

El RIDO 11 năm trước cách đây
mục cha
commit
134d22c958
3 tập tin đã thay đổi với 12 bổ sung16 xóa
  1. 1 1
      CHANGELOG.md
  2. 2 15
      lib/vizhash16x16.php
  3. 9 0
      tst/RainTPL.php

+ 1 - 1
CHANGELOG.md

@@ -49,6 +49,6 @@
     * ADDED: Deletion URL.
     * small refactoring.
     * improved regex checks.
-    * larger server alt on installation.    
+    * larger server alt on installation.
 
 

+ 2 - 15
lib/vizhash16x16.php

@@ -85,15 +85,6 @@ class vizhash16x16
         return $imagedata;
     }
 
-    // Generate a large random hexadecimal salt.
-    private function randomSalt()
-    {
-        $randomSalt='';
-        for($i=0;$i<6;$i++) { $randomSalt.=base_convert(mt_rand(),10,16); }
-        return $randomSalt;
-    }
-
-
     private function getInt() // Returns a single integer from the $VALUES array (0...255)
     {
         $v= $this->VALUES[$this->VALUES_INDEX];
@@ -101,6 +92,7 @@ class vizhash16x16
         $this->VALUES_INDEX %= count($this->VALUES); // Warp around the array
         return $v;
     }
+
     private function getX() // Returns a single integer from the array (roughly mapped to image width)
     {
         return $this->width*$this->getInt()/256;
@@ -148,14 +140,9 @@ class vizhash16x16
                 $points = array($this->getX(), $this->getY(), $this->getX(), $this->getY(), $this->getX(), $this->getY(),$this->getX(), $this->getY());
                 ImageFilledPolygon ($image, $points, 4, $color);
                 break;
-            case 4:
-            case 5:
-            case 6:
+            default:
                 $start=$this->getInt()*360/256; $end=$start+$this->getInt()*180/256;
                 ImageFilledArc ($image, $this->getX(), $this->getY(), $this->getX(), $this->getY(),$start,$end,$color,IMG_ARC_PIE);
-                break;
         }
     }
 }
-
-?>

+ 9 - 0
tst/RainTPL.php

@@ -91,4 +91,13 @@ class RainTPLTest extends PHPUnit_Framework_TestCase
             'outputs version correctly'
         );
     }
+
+    /**
+     * @expectedException RainTpl_Exception
+     */
+    public function testMissingTemplate()
+    {
+        $test = new RainTPL;
+        $test->draw('123456789 does not exist!');
+    }
 }