12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788 |
- <?php
- /**
- * Part of the Fuel framework.
- *
- * @package Fuel
- * @version 1.5
- * @author Fuel Development Team
- * @license MIT License
- * @copyright 2010 - 2013 Fuel Development Team
- * @link http://fuelphp.com
- */
- namespace Fuel\Core;
- /**
- * Security class tests
- *
- * @group Core
- * @group Security
- */
- class Test_Security extends TestCase
- {
- /**
- * Tests Security::htmlentities()
- *
- * @test
- */
- public function test_htmlentities_doublequote_and_ampersand()
- {
- $output = Security::htmlentities('"H&M"');
- $expected = '"H&M"';
- $this->assertEquals($expected, $output);
- }
- /**
- * Tests Security::htmlentities()
- *
- * @test
- */
- public function test_htmlentities_singlequote()
- {
- $output = Security::htmlentities("'");
- $expected = ''';
- $this->assertEquals($expected, $output);
- }
- /**
- * Tests Security::htmlentities()
- *
- * @test
- */
- public function test_htmlentities_charactor_references_no_double_encode()
- {
- $output = Security::htmlentities('You must write & as &');
- $expected = 'You must write & as &';
- $this->assertEquals($expected, $output);
- }
- /**
- * Tests Security::htmlentities()
- *
- * @test
- */
- public function test_htmlentities_charactor_references_double_encode()
- {
- $config = \Config::get('security.htmlentities_double_encode');
- \Config::set('security.htmlentities_double_encode', true);
- $output = Security::htmlentities('You must write & as &');
- $expected = 'You must write & as &amp;';
- $this->assertEquals($expected, $output);
- \Config::set('security.htmlentities_double_encode', $config);
- }
- /**
- * Tests Security::htmlentities()
- *
- * @test
- */
- public function test_htmlentities_double_encode()
- {
- $output = Security::htmlentities('"H&M"');
- $output = Security::htmlentities($output);
- $expected = '"H&M"';
- $this->assertEquals($expected, $output);
- }
- }
|