Ver Fonte

:octocat: test GD RGB clamp

codemasher há 7 anos atrás
pai
commit
3c8af1916d
1 ficheiros alterados com 16 adições e 0 exclusões
  1. 16 0
      tests/QROptionsTest.php

+ 16 - 0
tests/QROptionsTest.php

@@ -67,4 +67,20 @@ class QROptionsTest extends TestCase{
 	public function testInvalidEccLevelException(){
 		new QROptions(['eccLevel' => 42]);
 	}
+
+	public function testClampRGBValues(){
+		$o = new QROptions(['imageTransparencyBG' => [-1, 0, 999]]);
+
+		$this->assertSame(0, $o->imageTransparencyBG[0]);
+		$this->assertSame(0, $o->imageTransparencyBG[1]);
+		$this->assertSame(255, $o->imageTransparencyBG[2]);
+	}
+
+	/**
+	 * @expectedException \chillerlan\QRCode\QRCodeException
+	 * @expectedExceptionMessage Invalid RGB value.
+	 */
+	public function testInvalidRGBValueException(){
+		new QROptions(['imageTransparencyBG' => ['r', 'g', 'b']]);
+	}
 }