AuresCustomerDisplayTest.php 2.4KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. <?php
  2. use Mike42\Escpos\Devices\AuresCustomerDisplay;
  3. use Mike42\Escpos\PrintConnectors\DummyPrintConnector;
  4. use Mike42\Escpos\CapabilityProfile;
  5. class AuresCustomerDisplayTest extends PHPUnit\Framework\TestCase
  6. {
  7. protected $printer;
  8. protected $outputConnector;
  9. protected function setup()
  10. {
  11. /* Print to nowhere- for testing which inputs are accepted */
  12. $this -> outputConnector = new DummyPrintConnector();
  13. $profile = CapabilityProfile::load('OCD-300');
  14. $this -> printer = new AuresCustomerDisplay($this -> outputConnector, $profile);
  15. }
  16. protected function checkOutput($expected = null)
  17. {
  18. /* Check those output strings */
  19. $outp = $this -> outputConnector -> getData();
  20. if ($expected === null) {
  21. echo "\nOutput was:\n\"" . friendlyBinary($outp) . "\"\n";
  22. }
  23. $this -> assertEquals($expected, $outp);
  24. }
  25. protected function tearDown()
  26. {
  27. $this -> outputConnector -> finalize();
  28. }
  29. public function testInitializeOutput()
  30. {
  31. $this -> checkOutput("\x02\x05C1\x03\x1b@\x1bt\x00\x1f\x02");
  32. }
  33. public function testselectTextScrollMode() {
  34. $this -> outputConnector -> clear();
  35. $this -> printer -> selectTextScrollMode(AuresCustomerDisplay::TEXT_OVERWRITE);
  36. $this -> checkOutput("\x1f\x01");
  37. }
  38. public function testClear() {
  39. $this -> outputConnector -> clear();
  40. $this -> printer -> clear();
  41. $this -> checkOutput("\x0c");
  42. }
  43. public function testShowFirmwareVersion() {
  44. $this -> outputConnector -> clear();
  45. $this -> printer -> showFirmwareVersion();
  46. $this -> checkOutput("\x02\x05V\x01\x03");
  47. }
  48. public function testSelfTest() {
  49. $this -> outputConnector -> clear();
  50. $this -> printer -> selfTest();
  51. $this -> checkOutput("\x02\x05D\x08\x03");
  52. }
  53. public function testShowLogo() {
  54. $this -> outputConnector -> clear();
  55. $this -> printer -> showLogo();
  56. $this -> checkOutput("\x02\xfcU\xaaU\xaa");
  57. }
  58. public function testTest() {
  59. $this -> outputConnector -> clear();
  60. // Handling of line-endings differs to regular printers, need to use \r\n
  61. $this -> printer -> text("Hello\nWorld\n");
  62. $this -> checkOutput("Hello\x0d\x0aWorld\x0d\x0a");
  63. }
  64. }