DatainterfaceTestAbstract.php 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. <?php
  2. /**
  3. * Class DatainterfaceTestAbstract
  4. *
  5. * @filesource DatainterfaceTestAbstract.php
  6. * @created 24.11.2017
  7. * @package chillerlan\QRCodeTest\Data
  8. * @author Smiley <smiley@chillerlan.net>
  9. * @copyright 2017 Smiley
  10. * @license MIT
  11. */
  12. namespace chillerlan\QRCodeTest\Data;
  13. use chillerlan\QRCode\{QROptions, Data\QRDataInterface, Data\QRMatrix};
  14. use chillerlan\QRCodeTest\QRTestAbstract;
  15. abstract class DatainterfaceTestAbstract extends QRTestAbstract{
  16. /**
  17. * @var \chillerlan\QRCode\Data\QRDataAbstract
  18. */
  19. protected $dataInterface;
  20. protected $testdata;
  21. protected $expected;
  22. protected function setUp(){
  23. parent::setUp();
  24. $this->dataInterface = $this->reflection->newInstanceArgs([new QROptions(['version' => 4])]);
  25. }
  26. public function testInstance(){
  27. $this->dataInterface = $this->reflection->newInstanceArgs([new QROptions, $this->testdata]);
  28. $this->assertInstanceOf(QRDataInterface::class, $this->dataInterface);
  29. }
  30. public function testSetData(){
  31. $this->dataInterface->setData($this->testdata);
  32. $this->assertSame($this->expected, $this->getProperty('matrixdata')->getValue($this->dataInterface));
  33. }
  34. public function testInitMatrix(){
  35. $m = $this->dataInterface->setData($this->testdata)->initMatrix(0);
  36. $this->assertInstanceOf(QRMatrix::class, $m);
  37. }
  38. public function testGetMinimumVersion(){
  39. $this->assertSame(1, $this->getMethod('getMinimumVersion')->invoke($this->dataInterface));
  40. }
  41. /**
  42. * @expectedException \chillerlan\QRCode\Data\QRCodeDataException
  43. * @expectedExceptionMessage data exceeds
  44. */
  45. public function testGetMinimumVersionException(){
  46. $this->getProperty('strlen')->setValue($this->dataInterface, 13370);
  47. $this->getMethod('getMinimumVersion')->invoke($this->dataInterface);
  48. }
  49. }