codemasher 6 лет назад
Родитель
Сommit
709f62e557

+ 1 - 1
composer.json

@@ -24,7 +24,7 @@
 		"chillerlan/php-settings-container": "^1.0"
 	},
 	"require-dev": {
-		"phpunit/phpunit": "^7.5"
+		"phpunit/phpunit": "^8.0"
 	},
 	"autoload": {
 		"psr-4": {

+ 4 - 5
tests/Data/AlphaNumTest.php

@@ -12,7 +12,7 @@
 
 namespace chillerlan\QRCodeTest\Data;
 
-use chillerlan\QRCode\Data\AlphaNum;
+use chillerlan\QRCode\Data\{AlphaNum, QRCodeDataException};
 
 class AlphaNumTest extends DatainterfaceTestAbstract{
 
@@ -34,11 +34,10 @@ class AlphaNumTest extends DatainterfaceTestAbstract{
 		92, 112, 20, 198, 27
 	];
 
-	/**
-	 * @expectedException \chillerlan\QRCode\Data\QRCodeDataException
-	 * @expectedExceptionMessage illegal char: "#" [35]
-	 */
 	public function testGetCharCodeException(){
+		$this->expectException(QRCodeDataException::class);
+		$this->expectExceptionMessage('illegal char: "#" [35]');
+
 		$this->dataInterface->setData('#');
 	}
 

+ 6 - 6
tests/Data/DatainterfaceTestAbstract.php

@@ -12,7 +12,8 @@
 
 namespace chillerlan\QRCodeTest\Data;
 
-use chillerlan\QRCode\{QROptions, Data\QRDataInterface, Data\QRMatrix};
+use chillerlan\QRCode\QROptions;
+use chillerlan\QRCode\Data\{QRCodeDataException, QRDataInterface, QRMatrix};
 use chillerlan\QRCodeTest\QRTestAbstract;
 
 abstract class DatainterfaceTestAbstract extends QRTestAbstract{
@@ -25,7 +26,7 @@ abstract class DatainterfaceTestAbstract extends QRTestAbstract{
 	protected $testdata;
 	protected $expected;
 
-	protected function setUp(){
+	protected function setUp():void{
 		parent::setUp();
 
 		$this->dataInterface = $this->reflection->newInstanceArgs([new QROptions(['version' => 4])]);
@@ -53,11 +54,10 @@ abstract class DatainterfaceTestAbstract extends QRTestAbstract{
 		$this->assertSame(1, $this->getMethod('getMinimumVersion')->invoke($this->dataInterface));
 	}
 
-	/**
-	 * @expectedException \chillerlan\QRCode\Data\QRCodeDataException
-	 * @expectedExceptionMessage data exceeds
-	 */
 	public function testGetMinimumVersionException(){
+		$this->expectException(QRCodeDataException::class);
+		$this->expectExceptionMessage('data exceeds');
+
 		$this->getProperty('strlen')->setValue($this->dataInterface, 13370);
 		$this->getMethod('getMinimumVersion')->invoke($this->dataInterface);
 	}

+ 7 - 9
tests/Data/KanjiTest.php

@@ -12,7 +12,7 @@
 
 namespace chillerlan\QRCodeTest\Data;
 
-use chillerlan\QRCode\Data\Kanji;
+use chillerlan\QRCode\Data\{Kanji, QRCodeDataException};
 
 class KanjiTest extends DatainterfaceTestAbstract{
 
@@ -34,19 +34,17 @@ class KanjiTest extends DatainterfaceTestAbstract{
 		96, 113, 54, 191
 	];
 
-	/**
-	 * @expectedException \chillerlan\QRCode\Data\QRCodeDataException
-	 * @expectedExceptionMessage illegal char at 1 [16191]
-	 */
 	public function testIllegalCharException1(){
+		$this->expectException(QRCodeDataException::class);
+		$this->expectExceptionMessage('illegal char at 1 [16191]');
+
 		$this->dataInterface->setData('ÃÃ');
 	}
 
-	/**
-	 * @expectedException \chillerlan\QRCode\Data\QRCodeDataException
-	 * @expectedExceptionMessage illegal char at 1
-	 */
 	public function testIllegalCharException2(){
+		$this->expectException(QRCodeDataException::class);
+		$this->expectExceptionMessage('illegal char at 1');
+
 		$this->dataInterface->setData('Ã');
 	}
 }

+ 4 - 5
tests/Data/NumberTest.php

@@ -12,7 +12,7 @@
 
 namespace chillerlan\QRCodeTest\Data;
 
-use chillerlan\QRCode\Data\Number;
+use chillerlan\QRCode\Data\{Number, QRCodeDataException};
 
 class NumberTest extends DatainterfaceTestAbstract{
 
@@ -34,11 +34,10 @@ class NumberTest extends DatainterfaceTestAbstract{
 		89, 63, 168, 151
 	];
 
-	/**
-	 * @expectedException \chillerlan\QRCode\Data\QRCodeDataException
-	 * @expectedExceptionMessage illegal char: "#" [35]
-	 */
 	public function testGetCharCodeException(){
+		$this->expectException(QRCodeDataException::class);
+		$this->expectExceptionMessage('illegal char: "#" [35]');
+
 		$this->dataInterface->setData('#');
 	}
 

+ 12 - 14
tests/Data/QRMatrixTest.php

@@ -12,7 +12,8 @@
 
 namespace chillerlan\QRCodeTest\Data;
 
-use chillerlan\QRCode\{QRCode, Data\QRMatrix};
+use chillerlan\QRCode\QRCode;
+use chillerlan\QRCode\Data\{QRCodeDataException, QRMatrix};
 use chillerlan\QRCodeTest\QRTestAbstract;
 use ReflectionClass;
 
@@ -67,25 +68,23 @@ class QRMatrixTest extends QRTestAbstract{
 	 */
 	protected $matrix;
 
-	protected function setUp(){
+	protected function setUp():void{
 		parent::setUp();
 
 		$this->matrix = $this->reflection->newInstanceArgs([$this->version, QRCode::ECC_L]);
 	}
 
-	/**
-	 * @expectedException \chillerlan\QRCode\Data\QRCodeDataException
-	 * @expectedExceptionMessage invalid QR Code version
-	 */
 	public function testInvalidVersionException(){
+		$this->expectException(QRCodeDataException::class);
+		$this->expectExceptionMessage('invalid QR Code version');
+
 		$this->reflection->newInstanceArgs([42, 0]);
 	}
 
-	/**
-	 * @expectedException \chillerlan\QRCode\Data\QRCodeDataException
-	 * @expectedExceptionMessage invalid ecc level
-	 */
 	public function testInvalidEccException(){
+		$this->expectException(QRCodeDataException::class);
+		$this->expectExceptionMessage('invalid ecc level');
+
 		$this->reflection->newInstanceArgs([1, 42]);
 	}
 
@@ -234,11 +233,10 @@ class QRMatrixTest extends QRTestAbstract{
 		$this->assertSame(QRMatrix::M_TEST << 8, $this->matrix->get($size - 1 - $q, $size - 1 - $q));
 	}
 
-	/**
-	 * @expectedException \chillerlan\QRCode\Data\QRCodeDataException
-	 * @expectedExceptionMessage use only after writing data
-	 */
 	public function testSetQuietZoneException(){
+		$this->expectException(QRCodeDataException::class);
+		$this->expectExceptionMessage('use only after writing data');
+
 		$this->matrix->setQuietZone();
 	}
 

+ 1 - 1
tests/Helpers/BitBufferTest.php

@@ -22,7 +22,7 @@ class BitBufferTest extends QRTestAbstract{
 	 */
 	protected $bitBuffer;
 
-	protected function setUp(){
+	protected function setUp():void{
 		$this->bitBuffer = new BitBuffer;
 	}
 

+ 5 - 5
tests/Helpers/PolynomialTest.php

@@ -13,6 +13,7 @@
 namespace chillerlan\QRCodeTest\Helpers;
 
 use chillerlan\QRCode\Helpers\Polynomial;
+use chillerlan\QRCode\QRCodeException;
 use chillerlan\QRCodeTest\QRTestAbstract;
 
 class PolynomialTest extends QRTestAbstract{
@@ -22,7 +23,7 @@ class PolynomialTest extends QRTestAbstract{
 	 */
 	protected $polynomial;
 
-	protected function setUp(){
+	protected function setUp():void{
 		$this->polynomial = new Polynomial;
 	}
 
@@ -32,11 +33,10 @@ class PolynomialTest extends QRTestAbstract{
 		$this->assertSame(2,   $this->polynomial->gexp(256));
 	}
 
-	/**
-	 * @expectedException \chillerlan\QRCode\QRCodeException
-	 * @expectedExceptionMessage log(0)
-	 */
 	public function testGlogException(){
+		$this->expectException(QRCodeException::class);
+		$this->expectExceptionMessage('log(0)');
+
 		$this->polynomial->glog(0);
 	}
 }

+ 7 - 6
tests/Output/QROutputTestAbstract.php

@@ -12,7 +12,9 @@
 
 namespace chillerlan\QRCodeTest\Output;
 
-use chillerlan\QRCode\{QROptions, Data\Byte, Output\QROutputInterface};
+use chillerlan\QRCode\QROptions;
+use chillerlan\QRCode\Data\Byte;
+use chillerlan\QRCode\Output\{QRCodeOutputException, QROutputInterface};
 use chillerlan\QRCodeTest\QRTestAbstract;
 
 /**
@@ -36,7 +38,7 @@ abstract class QROutputTestAbstract extends QRTestAbstract{
 	 */
 	protected $matrix;
 
-	protected function setUp(){
+	protected function setUp():void{
 		parent::setUp();
 
 		$this->options         = new QROptions;
@@ -52,11 +54,10 @@ abstract class QROutputTestAbstract extends QRTestAbstract{
 		$this->assertInstanceOf(QROutputInterface::class, $this->outputInterface);
 	}
 
-	/**
-	 * @expectedException \chillerlan\QRCode\Output\QRCodeOutputException
-	 * @expectedExceptionMessage Could not write data to cache file: /foo
-	 */
 	public function testSaveException(){
+		$this->expectException(QRCodeOutputException::class);
+		$this->expectExceptionMessage('Could not write data to cache file: /foo');
+
 		$this->options->cachefile = '/foo';
 		$this->setOutputInterface();
 		$this->outputInterface->dump();

+ 11 - 12
tests/QRCodeTest.php

@@ -12,8 +12,9 @@
 
 namespace chillerlan\QRCodeTest;
 
-use chillerlan\QRCode\QROptions;
-use chillerlan\QRCode\QRCode;
+use chillerlan\QRCode\{QROptions, QRCode};
+use chillerlan\QRCode\Data\QRCodeDataException;
+use chillerlan\QRCode\Output\QRCodeOutputException;
 use chillerlan\QRCodeExamples\MyCustomOutput;
 
 class QRCodeTest extends QRTestAbstract{
@@ -25,7 +26,7 @@ class QRCodeTest extends QRTestAbstract{
 	 */
 	protected $qrcode;
 
-	protected function setUp(){
+	protected function setUp():void{
 		parent::setUp();
 
 		$this->qrcode = $this->reflection->newInstance();
@@ -67,22 +68,20 @@ class QRCodeTest extends QRTestAbstract{
 	public function testRenderImage($type, $expected){
 		$this->qrcode = $this->reflection->newInstanceArgs([new QROptions(['outputType' => $type])]);
 
-		$this->assertContains($expected, $this->qrcode->render('test'));
+		$this->assertStringContainsString($expected, $this->qrcode->render('test'));
 	}
 
-	/**
-	 * @expectedException \chillerlan\QRCode\Output\QRCodeOutputException
-	 * @expectedExceptionMessage invalid output type
-	 */
 	public function testInitDataInterfaceException(){
+		$this->expectException(QRCodeOutputException::class);
+		$this->expectExceptionMessage('invalid output type');
+
 		(new QRCode(new QROptions(['outputType' => 'foo'])))->render('test');
 	}
 
-	/**
-	 * @expectedException \chillerlan\QRCode\Data\QRCodeDataException
-	 * @expectedExceptionMessage QRCode::getMatrix() No data given.
-	 */
 	public function testGetMatrixException(){
+		$this->expectException(QRCodeDataException::class);
+		$this->expectExceptionMessage('QRCode::getMatrix() No data given.');
+
 		$this->qrcode->getMatrix('');
 	}
 

+ 7 - 9
tests/QROptionsTest.php

@@ -12,7 +12,7 @@
 
 namespace chillerlan\QRCodeTest;
 
-use chillerlan\QRCode\{QRCode,QROptions};
+use chillerlan\QRCode\{QRCode, QRCodeException, QROptions};
 use PHPUnit\Framework\TestCase;
 
 class QROptionsTest extends TestCase{
@@ -56,11 +56,10 @@ class QROptionsTest extends TestCase{
 		$this->assertSame(QRCode::MASK_PATTERN_AUTO, (new QROptions)->maskPattern); // QRCode::MASK_PATTERN_AUTO = -1, default
 	}
 
-	/**
-	 * @expectedException \chillerlan\QRCode\QRCodeException
-	 * @expectedExceptionMessage Invalid error correct level: 42
-	 */
 	public function testInvalidEccLevelException(){
+		$this->expectException(QRCodeException::class);
+		$this->expectExceptionMessage('Invalid error correct level: 42');
+
 		new QROptions(['eccLevel' => 42]);
 	}
 
@@ -72,11 +71,10 @@ class QROptionsTest extends TestCase{
 		$this->assertSame(255, $o->imageTransparencyBG[2]);
 	}
 
-	/**
-	 * @expectedException \chillerlan\QRCode\QRCodeException
-	 * @expectedExceptionMessage Invalid RGB value.
-	 */
 	public function testInvalidRGBValueException(){
+		$this->expectException(QRCodeException::class);
+		$this->expectExceptionMessage('Invalid RGB value.');
+
 		new QROptions(['imageTransparencyBG' => ['r', 'g', 'b']]);
 	}
 }

+ 1 - 1
tests/QRTestAbstract.php

@@ -27,7 +27,7 @@ abstract class QRTestAbstract extends TestCase{
 	 */
 	protected $FQCN;
 
-	protected function setUp(){
+	protected function setUp():void{
 		$this->reflection = new ReflectionClass($this->FQCN);
 	}