Proyectos de Subversion Moodle

Rev

Rev 1 | Mostrar el archivo completo | | | Autoría | Ultima modificación | Ver Log |

Rev 1 Rev 1441
Línea 23... Línea 23...
23
 * @package   core_question
23
 * @package   core_question
24
 * @category  test
24
 * @category  test
25
 * @copyright 2023 Jun Pataleta
25
 * @copyright 2023 Jun Pataleta
26
 * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
26
 * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
27
 */
27
 */
28
class question_display_options_test extends \advanced_testcase {
28
final class question_display_options_test extends \advanced_testcase {
Línea 29... Línea 29...
29
 
29
 
30
    /**
30
    /**
31
     * Data provider for {@see self::test_has_question_identifier()}
31
     * Data provider for {@see self::test_has_question_identifier()}
32
     *
32
     *
33
     * @return array[]
33
     * @return array[]
34
     */
34
     */
35
    public function has_question_identifier_provider(): array {
35
    public static function has_question_identifier_provider(): array {
36
        return [
36
        return [
37
            'Empty string' => ['', false],
37
            'Empty string' => ['', false],
38
            'Empty space' => ['   ', false],
38
            'Empty space' => ['   ', false],
39
            'Null' => [null, false],
39
            'Null' => [null, false],
Línea 59... Línea 59...
59
    /**
59
    /**
60
     * Data provider for {@see self::test_add_question_identifier_to_label()
60
     * Data provider for {@see self::test_add_question_identifier_to_label()
61
     *
61
     *
62
     * @return array[]
62
     * @return array[]
63
     */
63
     */
64
    public function add_question_identifier_to_label_provider(): array {
64
    public static function add_question_identifier_to_label_provider(): array {
65
        return [
65
        return [
66
            'Empty string identifier' => ['Hello', '', false, false, "Hello"],
66
            'Empty string identifier' => ['Hello', '', false, false, "Hello"],
67
            'Null identifier' => ['Hello', null, false, false, "Hello"],
67
            'Null identifier' => ['Hello', null, false, false, "Hello"],
68
            'With identifier' => ['Hello', 'World', false, false, "Hello World"],
68
            'With identifier' => ['Hello', 'World', false, false, "Hello World"],
-
 
69
            'With identifier, visually-hidden' => [
-
 
70
                'Hello',
-
 
71
                'World',
-
 
72
                true,
-
 
73
                false,
69
            'With identifier, sr-only' => ['Hello', 'World', true, false, 'Hello <span class="sr-only">World</span>'],
74
                'Hello <span class="visually-hidden">World</span>',
-
 
75
            ],
70
            'With identifier, prepend' => ['Hello', 'World', false, true, "World Hello"],
76
            'With identifier, prepend' => ['Hello', 'World', false, true, "World Hello"],
71
        ];
77
        ];
72
    }
78
    }
Línea 73... Línea 79...
73
 
79
 
Línea 76... Línea 82...
76
     *
82
     *
77
     * @covers ::add_question_identifier_to_label
83
     * @covers ::add_question_identifier_to_label
78
     * @dataProvider add_question_identifier_to_label_provider
84
     * @dataProvider add_question_identifier_to_label_provider
79
     * @param string $label The label string.
85
     * @param string $label The label string.
80
     * @param string|null $identifier The question identifier.
86
     * @param string|null $identifier The question identifier.
81
     * @param bool $sronly Whether to render the question identifier in a sr-only container
87
     * @param bool $sronly Whether to render the question identifier in a visually-hidden container
82
     * @param bool $addbefore Whether to render the question identifier before the label.
88
     * @param bool $addbefore Whether to render the question identifier before the label.
83
     * @param string $expected The expected return value.
89
     * @param string $expected The expected return value.
84
     * @return void
90
     * @return void
85
     */
91
     */
86
    public function test_add_question_identifier_to_label(
92
    public function test_add_question_identifier_to_label(