添加网站文件
This commit is contained in:
45
vendor/endroid/qr-code/tests/Bundle/Controller/QrCodeControllerTest.php
vendored
Normal file
45
vendor/endroid/qr-code/tests/Bundle/Controller/QrCodeControllerTest.php
vendored
Normal file
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* (c) Jeroen van den Enden <info@endroid.nl>
|
||||
*
|
||||
* This source file is subject to the MIT license that is bundled
|
||||
* with this source code in the file LICENSE.
|
||||
*/
|
||||
|
||||
namespace Endroid\QrCode\Tests\Bundle\Controller;
|
||||
|
||||
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
|
||||
class QrCodeControllerTest extends WebTestCase
|
||||
{
|
||||
public function testGenerateAction()
|
||||
{
|
||||
$client = static::createClient();
|
||||
$client->request('GET', $client->getContainer()->get('router')->generate('endroid_qrcode_generate', [
|
||||
'text' => 'Life is too short to be generating QR codes',
|
||||
'extension' => 'png',
|
||||
'size' => 200,
|
||||
'margin' => 10,
|
||||
'label' => 'Scan the code',
|
||||
'label_font_size' => 16,
|
||||
]));
|
||||
|
||||
$response = $client->getResponse();
|
||||
$image = imagecreatefromstring($response->getContent());
|
||||
|
||||
$this->assertTrue(220 == imagesx($image));
|
||||
$this->assertEquals(Response::HTTP_OK, $response->getStatusCode());
|
||||
}
|
||||
|
||||
public function testTwigFunctionsAction()
|
||||
{
|
||||
$client = static::createClient();
|
||||
$client->request('GET', $client->getContainer()->get('router')->generate('endroid_qrcode_twig_functions'));
|
||||
|
||||
$response = $client->getResponse();
|
||||
|
||||
$this->assertEquals(Response::HTTP_OK, $response->getStatusCode());
|
||||
}
|
||||
}
|
||||
20
vendor/endroid/qr-code/tests/Bundle/EndroidQrCodeBundleTest.php
vendored
Normal file
20
vendor/endroid/qr-code/tests/Bundle/EndroidQrCodeBundleTest.php
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* (c) Jeroen van den Enden <info@endroid.nl>
|
||||
*
|
||||
* This source file is subject to the MIT license that is bundled
|
||||
* with this source code in the file LICENSE.
|
||||
*/
|
||||
|
||||
namespace Endroid\QrCode\Tests\Bundle;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class EndroidQrCodeBundleTest extends TestCase
|
||||
{
|
||||
public function testNoTestsYet()
|
||||
{
|
||||
$this->assertTrue(true);
|
||||
}
|
||||
}
|
||||
2
vendor/endroid/qr-code/tests/Bundle/app/.gitignore
vendored
Normal file
2
vendor/endroid/qr-code/tests/Bundle/app/.gitignore
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
/cache
|
||||
/logs
|
||||
36
vendor/endroid/qr-code/tests/Bundle/app/AppKernel.php
vendored
Normal file
36
vendor/endroid/qr-code/tests/Bundle/app/AppKernel.php
vendored
Normal file
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* (c) Jeroen van den Enden <info@endroid.nl>
|
||||
*
|
||||
* This source file is subject to the MIT license that is bundled
|
||||
* with this source code in the file LICENSE.
|
||||
*/
|
||||
|
||||
use Symfony\Component\Config\Loader\LoaderInterface;
|
||||
use Symfony\Component\HttpKernel\Kernel;
|
||||
|
||||
class AppKernel extends Kernel
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function registerBundles()
|
||||
{
|
||||
$bundles = [
|
||||
new Symfony\Bundle\FrameworkBundle\FrameworkBundle(),
|
||||
new Symfony\Bundle\TwigBundle\TwigBundle(),
|
||||
new Endroid\QrCode\Bundle\QrCodeBundle\EndroidQrCodeBundle(),
|
||||
];
|
||||
|
||||
return $bundles;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function registerContainerConfiguration(LoaderInterface $loader)
|
||||
{
|
||||
$loader->load(__DIR__.'/config/config.yml');
|
||||
}
|
||||
}
|
||||
3
vendor/endroid/qr-code/tests/Bundle/app/bootstrap.php
vendored
Normal file
3
vendor/endroid/qr-code/tests/Bundle/app/bootstrap.php
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
<?php
|
||||
|
||||
$loader = require __DIR__.'/../../../vendor/autoload.php';
|
||||
8
vendor/endroid/qr-code/tests/Bundle/app/config/config.yml
vendored
Normal file
8
vendor/endroid/qr-code/tests/Bundle/app/config/config.yml
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
framework:
|
||||
test: ~
|
||||
secret: ThisTokenIsNotSoSecretChangeIt
|
||||
templating:
|
||||
engines: ['twig']
|
||||
router:
|
||||
resource: "%kernel.root_dir%/config/routing.yml"
|
||||
strict_requirements: ~
|
||||
3
vendor/endroid/qr-code/tests/Bundle/app/config/routing.yml
vendored
Normal file
3
vendor/endroid/qr-code/tests/Bundle/app/config/routing.yml
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
EndroidQrCodeBundle:
|
||||
resource: "@EndroidQrCodeBundle/Resources/config/routing.yml"
|
||||
prefix: /qrcode
|
||||
122
vendor/endroid/qr-code/tests/QrCodeTest.php
vendored
Normal file
122
vendor/endroid/qr-code/tests/QrCodeTest.php
vendored
Normal file
@@ -0,0 +1,122 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* (c) Jeroen van den Enden <info@endroid.nl>
|
||||
*
|
||||
* This source file is subject to the MIT license that is bundled
|
||||
* with this source code in the file LICENSE.
|
||||
*/
|
||||
|
||||
namespace Endroid\QrCode\Tests;
|
||||
|
||||
use Endroid\QrCode\Factory\QrCodeFactory;
|
||||
use Endroid\QrCode\QrCode;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class QrCodeTest extends TestCase
|
||||
{
|
||||
public function testReadable()
|
||||
{
|
||||
$messages = [
|
||||
'Tiny',
|
||||
'This one has spaces',
|
||||
'd2llMS9uU01BVmlvalM2YU9BUFBPTTdQMmJabHpqdndt',
|
||||
'http://this.is.an/url?with=query&string=attached',
|
||||
'11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111',
|
||||
'{"i":"serialized.data","v":1,"t":1,"d":"4AEPc9XuIQ0OjsZoSRWp9DRWlN6UyDvuMlyOYy8XjOw="}',
|
||||
'Spëci&al ch@ract3rs',
|
||||
'有限公司',
|
||||
];
|
||||
|
||||
foreach ($messages as $message) {
|
||||
$qrCode = new QrCode($message);
|
||||
$qrCode->setSize(300);
|
||||
$qrCode->setValidateResult(true);
|
||||
$pngData = $qrCode->writeString();
|
||||
$this->assertTrue(is_string($pngData));
|
||||
}
|
||||
}
|
||||
|
||||
public function testFactory()
|
||||
{
|
||||
$qrCodeFactory = new QrCodeFactory();
|
||||
$qrCode = $qrCodeFactory->create('QR Code', [
|
||||
'writer' => 'png',
|
||||
'size' => 300,
|
||||
'margin' => 10,
|
||||
]);
|
||||
|
||||
$pngData = $qrCode->writeString();
|
||||
$this->assertTrue(is_string($pngData));
|
||||
}
|
||||
|
||||
public function testWriteQrCode()
|
||||
{
|
||||
$qrCode = new QrCode('QrCode');
|
||||
|
||||
$qrCode->setWriterByName('binary');
|
||||
$binData = $qrCode->writeString();
|
||||
$this->assertTrue(is_string($binData));
|
||||
|
||||
$qrCode->setWriterByName('debug');
|
||||
$debugData = $qrCode->writeString();
|
||||
$this->assertTrue(is_string($debugData));
|
||||
|
||||
$qrCode->setWriterByName('eps');
|
||||
$epsData = $qrCode->writeString();
|
||||
$this->assertTrue(is_string($epsData));
|
||||
|
||||
$qrCode->setWriterByName('png');
|
||||
$pngData = $qrCode->writeString();
|
||||
$this->assertTrue(is_string($pngData));
|
||||
$pngDataUriData = $qrCode->writeDataUri();
|
||||
$this->assertTrue(0 === strpos($pngDataUriData, 'data:image/png;base64'));
|
||||
|
||||
$qrCode->setWriterByName('svg');
|
||||
$svgData = $qrCode->writeString();
|
||||
$this->assertTrue(is_string($svgData));
|
||||
$svgDataUriData = $qrCode->writeDataUri();
|
||||
$this->assertTrue(0 === strpos($svgDataUriData, 'data:image/svg+xml;base64'));
|
||||
}
|
||||
|
||||
public function testSetSize()
|
||||
{
|
||||
$size = 400;
|
||||
$margin = 10;
|
||||
|
||||
$qrCode = new QrCode('QrCode');
|
||||
$qrCode->setSize($size);
|
||||
$qrCode->setMargin($margin);
|
||||
|
||||
$pngData = $qrCode->writeString();
|
||||
$image = imagecreatefromstring($pngData);
|
||||
|
||||
$this->assertTrue(imagesx($image) === $size + 2 * $margin);
|
||||
$this->assertTrue(imagesy($image) === $size + 2 * $margin);
|
||||
}
|
||||
|
||||
public function testSetLabel()
|
||||
{
|
||||
$qrCode = new QrCode('QrCode');
|
||||
$qrCode
|
||||
->setSize(300)
|
||||
->setLabel('Scan the code', 15)
|
||||
;
|
||||
|
||||
$pngData = $qrCode->writeString();
|
||||
$this->assertTrue(is_string($pngData));
|
||||
}
|
||||
|
||||
public function testSetLogo()
|
||||
{
|
||||
$qrCode = new QrCode('QrCode');
|
||||
$qrCode
|
||||
->setSize(400)
|
||||
->setLogoPath(__DIR__.'/../assets/symfony.png')
|
||||
->setLogoWidth(150)
|
||||
->setValidateResult(true);
|
||||
|
||||
$pngData = $qrCode->writeString();
|
||||
$this->assertTrue(is_string($pngData));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user