Source of file InfoBoxesTest.php
Size: 1,543 Bytes - Last Modified: 2021-12-23T10:38:20+00:00
/var/www/docs.ssmods.com/process/src/tests/InfoBoxesTest.php
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758 | <?php class InfoBoxesTest extends SapphireTest { public function testParseForJS() { $reflection = new ReflectionClass('InfoBoxes'); $method = $reflection->getMethod('parseForJS'); $method->setAccessible(true); $checks = new InfoBoxes(); $testConf = array( 'dev' => array( 'type' => 0, 'message' => 'Dev Mode', 'link' => 'http://google.co.uk/' ), 'pass' => array( 'type' => 1, 'message' => 'Default Password', 'link' => false ), 'html' => array( 'type' => 2, 'message' => '<style>.devcheck { font-size: 18px; }</style><strong>\'HTML\' "Test"</strong>', 'link' => '"><script>alert(\'ok\');</script><a href="#' ) ); $returned = $method->invoke($checks, $testConf); $expected = array( 'Data' => "[[0, 'Dev Mode', 'http://google.co.uk/']," . " [1, 'Default Password', ''], " . "[2, '<style>.devcheck { font-size: 18px; }</style><strong>'HTML' "Test"</strong>', " . "'"><script>alert('ok');</script><a href="#']]" ); $this->assertEquals($expected, $returned); } public function testEscapeJS() { $reflection = new ReflectionClass('InfoBoxes'); $method = $reflection->getMethod('escapeJS'); $method->setAccessible(true); $checks = new InfoBoxes(); $returned = $method->invoke($checks, "' <script>alert('hello');</script>"); $expected = "' <script>alert('hello');</script>"; $this->assertEquals($expected, $returned); } } |