/** * Test the getInput method. * * @return void */ public function testGetInput() { $form = new JFormInspector('form1'); // Test a traditional hidden field type. $this->assertThat($form->load('<form><field name="hidden" type="hidden" label="foo" /></form>'), $this->isTrue(), 'Line:' . __LINE__ . ' XML string should load successfully.'); $field = new Field_Hidden($form); $this->assertThat($form->getLabel('hidden'), $this->equalTo(''), 'Line:' . __LINE__ . ' The label of a hidden element should be nothing.'); // Test a field with attribute hidden = true. $this->assertThat($form->load('<form><field name="hidden" type="text" label="foo" hidden="true" /></form>'), $this->isTrue(), 'Line:' . __LINE__ . ' XML string should load successfully.'); $field = new Field_Hidden($form); $this->assertThat($form->getLabel('hidden'), $this->equalTo(''), 'Line:' . __LINE__ . ' The label of a hidden element should be nothing.'); // Test a field with attribute hidden = false. $this->assertThat($form->load('<form><field name="hidden" type="text" label="foo" hidden="false" /></form>'), $this->isTrue(), 'Line:' . __LINE__ . ' XML string should load successfully.'); $field = new Field_Hidden($form); $this->assertThat($form->getLabel('hidden'), $this->equalTo('<label id="hidden-lbl" for="hidden" class="">foo</label>'), 'Line:' . __LINE__ . ' The label of a non-hidden element should be some HTML.'); }
/** * Test for Form::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.'); $expected = '<label id="title_id-lbl" for="title_id" class="hasTip required" ' . 'title="Title::The title.">Title<span class="star"> *</span></label>'; $this->assertThat($form->getLabel('title'), $this->equalTo($expected), 'Line:' . __LINE__ . ' The method should return a simple label field.'); }