From 3c8af1916d937d8ea1a5e79ea84a2363aed522a7 Mon Sep 17 00:00:00 2001 From: codemasher Date: Sat, 10 Nov 2018 19:29:12 +0100 Subject: [PATCH] :octocat: test GD RGB clamp --- tests/QROptionsTest.php | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/tests/QROptionsTest.php b/tests/QROptionsTest.php index a56a85183..12581f65e 100644 --- a/tests/QROptionsTest.php +++ b/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']]); + } }