/** * Tests the Form::bind method. * * This method is used to load data into the JForm object. * * @return void */ public function testBind() { $form = new JFormInspector('form1'); $xml = JFormDataHelper::$bindDocument; // Check the test data loads ok. $this->assertThat($form->load($xml), $this->isTrue(), 'Line:' . __LINE__ . ' XML string should load successfully.'); $data = array('title' => 'Joomla Framework', 'author' => 'Should not bind', 'params' => array('show_title' => 1, 'show_abstract' => 0, 'show_author' => 1, 'categories' => array(1, 2), 'keywords' => array('en-GB' => 'Joomla', 'fr-FR' => 'Joomla'))); $this->assertThat($form->bind($data), $this->isTrue(), 'Line:' . __LINE__ . ' The data should bind successfully.'); $data = $form->getData(); $this->assertThat($data->get('title'), $this->equalTo('Joomla Framework'), 'Line:' . __LINE__ . ' The data should bind to form field elements.'); $this->assertThat($data->get('author'), $this->isNull(), 'Line:' . __LINE__ . ' The data should not bind to unknown form field elements.'); $this->assertThat(is_array($data->get('params.categories')), $this->isTrue(), 'Line:' . __LINE__ . ' The categories param should be an array.'); }