예제 #1
0
 /**
  * Tests the JForm::getLabel method
  */
 public function testGetLabel()
 {
     $form = new JFormInspector('form1');
     $this->assertThat($form->load(JFormDataHelper::$loadFieldDocument), $this->isTrue(), 'Line:' . __LINE__ . ' XML string should load successfully.');
     $field = new JFormFieldInspector($form);
     // Standard usage.
     $xml = $form->getXML();
     $title = array_pop($xml->xpath('fields/field[@name="title"]'));
     $this->assertThat($field->setup($title, 'The title'), $this->isTrue(), 'Line:' . __LINE__ . ' The setup method should return true if successful.');
     $this->assertThat($field->getLabel(), $this->equalTo('<label id="title_id-lbl" for="title_id" class="hasTip required" title="Title::The title.">Title<span class="star">&#160;*</span></label>'), 'Line:' . __LINE__ . ' The property should be computed from the XML.');
 }
예제 #2
0
 /**
  * Tests the JFormField::getLabel method
  *
  * @return void
  */
 public function testGetLabel()
 {
     $form = new JFormInspector('form1');
     $this->assertThat($form->load(JFormDataHelper::$loadFieldDocument), $this->isTrue(), 'Line:' . __LINE__ . ' XML string should load successfully.');
     $field = new JFormFieldInspector($form);
     // Standard usage.
     $xml = $form->getXml();
     $data = $xml->xpath('fields/field[@name="title"]');
     $title = array_pop($data);
     $this->assertThat($field->setup($title, 'The title'), $this->isTrue(), 'Line:' . __LINE__ . ' The setup method should return true if successful.');
     $matcher = array('id' => 'title_id-lbl', 'tag' => 'label', 'attributes' => array('for' => 'title_id', 'class' => 'hasTooltip required', 'title' => '<strong>Title</strong><br />The title.'), 'content' => 'regexp:/Title.*\\*/', 'child' => array('tag' => 'span', 'attributes' => array('class' => 'star'), 'content' => 'regexp:/\\*/'));
     $this->assertTag($matcher, $field->getLabel(), 'Line:' . __LINE__ . ' The property should be computed from the XML.');
     // Not required
     $data = $xml->xpath('fields/fields[@name="params"]/field[@name="colours"]');
     $colours = array_pop($data);
     $this->assertThat($field->setup($colours, 'id'), $this->isTrue(), 'Line:' . __LINE__ . ' The setup method should return true if successful.');
     $matcher = array('id' => 'colours-lbl', 'tag' => 'label', 'attributes' => array('for' => 'colours', 'class' => ''), 'content' => 'colours');
     $this->assertTag($matcher, $field->getLabel(), 'Line:' . __LINE__ . ' The property should be computed from the XML.');
     // Hidden field
     $data = $xml->xpath('fields/field[@name="id"]');
     $id = array_pop($data);
     $this->assertThat($field->setup($id, 'id'), $this->isTrue(), 'Line:' . __LINE__ . ' The setup method should return true if successful.');
     $this->assertEmpty($field->getLabel(), 'Line:' . __LINE__ . ' The property should be computed from the XML.');
 }
예제 #3
0
 /**
  * Tests the JFormField::getLabel method
  *
  * @covers JFormField::getLabel
  *
  * @return void
  */
 public function testGetLabel()
 {
     $form = new JFormInspector('form1');
     $this->assertThat($form->load(JFormDataHelper::$loadFieldDocument), $this->isTrue(), 'Line:' . __LINE__ . ' XML string should load successfully.');
     $field = new JFormFieldInspector($form);
     // Standard usage.
     $xml = $form->getXML();
     $title = array_pop($xml->xpath('fields/field[@name="title"]'));
     $this->assertThat($field->setup($title, 'The title'), $this->isTrue(), 'Line:' . __LINE__ . ' The setup method should return true if successful.');
     $equals = '<label id="title_id-lbl" for="title_id" class="hasTooltip required" ' . 'title="<strong>Title</strong><br />The title.">Title<span class="star">&#160;*</span></label>';
     $this->assertThat($field->getLabel(), $this->equalTo($equals), 'Line:' . __LINE__ . ' The property should be computed from the XML.');
     // Not required
     $colours = array_pop($xml->xpath('fields/fields[@name="params"]/field[@name="colours"]'));
     $this->assertThat($field->setup($colours, 'id'), $this->isTrue(), 'Line:' . __LINE__ . ' The setup method should return true if successful.');
     $this->assertThat($field->getLabel(), $this->equalTo('<label id="colours-lbl" for="colours" class="">colours</label>'), 'Line:' . __LINE__ . ' The property should be computed from the XML.');
     // Hidden field
     $id = array_pop($xml->xpath('fields/field[@name="id"]'));
     $this->assertThat($field->setup($id, 'id'), $this->isTrue(), 'Line:' . __LINE__ . ' The setup method should return true if successful.');
     $this->assertThat($field->getLabel(), $this->equalTo(''), 'Line:' . __LINE__ . ' The property should be computed from the XML.');
 }