/** * Tests the Joomla\Form\Field::__construct method * * @covers Joomla\Form\Field::__construct * * @return void */ public function testConstruct() { $form = new Form('form1'); $this->assertThat($form->load(JFormDataHelper::$loadFieldDocument), $this->isTrue(), 'Line:' . __LINE__ . ' XML string should load successfully.'); $field = new JFormFieldInspector($form); $this->assertThat($field instanceof \Joomla\Form\Field, $this->isTrue(), 'Line:' . __LINE__ . ' The JFormField constuctor should return a JFormField object.'); $this->assertThat($field->getForm(), $this->identicalTo($form), 'Line:' . __LINE__ . ' The internal form should be identical to the variable passed in the contructor.'); // Add custom path. FormHelper::addFieldPath(__DIR__ . '/_testfields'); FormHelper::loadFieldType('foo.bar'); $field = new \Foo\Form\Field_Bar($form); $this->assertEquals($field->type, 'Foo\\Field_Bar', 'Line:' . __LINE__ . ' The field type should have been guessed by the constructor.'); FormHelper::loadFieldType('foo'); $field = new \Joomla\Form\Field_Foo($form); $this->assertEquals($field->type, 'Joomla\\Field_Foo', 'Line:' . __LINE__ . ' The field type should have been guessed by the constructor.'); FormHelper::loadFieldType('modal_foo'); $field = new \Joomla\Form\Field_Modal_Foo($form); $this->assertEquals($field->type, 'Joomla\\Field_Modal_Foo', 'Line:' . __LINE__ . ' The field type should have been guessed by the constructor.'); }