- simpletest will drop the whole test database in the end of each test so tearDown should not be needed.
- there is a missing parent::setUp(); in the beginning of each setUp()
- the biblio module needs to be enabled in each setUp() with parent::setUp('biblio');

Comments

scor’s picture

Status: Active » Needs review
StatusFileSize
new3.39 KB
scor’s picture

StatusFileSize
new4.13 KB

Some tests were failing due to the old D7 title as a field. Reverted to current title model. The keywords test was also failing due to biblio_get_keyword_by_id() returns a PDO db value, which needs to be cast to an array.

All biblio test are now passing on my machine with the latest HEAD.

rjerome’s picture

Thanks very much Stéphane,

Given the likely release of 7.x in the not so distant future, I've just recently started looking at the 7.x code base again. I should warn you that there are likely to be some fairly significant changes in the near future, becuase I'm going to merge in all the work I did in the 6.x-2.x branch.

I will include those changes to the tests.

Cheers,

Ron.

scor’s picture

That's great! Looking forward to see the changes landing in D7. May I ask you a rough estimate ETA for this merge D6.2 -> D7? Shall I stop digging into Biblio 7.x and I wait then?

rjerome’s picture

I'm just cleaning it up now, hopefully I can get something up this weekend.

scor’s picture

StatusFileSize
new15.5 KB

I was going to close this issue seeing the patch #2 was committed as part of the mega gigantic message-less commit http://drupal.org/cvs?commit=420636 but I found more issues that needs fixing in export.import.test (due to the new 6.x-2.x changes brought in 7.x).

So far I've only had time to fix the first test method testBiblioNodeExport() which passes. I had to make several fixes through the biblio modules which I'm attaching in this patch.

scor’s picture

Below I'm providing a patch review to make Ron's job a bit easier :) I'm not familliar with the API changes on the module, so please correct me if I'm wrong!

+++ biblio.module	14 Sep 2010 15:35:26 -0000
@@ -2426,7 +2426,12 @@ function biblio_get_title_url_info($node
 function biblio_get_map($type, $format) {
-  return  unserialize(db_result(db_query("SELECT %s FROM {biblio_type_maps} WHERE format='%s'", array($type, $format))));
+  $result = db_select('biblio_type_maps', 'btm')
+    ->fields('btm', array($type))
+    ->condition('format', $format)
+    ->execute()
+    ->fetchField();
+  return  unserialize($result);
 }

db_result is no longer part of D7.

+++ includes/biblio.import.export.inc	14 Sep 2010 15:35:26 -0000
@@ -353,7 +353,7 @@ function biblio_import($import_file, $ty
-      list($nids, $dups) = module_invoke($type, 'biblio_import', $import_file, $terms, $batch_proc, $session_id);
+      list($nids, $dups) = module_invoke('biblio_' . $type, 'biblio_import', $import_file, $terms, $batch_proc, $session_id);

module_invoke requires a valid module name as first parameter. all biblio modules are named using the convention biblio_FORMAT.

+++ modules/RIS/biblio_ris.install	14 Sep 2010 15:35:26 -0000
@@ -48,16 +48,20 @@ function biblio_ris_set_system_weight() 
-  db_query("INSERT INTO {biblio_type_maps} (format,type_map,type_names,field_map) VALUES ('%s','%s','%s','%s')",
-              array($maps['format'], $maps['type_map'], $maps['type_names'], $maps['field_map']));
-  //drupal_write_record('biblio_type_maps', $maps);
-
+  db_insert('biblio_type_maps')
+    ->fields(array(
+      'format' => $maps['format'],
+      'type_map' => $maps['type_map'],
+      'type_names' => $maps['type_names'],
+      'field_map' => $maps['field_map'],
+    ))
+    ->execute();

switched all .install _save_FORMAT_maps() to D7 database API.

+++ modules/crossref/biblio_crossref.module	14 Sep 2010 15:35:26 -0000
@@ -128,7 +128,7 @@ function biblio_crossref_node_insert($no
-  $result = db_query('SELECT  nid, biblio_crossref_id  FROM {biblio_crossref} WHERE nid IN(:nids)', array(':nid' => array_keys($nodes)));
+  $result = db_query('SELECT nid, biblio_crossref_id FROM {biblio_crossref} WHERE nid IN(:nids)', array(':nids' => array_keys($nodes)));

there was a typo in the placeholder.

+++ modules/endnote/biblio_tagged.module	14 Sep 2010 15:35:26 -0000
@@ -250,7 +250,9 @@ function _biblio_tagged_import($file, $t
-          $node->$field = $value;
+          if (isset($node->$field)) {
+            $node->$field = $value;
+          }

fix an access to empty attribute error.

+++ modules/endnote/biblio_xml.module	14 Sep 2010 15:35:26 -0000
@@ -117,8 +117,10 @@ function biblio_xml_node_delete($node) {
-  if ($node->type != 'biblio' || !isset($node->biblio_xml_md5)) return
-    drupal_write_record('biblio_xml', $node);
+  if ($node->type != 'biblio' || !isset($node->biblio_xml_md5)) {
+    return;
+  }
+  drupal_write_record('biblio_xml', $node);

This is where not following Drupal's coding standards can bite :( - drupal_write_record() was executed despite the return, and because it's missing ; right after the return.

+++ tests/import.export.test	14 Sep 2010 15:35:26 -0000
@@ -2,10 +2,8 @@
-    module_load_include('inc', 'biblio', 'biblio.type.mapper');

it seems biblio.type.mapper.inc does not exist and is no longer necessary.

+++ tests/import.export.test	14 Sep 2010 15:35:26 -0000
@@ -2,10 +2,8 @@
+    parent::setUp('biblio', 'biblio_ris', 'biblio_bibtex', 'biblio_tagged', 'biblio_xml', 'biblio_crossref');

we need all the modules to perform the tests

+++ tests/import.export.test	14 Sep 2010 15:35:26 -0000
@@ -35,15 +33,14 @@ class BiblioImportExportUnitTest extends
-    module_load_include('inc', 'biblio', 'endnote8_export');
+    module_load_include('inc', 'biblio_xml', 'endnote8_export');

the endnote8_export is located in the same folder as biblio_xml module.

+++ tests/import.export.test	14 Sep 2010 15:35:26 -0000
@@ -35,15 +33,14 @@ class BiblioImportExportUnitTest extends
-    $this->assertEqual(biblio_endnote_tagged_export($node), $this->getTaggedString());//, 'Export a node in EndNote Tagged format');
-    $this->assertEqual(biblio_bibtex_export($node), $this->getBibTexString(), 'Export a node in BibTex format');
+    $this->assertEqual(_biblio_tagged_export($node), $this->getTaggedString(), 'Export a node in EndNote Tagged format');
+    $this->assertEqual(_biblio_bibtex_export($node), $this->getBibTexString(), 'Export a node in BibTex format');

these functions were renamed it seems...

+++ tests/import.export.test	14 Sep 2010 15:35:26 -0000
@@ -53,7 +50,7 @@ class BiblioImportExportUnitTest extends
-    $fields = array_filter(biblio_get_field_map('endnote8'));
+    $fields = array_filter(biblio_get_map('field_map', 'endnote8'));

it seems all the old biblio_get_field_map etc were centralized in biblio_get_map().

Powered by Dreditor.

rjerome’s picture

Thanks,

I could have put the CVS comment "changed everything" but I thought that was about as useful as nothing :-P

BTW, I should also mention that (as you are obviously well aware) the 7.x-dev version is not yet a working entity but I wanted to get what I had into the repository so I could work on it from other locations.

Thanks for all the above pointers that will save some time.

Ron.

rjerome’s picture

Applied most of the patches in #6

except..

+++ modules/endnote/biblio_tagged.module 14 Sep 2010 15:35:26 -0000
@@ -250,7 +250,9 @@ function _biblio_tagged_import($file, $t
-          $node->$field = $value;
+          if (isset($node->$field)) {
+            $node->$field = $value;
+          }

Need to test this one a bit

+++ includes/biblio.import.export.inc 14 Sep 2010 15:35:26 -0000
@@ -353,7 +353,7 @@ function biblio_import($import_file, $ty
-      list($nids, $dups) = module_invoke($type, 'biblio_import', $import_file, $terms, $batch_proc, $session_id);
+      list($nids, $dups) = module_invoke('biblio_' . $type, 'biblio_import', $import_file, $terms, $batch_proc, $session_id);

$type is the module name already.

Cheers,

Ron.

liam morland’s picture

Issue summary: View changes
Status: Needs review » Fixed
Related issues: +#3030134: Make tests pass

Test run since #3030134: Make tests pass. Further improvements to testing is welcome.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.