当前位置: 首页>>代码示例>>PHP>>正文


PHP html_writer::attributes方法代码示例

本文整理汇总了PHP中html_writer::attributes方法的典型用法代码示例。如果您正苦于以下问题:PHP html_writer::attributes方法的具体用法?PHP html_writer::attributes怎么用?PHP html_writer::attributes使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在html_writer的用法示例。


在下文中一共展示了html_writer::attributes方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: assert

 public function assert($expectation, $compare, $notused = '')
 {
     if (get_class($expectation) === 'question_pattern_expectation') {
         $this->assertRegExp($expectation->pattern, $compare, 'Expected regex ' . $expectation->pattern . ' not found in ' . $compare);
         return;
     } else {
         if (get_class($expectation) === 'question_no_pattern_expectation') {
             $this->assertNotRegExp($expectation->pattern, $compare, 'Unexpected regex ' . $expectation->pattern . ' found in ' . $compare);
             return;
         } else {
             if (get_class($expectation) === 'question_contains_tag_with_attributes') {
                 $this->assertTag(array('tag' => $expectation->tag, 'attributes' => $expectation->expectedvalues), $compare, 'Looking for a ' . $expectation->tag . ' with attributes ' . html_writer::attributes($expectation->expectedvalues) . ' in ' . $compare);
                 foreach ($expectation->forbiddenvalues as $k => $v) {
                     $attr = $expectation->expectedvalues;
                     $attr[$k] = $v;
                     $this->assertNotTag(array('tag' => $expectation->tag, 'attributes' => $attr), $compare, $expectation->tag . ' had a ' . $k . ' attribute that should not be there in ' . $compare);
                 }
                 return;
             } else {
                 if (get_class($expectation) === 'question_contains_tag_with_attribute') {
                     $attr = array($expectation->attribute => $expectation->value);
                     $this->assertTag(array('tag' => $expectation->tag, 'attributes' => $attr), $compare, 'Looking for a ' . $expectation->tag . ' with attribute ' . html_writer::attributes($attr) . ' in ' . $compare);
                     return;
                 } else {
                     if (get_class($expectation) === 'question_does_not_contain_tag_with_attributes') {
                         $this->assertNotTag(array('tag' => $expectation->tag, 'attributes' => $expectation->attributes), $compare, 'Unexpected ' . $expectation->tag . ' with attributes ' . html_writer::attributes($expectation->attributes) . ' found in ' . $compare);
                         return;
                     } else {
                         if (get_class($expectation) === 'question_contains_select_expectation') {
                             $tag = array('tag' => 'select', 'attributes' => array('name' => $expectation->name), 'children' => array('count' => count($expectation->choices)));
                             if ($expectation->enabled === false) {
                                 $tag['attributes']['disabled'] = 'disabled';
                             } else {
                                 if ($expectation->enabled === true) {
                                     // TODO
                                 }
                             }
                             foreach (array_keys($expectation->choices) as $value) {
                                 if ($expectation->selected === $value) {
                                     $tag['child'] = array('tag' => 'option', 'attributes' => array('value' => $value, 'selected' => 'selected'));
                                 } else {
                                     $tag['child'] = array('tag' => 'option', 'attributes' => array('value' => $value));
                                 }
                             }
                             $this->assertTag($tag, $compare, 'expected select not found in ' . $compare);
                             return;
                         } else {
                             if (get_class($expectation) === 'question_check_specified_fields_expectation') {
                                 $expect = (array) $expectation->expect;
                                 $compare = (array) $compare;
                                 foreach ($expect as $k => $v) {
                                     if (!array_key_exists($k, $compare)) {
                                         $this->fail("Property {$k} does not exist");
                                     }
                                     if ($v != $compare[$k]) {
                                         $this->fail("Property {$k} is different");
                                     }
                                 }
                                 $this->assertTrue(true);
                                 return;
                             } else {
                                 if (get_class($expectation) === 'question_contains_tag_with_contents') {
                                     $this->assertTag(array('tag' => $expectation->tag, 'content' => $expectation->content), $compare, 'Looking for a ' . $expectation->tag . ' with content ' . $expectation->content . ' in ' . $compare);
                                     return;
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
     throw new coding_exception('Unknown expectiontion:' . get_class($expectation));
 }
开发者ID:saurabh947,项目名称:MoodleLearning,代码行数:74,代码来源:helpers.php

示例2: check_output_contains_hidden_input

 protected function check_output_contains_hidden_input($name, $value)
 {
     $attributes = array('type' => 'hidden', 'name' => $this->quba->get_field_prefix($this->slot) . $name, 'value' => $value);
     $this->assertTag($this->get_tag_matcher('input', $attributes), $this->currentoutput, 'Looking for a hidden input with attributes ' . html_writer::attributes($attributes) . ' in ' . $this->currentoutput);
 }
开发者ID:gabrielrosset,项目名称:moodle,代码行数:5,代码来源:helpers.php

示例3: check_output_contains_text_input

 protected function check_output_contains_text_input($name, $value = null, $enabled = true)
 {
     $attributes = array('type' => 'text', 'name' => $this->quba->get_field_prefix($this->slot) . $name);
     if (!is_null($value)) {
         $attributes['value'] = $value;
     }
     if (!$enabled) {
         $attributes['readonly'] = 'readonly';
     }
     $matcher = $this->get_tag_matcher('input', $attributes);
     $this->assertTag($matcher, $this->currentoutput, 'Looking for an input with attributes ' . html_writer::attributes($attributes) . ' in ' . $this->currentoutput);
     if ($enabled) {
         $matcher['attributes']['readonly'] = 'readonly';
         $this->assertNotTag($matcher, $this->currentoutput, 'input with attributes ' . html_writer::attributes($attributes) . ' should not be read-only in ' . $this->currentoutput);
     }
 }
开发者ID:sowirepo,项目名称:moodle-qtype_stack,代码行数:16,代码来源:test_base.php


注:本文中的html_writer::attributes方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。