OutputTestAbstract.php 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. <?php
  2. /**
  3. *
  4. * @filesource OutputTestAbstract.php
  5. * @created 17.12.2016
  6. * @package chillerlan\QRCodeTest\Output
  7. * @author Smiley <smiley@chillerlan.net>
  8. * @copyright 2016 Smiley
  9. * @license MIT
  10. */
  11. namespace chillerlan\QRCodeTest\Output;
  12. use PHPUnit\Framework\TestCase;
  13. /**
  14. * Class OutputTestAbstract
  15. */
  16. abstract class OutputTestAbstract extends TestCase{
  17. protected $outputInterfaceClass;
  18. protected $outputOptionsClass;
  19. protected $options;
  20. protected $outputInterface;
  21. protected function setUp(){
  22. $this->options = new $this->outputOptionsClass;
  23. $this->outputInterface = new $this->outputInterfaceClass($this->options);
  24. }
  25. public function testInstance(){
  26. $this->assertInstanceOf($this->outputInterfaceClass, $this->outputInterface);
  27. $this->assertInstanceOf($this->outputOptionsClass, $this->options);
  28. }
  29. /**
  30. * @expectedException \chillerlan\QRCode\Output\QRCodeOutputException
  31. * @expectedExceptionMessage Invalid output type!
  32. */
  33. public function testOutputTypeException(){
  34. $this->options->type = 'foo';
  35. new $this->outputInterfaceClass($this->options);
  36. }
  37. /**
  38. * @expectedException \chillerlan\QRCode\Output\QRCodeOutputException
  39. * @expectedExceptionMessage Invalid matrix!
  40. */
  41. public function testSetMatrixException(){
  42. /** @var \chillerlan\QRCode\Output\QROutputInterface $outputInterface */
  43. $outputInterface = new $this->outputInterfaceClass;
  44. $outputInterface->setMatrix([]);
  45. }
  46. }