/** * Test for JForm::getGroup method. * * @return void */ public function testGetGroup() { $form = new JFormInspector('form1'); $this->assertThat($form->load(JFormDataHelper::$findFieldsByGroupDocument), $this->isTrue(), 'Line:' . __LINE__ . ' XML string should load successfully.'); // Test error handling. $this->assertThat($form->getGroup('bogus'), $this->equalTo(array()), 'Line:' . __LINE__ . ' A group that does not exist should return an empty array.'); // Test general usage. $this->assertThat(count($form->getGroup('params')), $this->equalTo(3), 'Line:' . __LINE__ . ' The params group should have 3 field elements.'); $this->assertThat(count($form->getGroup('level1', true)), $this->equalTo(2), 'Line:' . __LINE__ . ' The level1 group should have 2 nested field elements.'); $this->assertThat(array_keys($form->getGroup('level1', true)), $this->equalTo(array('level1_field1', 'level1_level2_field2')), 'Line:' . __LINE__ . ' The level1 group should have 2 nested field elements.'); $this->assertThat(count($form->getGroup('level1.level2')), $this->equalTo(1), 'Line:' . __LINE__ . ' The level2 group should have 1 field element.'); }