BladeJsonTest.php 686 B

12345678910111213141516171819202122
  1. <?php
  2. namespace Illuminate\Tests\View\Blade;
  3. class BladeJsonTest extends AbstractBladeTestCase
  4. {
  5. public function testStatementIsCompiledWithSafeDefaultEncodingOptions()
  6. {
  7. $string = 'var foo = @json($var);';
  8. $expected = 'var foo = <?php echo json_encode($var, 15, 512) ?>;';
  9. $this->assertEquals($expected, $this->compiler->compileString($string));
  10. }
  11. public function testEncodingOptionsCanBeOverwritten()
  12. {
  13. $string = 'var foo = @json($var, JSON_HEX_TAG);';
  14. $expected = 'var foo = <?php echo json_encode($var, JSON_HEX_TAG, 512) ?>;';
  15. $this->assertEquals($expected, $this->compiler->compileString($string));
  16. }
  17. }