QRMarkupTest.php 1.4 KB

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