StringTest.php 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  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. ];
  28. }
  29. /**
  30. * @dataProvider stringDataProvider
  31. */
  32. public function testStringOutput($type, $data, $expected){
  33. $this->options->type = $type;
  34. $this->assertEquals(file_get_contents(__DIR__.'/string/'.$expected), (new QRCode($data, new $this->outputInterfaceClass($this->options)))->output());
  35. }
  36. }