PageRenderTime 54ms CodeModel.GetById 22ms RepoModel.GetById 0ms app.codeStats 0ms

/tests/Rendering/Manager/SwimRenderingManagerTest.php

https://gitlab.com/src-run/teavee-scribble-down-bundle
PHP | 74 lines | 44 code | 18 blank | 12 comment | 0 complexity | f4750a7aabaaebf31a0903630c523df5 MD5 | raw file
  1. <?php
  2. /*
  3. * This file is part of the Scribe Cache Bundle.
  4. *
  5. * (c) Scribe Inc. <source@scribe.software>
  6. *
  7. * For the full copyright and license information, please view the LICENSE.md
  8. * file that was distributed with this source code.
  9. */
  10. namespace Scribe\Teavee\ScribbleDownBundle\Tests\Rendering\Manager;
  11. use Scribe\WonkaBundle\Utility\TestCase\KernelTestCase;
  12. /**
  13. * Class SwimRenderingManagerTest.
  14. */
  15. class SwimRenderingManagerTest extends KernelTestCase
  16. {
  17. public function testSwimManagerInstance()
  18. {
  19. $manager = static::$staticContainer->get('s.teavee_scribble_down');
  20. static::assertInstanceOf('Scribe\Teavee\ScribbleDownBundle\Rendering\Manager\SwimRenderingManagerCached', $manager);
  21. }
  22. public function testSwimManagerRendering()
  23. {
  24. $manager = static::$staticContainer->get('s.teavee_scribble_down');
  25. $swim = "# Header 1\n\nSome text.\n\n## Header 2\n\nOther text.";
  26. $expected = '<h1 id="anchor-header1">Header 1</h1>
  27. <p>Some text.</p>
  28. <h2 id="anchor-header2">Header 2</h2>
  29. <p>Other text.</p>';
  30. $result = $manager->render($swim);
  31. static::assertEquals($expected, $result);
  32. }
  33. public function testSwimManagerRenderingAvertCached()
  34. {
  35. $manager = static::$staticContainer->get('s.teavee_scribble_down');
  36. $rand1 = mt_rand(10000, 40000);
  37. $rand2 = mt_rand(50000, 100000);
  38. $swim = "# Header 1\n\nRandom number: ".$rand1.".\n\n## Header 2\n\nRandom number: ".$rand2.'.';
  39. $expected = '<h1 id="anchor-header1">Header 1</h1>
  40. <p>Random number: '.$rand1.'.</p>
  41. <h2 id="anchor-header2">Header 2</h2>
  42. <p>Random number: '.$rand2.'.</p>';
  43. $result = $manager->render($swim);
  44. static::assertEquals($expected, $result);
  45. }
  46. public function testSwimManagerFullPage()
  47. {
  48. $manager = static::$staticContainer->get('s.teavee_scribble_down');
  49. $dirPath = realpath(static::$staticContainer->getParameter('kernel.root_dir').'/../../.config/testers/fixtures/ScribeSwimBundle/Rendering/Manager/');
  50. $content_swim = file_get_contents($dirPath.'/scml.swim');
  51. $content_html = file_get_contents($dirPath.'/scml.html');
  52. $result = $manager->render($content_swim);
  53. static::assertEquals($content_html, $result);
  54. }
  55. }
  56. /* EOF */