JsHelperTest.php 959 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. <?php
  2. namespace Tools\TestCase\View\Helper;
  3. use Cake\View\View;
  4. use Tools\TestSuite\TestCase;
  5. use Tools\View\Helper\JsHelper;
  6. class JsHelperTest extends TestCase {
  7. /**
  8. * @return void
  9. */
  10. public function setUp() {
  11. parent::setUp();
  12. $this->Js = new JsHelper(new View(null));
  13. }
  14. /**
  15. * @return void
  16. */
  17. public function tearDown() {
  18. unset($this->Table);
  19. //TableRegistry::clear();
  20. parent::tearDown();
  21. }
  22. /**
  23. * @return void
  24. */
  25. public function testObject() {
  26. $this->assertInstanceOf('Tools\View\Helper\JsHelper', $this->Js);
  27. }
  28. /**
  29. * JsHelperTest::testBuffer()
  30. *
  31. * @return void
  32. */
  33. public function testBuffer() {
  34. $script = <<<JS
  35. jQuery(document).ready(function() {
  36. // Code
  37. });
  38. JS;
  39. $this->Js->buffer($script);
  40. $output = $this->Js->writeBuffer();
  41. $expected = <<<HTML
  42. <script>
  43. //<![CDATA[
  44. jQuery(document).ready(function() {
  45. // Code
  46. });
  47. //]]>
  48. </script>
  49. HTML;
  50. $this->assertTextEquals($expected, $output);
  51. }
  52. }