renderer = new Html(); $this->writer = new Writer($this->renderer); } public function testBasicRender() { $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->assertEquals($expected, $this->renderer->render($qrCode)); } public function testSetStyle() { $content = 'foobar'; $qrCode = Encoder::encode( $content, new ErrorCorrectionLevel(ErrorCorrectionLevel::L), Encoder::DEFAULT_BYTE_MODE_ECODING ); $this->renderer->setStyle('bar'); $this->assertEquals('bar', $this->renderer->getStyle()); $this->assertStringMatchesFormat('%astyle="bar"%a', $this->renderer->render($qrCode)); } public function testSetClass() { $content = 'foobar'; $qrCode = Encoder::encode( $content, new ErrorCorrectionLevel(ErrorCorrectionLevel::L), Encoder::DEFAULT_BYTE_MODE_ECODING ); $this->renderer->setClass('bar'); $this->assertEquals('bar', $this->renderer->getClass()); $this->assertStringMatchesFormat('%aclass="bar"%a', $this->renderer->render($qrCode)); } }