16 |
17 |
= __('QR Codes') ?>
18 |
19 |
By default, we render a simple SVG image that can be scaled up/down easily.
20 |
21 |
22 | Result';
25 | echo $this->QrCode->image($result, $options);
26 | }
27 | ?>
28 |
29 |
30 |
Generate QR Code
31 |
32 | Form->create();?>
33 |
Enter some text (URL, ...)
34 |
35 | Form->control('content', ['autocomplete' => 'off', 'type' => 'textarea']);
37 | ?>
38 |
39 | Form->button(__('Go'), ['class' => 'btn btn-success']);?>
40 |
41 | Form->end(); ?>
42 |
43 |
44 |
45 |
--------------------------------------------------------------------------------
/templates/QrCode/image.php:
--------------------------------------------------------------------------------
1 | QrCode->raw($result, $options);
9 |
--------------------------------------------------------------------------------
/tests/TestCase/Controller/Admin/QrCodeControllerTest.php:
--------------------------------------------------------------------------------
1 | session([
23 | 'Auth' => [
24 | 'User' => [
25 | 'id' => 1,
26 | ],
27 | ],
28 | ]);
29 |
30 | $this->get(['prefix' => 'Admin', 'plugin' => 'QrCode', 'controller' => 'QrCode', 'action' => 'index']);
31 |
32 | $this->assertResponseOk();
33 | }
34 |
35 | /**
36 | * @uses \QrCode\Controller\Admin\QrCodeController::image()
37 | *
38 | * @return void
39 | */
40 | public function testImage(): void {
41 | $this->disableErrorHandlerMiddleware();
42 |
43 | $this->session([
44 | 'Auth' => [
45 | 'User' => [
46 | 'id' => 1,
47 | ],
48 | ],
49 | ]);
50 |
51 | $this->get(['prefix' => 'Admin', 'plugin' => 'QrCode', 'controller' => 'QrCode', 'action' => 'image', '_ext' => 'svg', '?' => ['content' => 'Foo Bar']]);
52 |
53 | $this->assertResponseOk();
54 | }
55 |
56 | }
57 |
--------------------------------------------------------------------------------
/tests/TestCase/Controller/QrCodeControllerTest.php:
--------------------------------------------------------------------------------
1 | disableErrorHandlerMiddleware();
25 |
26 | $this->session([
27 | 'Auth' => [
28 | 'User' => [
29 | 'id' => 1,
30 | ],
31 | ],
32 | ]);
33 |
34 | $this->get(['plugin' => 'QrCode', 'controller' => 'QrCode', 'action' => 'image', '_ext' => 'svg', '?' => ['content' => 'Foo Bar']]);
35 |
36 | $this->assertResponseOk();
37 | }
38 |
39 | }
40 |
--------------------------------------------------------------------------------
/tests/TestCase/Utility/FormatterTest.php:
--------------------------------------------------------------------------------
1 | formatter = new Formatter($view);
24 |
25 | $this->loadRoutes();
26 | }
27 |
28 | /**
29 | * @return void
30 | */
31 | protected function tearDown(): void {
32 | unset($this->formatter);
33 |
34 | parent::tearDown();
35 | }
36 |
37 | /**
38 | * @uses \QrCode\View\Helper\QrCodeHelper::image()
39 | *
40 | * @return void
41 | */
42 | public function testWifi(): void {
43 | $network = 'FooBar';
44 | $result = $this->formatter->formatWifi($network, 'pwd');
45 | $this->assertSame('WIFI:T:WPA;S:FooBar;P:pwd;;', $result);
46 | }
47 |
48 | }
49 |
--------------------------------------------------------------------------------
/tests/TestCase/View/Helper/QrCodeHelperTest.php:
--------------------------------------------------------------------------------
1 | QrCode = new QrCodeHelper($view);
25 |
26 | $this->loadRoutes();
27 | }
28 |
29 | /**
30 | * @return void
31 | */
32 | protected function tearDown(): void {
33 | unset($this->QrCode);
34 |
35 | parent::tearDown();
36 | }
37 |
38 | /**
39 | * @uses \QrCode\View\Helper\QrCodeHelper::image()
40 | *
41 | * @return void
42 | */
43 | public function testImage(): void {
44 | $content = 'Foo Bar';
45 | $image = $this->QrCode->image($content);
46 | $this->assertNotEmpty($image);
47 | $this->assertStringStartsWith('