Beispiel #1
0
 public function testBasicRenderCustomChar()
 {
     $content = 'foobar';
     $expected = "-----------------------\n" . "-#######-#####-#######-\n" . "-#-----#--#-#--#-----#-\n" . "-#-###-#--##---#-###-#-\n" . "-#-###-#--###--#-###-#-\n" . "-#-###-#---#-#-#-###-#-\n" . "-#-----#----##-#-----#-\n" . "-#######-#-#-#-#######-\n" . "---------#####---------\n" . "-##-##-#--##-#-#-----#-\n" . "----##----##-#-#-##----\n" . "--########-#--##-#--##-\n" . "-----------##------#-#-\n" . "--##--###--#---#--#--#-\n" . "---------#-###----#-#--\n" . "-#######--##-######----\n" . "-#-----#---####---##---\n" . "-#-###-#-##-##-##-#-##-\n" . "-#-###-#-##-##--#-##---\n" . "-#-###-#---#---#-##-##-\n" . "-#-----#-###--###-####-\n" . "-#######-####---##-----\n" . "-----------------------\n";
     $qrCode = Encoder::encode($content, new ErrorCorrectionLevel(ErrorCorrectionLevel::L), Encoder::DEFAULT_BYTE_MODE_ECODING);
     $this->renderer->setFullBlock('#');
     $this->renderer->setEmptyBlock('-');
     $this->assertEquals('#', $this->renderer->getFullBlock());
     $this->assertEquals('-', $this->renderer->getEmptyBlock());
     $this->assertEquals($expected, $this->renderer->render($qrCode));
 }
Beispiel #2
0
 /**
  * render(): defined by RendererInterface.
  *
  * @see    RendererInterface::render()
  * @param  QrCode $qrCode
  * @return string
  */
 public function render(QrCode $qrCode)
 {
     $textCode = parent::render($qrCode);
     $result = '<pre' . ' style="' . htmlspecialchars($this->style, ENT_QUOTES, 'utf-8') . '"' . ' class="' . htmlspecialchars($this->class, ENT_QUOTES, 'utf-8') . '"' . '>' . $textCode . '</pre>';
     return $result;
 }