Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
10.53% covered (danger)
10.53%
2 / 19
50.00% covered (danger)
50.00%
1 / 2
CRAP
0.00% covered (danger)
0.00%
0 / 1
phpbb_quoteattr_test
10.53% covered (danger)
10.53%
2 / 19
50.00% covered (danger)
50.00%
1 / 2
4.87
0.00% covered (danger)
0.00%
0 / 1
 quoteattr_test_data
0.00% covered (danger)
0.00%
0 / 17
0.00% covered (danger)
0.00%
0 / 1
2
 test_quoteattr
100.00% covered (success)
100.00%
2 / 2
100.00% covered (success)
100.00%
1 / 1
1
1<?php
2/**
3*
4* This file is part of the phpBB Forum Software package.
5*
6* @copyright (c) phpBB Limited <https://www.phpbb.com>
7* @license GNU General Public License, version 2 (GPL-2.0)
8*
9* For full copyright and license information, please see
10* the docs/CREDITS.txt file.
11*
12*/
13
14class phpbb_quoteattr_test extends phpbb_test_case
15{
16    public static function quoteattr_test_data()
17    {
18        return array(
19            array('foo', null, '"foo"'),
20            array('', null, '""'),
21            array(' ', null, '" "'),
22            array('<a>', null, '"&lt;a&gt;"'),
23            array('&amp;', null, '"&amp;amp;"'),
24            array('"hello"', null, "'\"hello\"'"),
25            array("'hello'", null, "\"'hello'\""),
26            array("\"'", null, "\"&quot;'\""),
27            array("a\nb", null, '"a&#10;b"'),
28            array("a\r\nb", null, '"a&#13;&#10;b"'),
29            array("a\tb", null, '"a&#9;b"'),
30            array('a b', null, '"a b"'),
31            array('"a<b"', null, "'\"a&lt;b\"'"),
32            array('foo', array('f' => 'z'), '"zoo"'),
33            array('<a>', array('a' => '&amp;'), '"&lt;&amp;&gt;"'),
34        );
35    }
36
37    /**
38    * @dataProvider quoteattr_test_data
39    */
40    public function test_quoteattr($input, $entities, $expected)
41    {
42        $output = phpbb_quoteattr($input, $entities);
43
44        $this->assertEquals($expected, $output);
45    }
46}