QRMarkupTest.php 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. <?php
  2. /**
  3. * Class QRMarkupTest
  4. *
  5. * @filesource QRMarkupTest.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\Output\QRMarkup;
  14. use chillerlan\QRCode\QRCode;
  15. class QRMarkupTest extends QROutputTestAbstract{
  16. protected $FQCN = QRMarkup::class;
  17. public function types(){
  18. return [
  19. [QRCode::OUTPUT_MARKUP_HTML],
  20. [QRCode::OUTPUT_MARKUP_SVG],
  21. ];
  22. }
  23. /**
  24. * @dataProvider types
  25. * @param $type
  26. */
  27. public function testMarkupOutputFile($type){
  28. $this->options->outputType = $type;
  29. $this->options->cachefile = $this::cachefile.$type;
  30. $this->setOutputInterface();
  31. $data = $this->outputInterface->dump();
  32. $this->assertSame($data, file_get_contents($this->options->cachefile));
  33. }
  34. /**
  35. * @dataProvider types
  36. * @param $type
  37. */
  38. public function testMarkupOutput($type){
  39. $this->options->outputType = $type;
  40. $this->setOutputInterface();
  41. $expected = explode($this->options->eol, file_get_contents($this::cachefile.$type));
  42. // cut off the doctype & head
  43. array_shift($expected);
  44. if($type === QRCode::OUTPUT_MARKUP_HTML){
  45. // cut off the </body> tag
  46. array_pop($expected);
  47. }
  48. $expected = implode($this->options->eol, $expected);
  49. $this->assertSame(trim($expected), trim($this->outputInterface->dump()));
  50. }
  51. }