/** * Test for JForm::filter method. * * @return void */ public function testFilter() { $form = new JFormInspector('form1'); // Check the test data loads ok. $this->assertThat($form->load(JFormDataHelper::$filterDocument), $this->isTrue(), 'Line:' . __LINE__ . ' XML string should load successfully.'); $data = array('word' => 'Joomla! Framework', 'author' => 'Should not bind', 'params' => array('show_title' => 1, 'show_author' => false), 'default' => ''); $filtered = $form->filter($data); $this->assertThat(is_array($filtered), $this->isTrue(), 'Line:' . __LINE__ . ' The filtered result should be an array.'); // Test that filtering is occuring (not that all filters work - done in testFilterField). $this->assertThat($filtered['word'], $this->equalTo('JoomlaFramework'), 'Line:' . __LINE__ . ' The variable should be filtered by the "word" filter.'); $this->assertThat(isset($filtered['author']), $this->isFalse(), 'Line:' . __LINE__ . ' A variable in the data not present in the form should not exist.'); $this->assertThat($filtered['params']['show_title'], $this->equalTo(1), 'Line:' . __LINE__ . ' The nested variable should be present.'); $this->assertThat($filtered['params']['show_author'], $this->equalTo(0), 'Line:' . __LINE__ . ' The nested variable should be present.'); }