JsHelperTest.php 1.0 KB

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