Prechádzať zdrojové kódy

added code length overflow exception

smiley 10 rokov pred
rodič
commit
76a035cea6
1 zmenil súbory, kde vykonal 16 pridanie a 2 odobranie
  1. 16 2
      tests/QRCodeTest.php

+ 16 - 2
tests/QRCodeTest.php

@@ -71,10 +71,14 @@ class QRCodeTest extends \PHPUnit_Framework_TestCase{
 		}
 	}
 
-	public function testTypeAutoOverride(){
+	/**
+	 * @dataProvider stringDataProvider
+	 */
+	public function testTypeAutoOverride($data){
 		$this->options->typeNumber = QRCode::TYPE_05;
-		new QRCode('foobar', new QRString, $this->options);
+		new QRCode($data, new QRString, $this->options);
 	}
+
 	/**
 	 * @expectedException \chillerlan\QRCode\QRCodeException
 	 * @expectedExceptionMessage No data given.
@@ -92,4 +96,14 @@ class QRCodeTest extends \PHPUnit_Framework_TestCase{
 		new QRCode('foobar', new QRString, $this->options);
 	}
 
+	/**
+	 * @expectedException \chillerlan\QRCode\QRCodeException
+	 * @expectedExceptionMessage code length overflow. (261 > 72bit)
+	 */
+	public function testCodeLengthOverflowException(){
+		$this->options->typeNumber = QRCode::TYPE_01;
+		$this->options->errorCorrectLevel = QRCode::ERROR_CORRECT_LEVEL_H;
+		(new QRCode('ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890 $%*+-./:', new QRString, $this->options))->getRawData();
+	}
+
 }