QrCodeControllerTest.php 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. <?php
  2. /*
  3. * (c) Jeroen van den Enden <info@endroid.nl>
  4. *
  5. * This source file is subject to the MIT license that is bundled
  6. * with this source code in the file LICENSE.
  7. */
  8. namespace Endroid\QrCode\Tests\Bundle\Controller;
  9. use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
  10. use Symfony\Component\HttpFoundation\Response;
  11. class QrCodeControllerTest extends WebTestCase
  12. {
  13. public function testGenerateAction()
  14. {
  15. $client = static::createClient();
  16. $client->request('GET', $client->getContainer()->get('router')->generate('endroid_qrcode_generate', [
  17. 'text' => 'Life is too short to be generating QR codes',
  18. 'extension' => 'png',
  19. 'size' => 200,
  20. 'margin' => 10,
  21. 'label' => 'Scan the code',
  22. 'label_font_size' => 16,
  23. ]));
  24. $response = $client->getResponse();
  25. $image = imagecreatefromstring($response->getContent());
  26. $this->assertTrue(220 == imagesx($image));
  27. $this->assertEquals(Response::HTTP_OK, $response->getStatusCode());
  28. }
  29. public function testTwigFunctionsAction()
  30. {
  31. $client = static::createClient();
  32. $client->request('GET', $client->getContainer()->get('router')->generate('endroid_qrcode_twig_functions'));
  33. $response = $client->getResponse();
  34. $this->assertEquals(Response::HTTP_OK, $response->getStatusCode());
  35. }
  36. }