StringTest.php 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. <?php
  2. /**
  3. *
  4. * @filesource StringTest.php
  5. * @created 08.02.2016
  6. * @package chillerlan\QRCodeTest\Output
  7. * @author Smiley <smiley@chillerlan.net>
  8. * @copyright 2015 Smiley
  9. * @license MIT
  10. */
  11. namespace chillerlan\QRCodeTest\Output;
  12. use chillerlan\QRCode\Output\QRString;
  13. use chillerlan\QRCode\Output\QRStringOptions;
  14. use chillerlan\QRCode\QRCode;
  15. class StringTest extends OutputTestAbstract{
  16. protected $outputInterfaceClass = QRString::class;
  17. protected $outputOptionsClass = QRStringOptions::class;
  18. public function testOptions(){
  19. $this->assertEquals(QRCode::OUTPUT_STRING_JSON, $this->options->type);
  20. }
  21. public function stringDataProvider(){
  22. return [
  23. [QRCode::OUTPUT_STRING_JSON, 'foobar', 'str1.json'],
  24. [QRCode::OUTPUT_STRING_JSON, 'otpauth://totp/test?secret=B3JX4VCVJDVNXNZ5&issuer=chillerlan.net', 'str2.json'],
  25. [QRCode::OUTPUT_STRING_TEXT, 'foobar', 'str1.txt'],
  26. [QRCode::OUTPUT_STRING_TEXT, 'otpauth://totp/test?secret=B3JX4VCVJDVNXNZ5&issuer=chillerlan.net', 'str2.txt'],
  27. // https://github.com/codemasher/php-qrcode/issues/4
  28. [QRCode::OUTPUT_STRING_TEXT, 'eyJjdCI6IjVPSExXNzZQZUg1NitEUUdtcFwvY2FBPT0iLCJpdiI6ImY0ZTI4MGMyYjc2NDExZmJjMmUzMjc5NzA0MTc3YmI4IiwicyI6ImZjZTZlMTY3YjNjMTQwMDUifQ%3D%3D', 'str3.txt'],
  29. ];
  30. }
  31. /**
  32. * @dataProvider stringDataProvider
  33. */
  34. public function testStringOutput($type, $data, $expected){
  35. $this->options->type = $type;
  36. $this->assertEquals(file_get_contents(__DIR__.'/string/'.$expected), (new QRCode($data, new $this->outputInterfaceClass($this->options)))->output());
  37. }
  38. }