:octocat: rework output interface invocation

This commit is contained in:
smiley
2023-03-02 23:04:23 +01:00
parent ca56fe5ca9
commit c474cc704e
2 changed files with 37 additions and 20 deletions
+29 -4
View File
@@ -11,16 +11,16 @@
namespace chillerlan\QRCodeTest;
use chillerlan\QRCode\{QROptions, QRCode};
use chillerlan\QRCode\Data\QRCodeDataException;
use chillerlan\QRCode\Output\QRCodeOutputException;
use chillerlan\QRCode\Output\{QRCodeOutputException, QROutputInterface};
use PHPUnit\Framework\TestCase;
use stdClass;
/**
* Tests basic functions of the QRCode class
*/
final class QRCodeTest extends TestCase{
private QRCode $qrcode;
private QRCode $qrcode;
private QROptions $options;
/**
@@ -36,11 +36,36 @@ final class QRCodeTest extends TestCase{
*/
public function testInitOutputInterfaceException():void{
$this->expectException(QRCodeOutputException::class);
$this->expectExceptionMessage('invalid output type');
$this->expectExceptionMessage('invalid output module');
$this->options->outputType = 'foo';
(new QRCode($this->options))->render('test');
}
/**
* tests if an exception is thrown if the given output class does not exist
*/
public function testInitCustomOutputInterfaceNotExistsException():void{
$this->expectException(QRCodeOutputException::class);
$this->expectExceptionMessage('invalid output module');
$this->options->outputType = QROutputInterface::CUSTOM;
(new QRCode($this->options))->render('test');
}
/**
* tests if an exception is thrown if the given output class does not implement QROutputInterface
*/
public function testInitCustomOutputInterfaceNotImplementsException():void{
$this->expectException(QRCodeOutputException::class);
$this->expectExceptionMessage('output module does not implement QROutputInterface');
$this->options->outputType = QROutputInterface::CUSTOM;
$this->options->outputInterface = stdClass::class;
(new QRCode($this->options))->render('test');
}
}