function test_format_records()
 {
     $records = array(array('url' => '/dummy/test/many001'), array('url' => '/dummy/test/many002'), array('url' => '/dummy/test/single'));
     $module = new DummyModule();
     // returns null if no formatter found
     $this->assertTrue(is_null($module->format_records(array(), 'junk', 1)));
     // returns null if no formatter specified
     $this->assertTrue(is_null($module->format_records(array(), NULL, 1)));
     // check formats
     // xml
     $result = $module->format_records($records, 'xml', 3);
     $this->assertTrue(preg_match('/\\bsingle\\b/', $result) == 1);
     $matches = array();
     preg_match_all('/<record>/', $result, $matches);
     $this->assertEqual(count($matches[0]), 3);
     // text
     $result = $module->format_records($records, 'text', 3);
     $this->assertTrue(preg_match('/\\bsingle\\b/', $result) == 1);
     preg_match_all('/Title:/', $result, $matches);
     $this->assertEqual(count($matches[0]), 3);
     // bibtex
     $result = $module->format_records($records, 'bibtex', 3);
     $this->assertTrue(preg_match('/\\bsingle\\b/', $result) == 1);
     preg_match_all('/@Misc/', $result, $matches);
     $this->assertEqual(count($matches[0]), 3);
     // check limit
     $result = $module->format_records($records, 'text', 2);
     $this->assertFalse(preg_match('/\\bsingle\\b/', $result) == 1);
     preg_match_all('/Title:/', $result, $matches);
     $this->assertEqual(count($matches[0]), 2);
     // check default record separator using text formatter
     $result = $module->format_records($records, 'text', 3);
     preg_match_all('/----/', $result, $matches);
     $this->assertEqual(count($matches[0]), 2);
     // check custom record separator
     $result = $module->format_records($records, 'text', 3, '@@@@');
     $this->assertFalse(preg_match('/----/', $result) == 1);
     preg_match_all('/@@@@/', $result, $matches);
     $this->assertEqual(count($matches[0]), 2);
     // check header/footer using xml formatter
     $result = $module->format_records($records, 'xml', 3);
     $this->assertTrue(preg_match('/xml version/', $result) == 1);
     $this->assertTrue(preg_match('/<\\/results>/', $result) == 1);
 }