Procházet zdrojové kódy

added code length overflow exception

smiley před 10 roky
rodič
revize
76a035cea6
1 změnil soubory, kde provedl 16 přidání a 2 odebrání
  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;
 		$this->options->typeNumber = QRCode::TYPE_05;
-		new QRCode('foobar', new QRString, $this->options);
+		new QRCode($data, new QRString, $this->options);
 	}
 	}
+
 	/**
 	/**
 	 * @expectedException \chillerlan\QRCode\QRCodeException
 	 * @expectedException \chillerlan\QRCode\QRCodeException
 	 * @expectedExceptionMessage No data given.
 	 * @expectedExceptionMessage No data given.
@@ -92,4 +96,14 @@ class QRCodeTest extends \PHPUnit_Framework_TestCase{
 		new QRCode('foobar', new QRString, $this->options);
 		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();
+	}
+
 }
 }