MarcusBarnes / mik

The Move to Islandora Kit is an extensible PHP command-line tool for converting source content and metadata into packages suitable for importing into Islandora (or other digital repository and preservations systems).
GNU General Public License v3.0
34 stars 11 forks source link

CSV Compound coolchain PHPUnit test failure #418

Open whikloj opened 7 years ago

whikloj commented 7 years ago

Related to the commented out test in XCsvCompoundToolchainTest

I'm assuming that the test metadata record is wrong, but here is what I am seeing.

Here you start writing the packages

$writer->writePackages($mods, $pages, 'cpd2');

Once inside the CsvCompound writer, you get to here to write the individual metadata record for the children.

But this cache has already been written here and you are still using the $record_key of cpd2.

So the same metadata is used.

[/private/var/folders/w3/9tw0brpn0xg9gr2q6ct9zty80000gp/T/mik_csv_compound_temp_dir] 
> cat cpd2.metadata 
O:8:"stdClass":7:{s:10:"Identifier";s:4:"cpd2";s:5:"Child";s:0:"";s:9:"Directory";s:9:"compound2";s:5:"Title";s:22:"Second compound object";s:6:"Author";s:17:"Neuman, Alfred E.";s:16:"Publication Date";s:4:"1967";s:3:"key";s:4:"cpd2";}

So at line 156 you are checking

if (strlen($child_item_info->{$this->child_key})) {

where $this->child_key == "Child" and $child_item_info is

stdClass Object
(
    [Identifier] => cpd2
    [Child] => 
    [Directory] => compound2
    [Title] => Second compound object
    [Author] => Neuman, Alfred E.
    [Publication Date] => 1967
    [key] => cpd2
)

...and that is why your test fails. I'm not clear on how this is supposed to work, but (off the top of my head) it would seem like you need to determine there are children first then check for any metadata they have?

Like inside this for each loop do a getItemInfo() there to see if there is metadata.

But I'll leave this to you to work out.

mjordan commented 7 years ago

Thanks @whikloj I'll take a look.