QROutputTestAbstract.php 1.5 KB

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