QROutputTestAbstract.php 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  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;
  15. use chillerlan\QRCode\Output\{QRCodeOutputException, QROutputInterface};
  16. use chillerlan\QRCodeTest\QRTestAbstract;
  17. /**
  18. */
  19. abstract class QROutputTestAbstract extends QRTestAbstract{
  20. const cachefile = __DIR__.'/output_test.';
  21. /**
  22. * @var \chillerlan\QRCode\Output\QROutputInterface
  23. */
  24. protected $outputInterface;
  25. /**
  26. * @var \chillerlan\QRCode\QROptions
  27. */
  28. protected $options;
  29. /**
  30. * @var \chillerlan\QRCode\Data\QRMatrix
  31. */
  32. protected $matrix;
  33. protected function setUp():void{
  34. parent::setUp();
  35. $this->options = new QROptions;
  36. $this->setOutputInterface();
  37. }
  38. protected function setOutputInterface(){
  39. $this->outputInterface = $this->reflection->newInstanceArgs([$this->options, (new Byte($this->options, 'testdata'))->initMatrix(0)]);
  40. return $this->outputInterface;
  41. }
  42. public function testInstance(){
  43. $this->assertInstanceOf(QROutputInterface::class, $this->outputInterface);
  44. }
  45. public function testSaveException(){
  46. $this->expectException(QRCodeOutputException::class);
  47. $this->expectExceptionMessage('Could not write data to cache file: /foo');
  48. $this->options->cachefile = '/foo';
  49. $this->setOutputInterface();
  50. $this->outputInterface->dump();
  51. }
  52. }