Просмотр исходного кода

fixed invalid output type exception

smiley 10 лет назад
Родитель
Сommit
3484cfd269
2 измененных файлов с 5 добавлено и 1 удалено
  1. 1 1
      src/Output/QRString.php
  2. 4 0
      tests/Output/StringTest.php

+ 1 - 1
src/Output/QRString.php

@@ -34,7 +34,7 @@ class QRString extends QROutputBase implements QROutputInterface{
 			$this->options = new QRStringOptions;
 		}
 
-		if(!in_array($this->options->type ,[QRCode::OUTPUT_STRING_TEXT, QRCode::OUTPUT_STRING_JSON, QRCode::OUTPUT_STRING_HTML])){
+		if(!in_array($this->options->type, [QRCode::OUTPUT_STRING_TEXT, QRCode::OUTPUT_STRING_JSON, QRCode::OUTPUT_STRING_HTML], true)){
 			throw new QRCodeOutputException('Invalid string output type!');
 		}
 

+ 4 - 0
tests/Output/StringTest.php

@@ -49,6 +49,10 @@ class StringTest extends \PHPUnit_Framework_TestCase{
 		$this->assertEquals($expected, (new QRCode($data, new QRString($this->options)))->output());
 	}
 
+	/**
+	 * @expectedException \chillerlan\QRCode\Output\QRCodeOutputException
+	 * @expectedExceptionMessage Invalid string output type!
+	 */
 	public function testOutputTypeException(){
 		$this->options->type = 'foo';
 		new QRString($this->options);