Skip to content

Commit

Permalink
Loss of potential RELS-INT statements when the RELS-INT does not exist (
Browse files Browse the repository at this point in the history
#162)

* Add tests that show errors with RELS-INT.

* Fix RELS-INT, mark incomplete other bug in ISLANDORA-2068.

* Actually mark the test incomplete.
  • Loading branch information
jordandukart authored and DiegoPino committed Sep 26, 2017
1 parent 5f04099 commit f4f9d7e
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 0 deletions.
3 changes: 3 additions & 0 deletions FedoraRelationships.php
Original file line number Diff line number Diff line change
Expand Up @@ -799,6 +799,9 @@ public function add($predicate_uri, $predicate, $object, $type = RELS_TYPE_URI)
* TRUE if relationships were removed, FALSE otherwise.
*/
public function remove($predicate_uri = NULL, $predicate = NULL, $object = NULL, $type = RELS_TYPE_URI) {
if (!isset($this->aboutDs->parent['RELS-INT'])) {
return FALSE;
}
$this->initializeDatastream();
$return = parent::internalRemove("{$this->aboutDs->parent->id}/{$this->aboutDs->id}", $predicate_uri, $predicate, $object, $type);

Expand Down
34 changes: 34 additions & 0 deletions tests/FedoraRelationshipsInternalTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,4 +89,38 @@ function testNullPredicateURI() {
function testPurge() {
$this->assertTrue($this->object->purgeDatastream('RELS-INT'));
}

function testMultipleWritesWhenPurging() {
$this->markTestIncomplete('This is a current bug that needs to be addressed in ISLANDORA-2068.');
$this->object->purgeDatastream('RELS-INT');
$this->object->ingestDatastream($this->datastream);
$this->object->ingestDatastream($this->datastream2);

$this->datastream->relationships->remove(ISLANDORA_RELS_INT_URI, 'whargarbl');
$this->datastream2->relationships->remove(ISLANDORA_RELS_INT_URI, 'omnomnom');

$this->datastream->relationships->add(ISLANDORA_RELS_INT_URI, 'isWhargarbl', 'whargarbl', TRUE);
$this->datastream2->relationships->add(ISLANDORA_RELS_INT_URI, 'isOmNom', 'omnom', TRUE);
$this->assertEquals(1, count($this->datastream->relationships->get(ISLANDORA_RELS_INT_URI, 'isWhargarbl')));
$this->assertEquals(1, count($this->datastream->relationships->get(ISLANDORA_RELS_INT_URI, 'isOmNom')));
}

function testMultipleWritesWithoutPurging() {
$connection = new RepositoryConnection(FEDORAURL, FEDORAUSER, FEDORAPASS);
$this->api = new FedoraApi($connection);
$cache = new SimpleCache();
$repository = new FedoraRepository($this->api, $cache);
$object = $repository->constructObject('om:nom');
$ds = $object->constructDatastream('om');
$ds2 = $object->constructDatastream('nom');

$ds->relationships->remove(ISLANDORA_RELS_INT_URI, 'whargarbl');
$ds2->relationships->remove(ISLANDORA_RELS_INT_URI, 'omnomnom');

$ds->relationships->add(ISLANDORA_RELS_INT_URI, 'isWhargarbl', 'whargarbl', TRUE);
$ds2->relationships->add(ISLANDORA_RELS_INT_URI, 'isOmNom', 'omnom', TRUE);
$this->assertEquals(1, count($ds->relationships->get(ISLANDORA_RELS_INT_URI, 'isWhargarbl')));
$this->assertEquals(1, count($ds2->relationships->get(ISLANDORA_RELS_INT_URI, 'isOmNom')));
}

}

0 comments on commit f4f9d7e

Please sign in to comment.