setQueryResultsIteratorMock($mock); global $wpdb; $wpdb = new WPDB_Mock; $fields = array(); foreach (array_keys($data[0]) as $key) { $fields[] = (object)array('field_name' => $key); } $wpdb->getResultReturnVal = $fields; } public function test_missing_lname_field() { $options = array(); $options['content'] = '${fname} ${lname} | '; $exp = new ExportToHtmlTemplate(); ob_start(); $exp->export('dates', $options); $text = ob_get_contents(); $this->assertEquals("Mike Simpson | Oya | ", $text); } }