MarkupTest.php 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. <?php
  2. /**
  3. *
  4. * @filesource MarkupTest.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 chillerlan\QRCode\Output\QRMarkup;
  13. use chillerlan\QRCode\Output\QRMarkupOptions;
  14. use chillerlan\QRCode\QRCode;
  15. /**
  16. * Class MarkupTest
  17. */
  18. class MarkupTest extends OutputTestAbstract{
  19. protected $outputInterfaceClass = QRMarkup::class;
  20. protected $outputOptionsClass = QRMarkupOptions::class;
  21. public function testOptions(){
  22. $this->assertEquals(QRCode::OUTPUT_MARKUP_SVG, $this->options->type);
  23. }
  24. public function markupDataProvider(){
  25. return [
  26. [QRCode::OUTPUT_MARKUP_HTML, true, 'foobar', 'str1.html'],
  27. [QRCode::OUTPUT_MARKUP_HTML, false, 'foobar', 'str2.html'],
  28. [QRCode::OUTPUT_MARKUP_HTML, true, 'otpauth://totp/test?secret=B3JX4VCVJDVNXNZ5&issuer=chillerlan.net', 'str3.html'],
  29. [QRCode::OUTPUT_MARKUP_HTML, false, 'otpauth://totp/test?secret=B3JX4VCVJDVNXNZ5&issuer=chillerlan.net', 'str4.html'],
  30. [QRCode::OUTPUT_MARKUP_SVG , null, 'foobar', 'str1.svg'],
  31. [QRCode::OUTPUT_MARKUP_SVG , null, 'otpauth://totp/test?secret=B3JX4VCVJDVNXNZ5&issuer=chillerlan.net', 'str2.svg'],
  32. ];
  33. }
  34. /**
  35. * @dataProvider markupDataProvider
  36. */
  37. public function testMarkupOutput($type, $omitEndTag, $data, $expected){
  38. $this->options->type = $type;
  39. $this->options->htmlOmitEndTag = $omitEndTag;
  40. $this->options->cssClass = 'test';
  41. $this->assertEquals(file_get_contents(__DIR__.'/markup/'.$expected), (new QRCode($data, new $this->outputInterfaceClass($this->options)))->output());
  42. }
  43. }