QROutputTestAbstract.php 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. <?php
  2. /**
  3. * Class QROutputTestAbstract
  4. *
  5. * @filesource QROutputTestAbstract.php
  6. * @created 24.12.2017
  7. * @package chillerlan\QRCodeTest\Output
  8. * @author Smiley <smiley@chillerlan.net>
  9. * @copyright 2017 Smiley
  10. * @license MIT
  11. */
  12. namespace chillerlan\QRCodeTest\Output;
  13. use chillerlan\QRCode\QROptions;
  14. use chillerlan\QRCode\Data\{Byte, QRMatrix};
  15. use chillerlan\QRCode\Output\{QRCodeOutputException, QROutputInterface};
  16. use chillerlan\QRCodeTest\QRTestAbstract;
  17. use chillerlan\Settings\SettingsContainerInterface;
  18. /**
  19. */
  20. abstract class QROutputTestAbstract extends QRTestAbstract{
  21. protected const cachefile = __DIR__.'/output_test.';
  22. protected QROutputInterface $outputInterface;
  23. /** @var \chillerlan\Settings\SettingsContainerInterface|\chillerlan\QRCode\QROptions */
  24. protected SettingsContainerInterface $options;
  25. protected QRMatrix $matrix;
  26. protected function setUp():void{
  27. parent::setUp();
  28. $this->options = new QROptions;
  29. $this->setOutputInterface();
  30. }
  31. protected function setOutputInterface(){
  32. $this->outputInterface = $this->reflection->newInstanceArgs([$this->options, (new Byte($this->options, 'testdata'))->initMatrix(0)]);
  33. return $this->outputInterface;
  34. }
  35. public function testInstance(){
  36. $this->assertInstanceOf(QROutputInterface::class, $this->outputInterface);
  37. }
  38. public function testSaveException(){
  39. $this->expectException(QRCodeOutputException::class);
  40. $this->expectExceptionMessage('Could not write data to cache file: /foo');
  41. $this->options->cachefile = '/foo';
  42. $this->setOutputInterface();
  43. $this->outputInterface->dump();
  44. }
  45. }