QROutputTestAbstract.php 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  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\Data\Byte;
  14. use chillerlan\QRCode\Output\QROutputInterface;
  15. use chillerlan\QRCode\QROptions;
  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(){
  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. /**
  46. * @expectedException \chillerlan\QRCode\Output\QRCodeOutputException
  47. * @expectedExceptionMessage Could not write data to cache file: /foo
  48. */
  49. public function testSaveException(){
  50. $this->options->cachefile = '/foo';
  51. $this->setOutputInterface();
  52. $this->outputInterface->dump();
  53. }
  54. }