/** * Test the getInput method. * * @return void * * @since 1.0 */ public function testGetInput() { $form = new JFormInspector('form1'); $this->assertThat($form->load('<form><field name="databaseconnection" type="databaseconnection" supported="mysqli" /></form>'), $this->isTrue(), 'Line:' . __LINE__ . ' XML string should load successfully.'); $field = new Field_DatabaseConnection($form); $this->assertThat($field->setup($form->getXml()->field, 'value'), $this->isTrue(), 'Line:' . __LINE__ . ' The setup method should return true.'); $this->assertThat(strlen($field->input), $this->greaterThan(0), 'Line:' . __LINE__ . ' The getInput method should return something without error; in this case, a "Mysqli" option.'); $this->assertThat($form->load('<form><field name="databaseconnection" type="databaseconnection" supported="non-existing" /></form>'), $this->isTrue(), 'Line:' . __LINE__ . ' XML string should load successfully.'); $field = new Field_DatabaseConnection($form); $this->assertThat($field->setup($form->getXml()->field, 'value'), $this->isTrue(), 'Line:' . __LINE__ . ' The setup method should return true.'); $this->assertThat(strlen($field->input), $this->greaterThan(0), 'Line:' . __LINE__ . ' The getInput method should return something without error; in this case, a "None" option.'); // TODO: Should check all the attributes have come in properly. }
/** * Test the getOptions method. * * @return void * * @since 1.0 */ public function testGetOptions() { $form = new JFormInspector('form1'); $this->assertThat($form->load('<form><field name="radio" type="radio"><option value="0">No</option><item value="1">Yes</item></field></form>'), $this->isTrue(), 'Line:' . __LINE__ . ' XML string should load successfully.'); $field = new Field_Radio($form); $this->assertThat($field->setup($form->getXml()->field, 'value'), $this->isTrue(), 'Line:' . __LINE__ . ' The setup method should return true.'); $this->assertThat(strlen($field->input), $this->logicalNot($this->StringContains('Yes')), 'Line:' . __LINE__ . ' The field should not contain a Yes option.'); }
/** * Test the getInput method. * * @return void * * @since 1.0 */ public function testGetInput() { $form = new JFormInspector('form1'); $this->assertThat($form->load('<form><field name="folderlist" type="folderlist" /></form>'), $this->isTrue(), 'Line:' . __LINE__ . ' XML string should load successfully.'); $field = new Field_FolderList($form); $this->assertThat($field->setup($form->getXml()->field, 'value'), $this->isTrue(), 'Line:' . __LINE__ . ' The setup method should return true.'); $this->assertThat(strlen($field->input), $this->greaterThan(0), 'Line:' . __LINE__ . ' The getInput method should return something without error.'); // TODO: Should check all the attributes have come in properly. }
/** * Test the getOptions method. * * @return void * * @since 1.0 */ public function testGetOptions() { $form = new JFormInspector('form1'); $this->assertThat($form->load('<form><field name="integer" type="integer" first="1" last="-5" step="1"/></form>'), $this->isTrue(), 'Line:' . __LINE__ . ' XML string should load successfully.'); $field = new Field_Integer($form); $this->assertThat($field->setup($form->getXml()->field, 'value'), $this->isTrue(), 'Line:' . __LINE__ . ' The setup method should return true.'); $this->assertThat($field->input, $this->logicalNot($this->StringContains('<option')), 'Line:' . __LINE__ . ' The field should not contain any options.'); $this->assertThat($form->load('<form><field name="integer" type="integer" first="-7" last="-5" step="1"/></form>'), $this->isTrue(), 'Line:' . __LINE__ . ' XML string should load successfully.'); $field = new Field_Integer($form); $this->assertThat($field->setup($form->getXml()->field, 'value'), $this->isTrue(), 'Line:' . __LINE__ . ' The setup method should return true.'); $this->assertThat($field->input, $this->StringContains('<option value="-7">-7</option>'), 'Line:' . __LINE__ . ' The field should contain -7 through -5 as options.'); $this->assertThat($form->load('<form><field name="integer" type="integer" first="-7" last="-5" step="-1"/></form>'), $this->isTrue(), 'Line:' . __LINE__ . ' XML string should load successfully.'); $field = new Field_Integer($form); $this->assertThat($field->setup($form->getXml()->field, 'value'), $this->isTrue(), 'Line:' . __LINE__ . ' The setup method should return true.'); $this->assertThat($field->input, $this->logicalNot($this->StringContains('<option')), 'Line:' . __LINE__ . ' The field should not contain any options.'); $this->assertThat($form->load('<form><field name="integer" type="integer" first="-5" last="-7" step="-1"/></form>'), $this->isTrue(), 'Line:' . __LINE__ . ' XML string should load successfully.'); $field = new Field_Integer($form); $this->assertThat($field->setup($form->getXml()->field, 'value'), $this->isTrue(), 'Line:' . __LINE__ . ' The setup method should return true.'); $this->assertThat($field->input, $this->StringContains('<option value="-7">-7</option>'), 'Line:' . __LINE__ . ' The field should contain -5 through -7 as options.'); }
/** * Test the getLabel method. * * @return void */ public function testGetLabel() { $form = new JFormInspector('form1'); $this->assertThat($form->load('<form><field name="spacer" type="spacer" description="spacer" /></form>'), $this->isTrue(), 'Line:' . __LINE__ . ' XML string should load successfully.'); $field = new Field_Spacer($form); $this->assertThat($field->setup($form->getXml()->field, 'value'), $this->isTrue(), 'Line:' . __LINE__ . ' The setup method should return true.'); $equals = '<span class="spacer"><span class="before"></span><span class="">' . '<label id="spacer-lbl" class="hasTip" title="spacer::spacer">spacer</label></span>' . '<span class="after"></span></span>'; $this->assertEquals($field->label, $equals, 'Line:' . __LINE__ . ' The getLabel method should return something without error.'); $this->assertThat($form->load('<form><field name="spacer" type="spacer" class="text" /></form>'), $this->isTrue(), 'Line:' . __LINE__ . ' XML string should load successfully.'); $field = new Field_Spacer($form); $this->assertThat($field->setup($form->getXml()->field, 'value'), $this->isTrue(), 'Line:' . __LINE__ . ' The setup method should return true.'); $equals = '<span class="spacer"><span class="before"></span><span class="text">' . '<label id="spacer-lbl" class="">spacer</label></span><span class="after"></span></span>'; $this->assertEquals($field->label, $equals, 'Line:' . __LINE__ . ' The getLabel method should return something without error.'); $this->assertThat($form->load('<form><field name="spacer" type="spacer" class="text" label="MyLabel" /></form>'), $this->isTrue(), 'Line:' . __LINE__ . ' XML string should load successfully.'); $field = new Field_Spacer($form); $this->assertThat($field->setup($form->getXml()->field, 'value'), $this->isTrue(), 'Line:' . __LINE__ . ' The setup method should return true.'); $equals = '<span class="spacer"><span class="before"></span><span class="text">' . '<label id="spacer-lbl" class="">MyLabel</label></span><span class="after"></span></span>'; $this->assertEquals($field->label, $equals, 'Line:' . __LINE__ . ' The getLabel method should return something without error.'); $this->assertThat($form->load('<form><field name="spacer" type="spacer" hr="true" /></form>'), $this->isTrue(), 'Line:' . __LINE__ . ' XML string should load successfully.'); $field = new Field_Spacer($form); $this->assertThat($field->setup($form->getXml()->field, 'value'), $this->isTrue(), 'Line:' . __LINE__ . ' The setup method should return true.'); $expected = '<span class="spacer"><span class="before"></span><span class=""><hr class="" /></span>' . '<span class="after"></span></span>'; $this->assertEquals($field->label, $expected, 'Line:' . __LINE__ . ' The getLabel method should return something without error.'); }
/** * Test the Form::load method for XPath data. * * This method can load an XML data object, or parse an XML string. * * @return void */ public function testLoad_XPath() { $form = new JFormInspector('form1'); $this->assertThat($form->load(JFormDataHelper::$loadXPathDocument, true, '/extension/fields'), $this->isTrue(), 'Line:' . __LINE__ . ' XML string should load successfully.'); $this->assertThat($form->getXml()->getName(), $this->equalTo('form'), 'Line:' . __LINE__ . ' The internal XML should still be named "form".'); // @todo remove: $this->_showXml($form);die; $this->assertThat(count($form->getXml()->fields->fields), $this->equalTo(2), 'Line:' . __LINE__ . ' The test data has 2 fields.'); }