-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fixed TemporaryIndex::updateEntry; ...
- added test for TemporaryIndex::updateEntry - renamed IndexEntry's (s)getLatestNtFile to (s)getLatestNtriplesFile - refined composer.json and MergeInManuallyMaintainedMetadata
- Loading branch information
Showing
11 changed files
with
423 additions
and
288 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
<?php | ||
|
||
namespace Tests; | ||
|
||
use App\IndexEntry; | ||
use App\TemporaryIndex; | ||
use Test\TestCase; | ||
|
||
class TemporaryIndexTest extends TestCase | ||
{ | ||
protected function setUp(): void | ||
{ | ||
parent::setUp(); | ||
|
||
if (file_exists(VAR_FOLDER_PATH.'test.db')) { | ||
unlink(VAR_FOLDER_PATH.'test.db'); | ||
} | ||
} | ||
|
||
public function testUpdateEntry(): void | ||
{ | ||
$subjectUnderTest = new TemporaryIndex(VAR_FOLDER_PATH.'test.db'); | ||
|
||
$newEntry = new IndexEntry('test1', 'test2'); | ||
$newEntry->setLatestJsonLdFile('http://localhost/test.ttl'); | ||
$newEntry->setOntologyIri('http://localhost/'); | ||
$newEntry->setOntologyTitle('test onto'); | ||
|
||
$subjectUnderTest->storeEntries([$newEntry]); | ||
|
||
// check that entry is in DB | ||
$this->assertTrue($subjectUnderTest->hasEntry($newEntry->getOntologyIri())); | ||
|
||
// update entry in the meantime | ||
$newEntry->setLicenseInformation('test license'); | ||
|
||
// update entry in DB | ||
$subjectUnderTest->updateEntry($newEntry); | ||
|
||
$entryArr = $subjectUnderTest->getEntryDataAsArray($newEntry->getOntologyIri()); | ||
|
||
$this->assertEquals($newEntry->getLicenseInformation(), $entryArr['license_information']); | ||
} | ||
|
||
public function testUpdateEntryKeepExistingValues(): void | ||
{ | ||
$subjectUnderTest = new TemporaryIndex(VAR_FOLDER_PATH.'test.db'); | ||
|
||
$newEntry = new IndexEntry('test1', 'test2'); | ||
$newEntry->setLatestJsonLdFile('http://localhost/test.ttl'); | ||
$newEntry->setOntologyIri('http://localhost/'); | ||
$newEntry->setOntologyTitle('test onto'); | ||
$newEntry->setVersion('test version'); | ||
|
||
$subjectUnderTest->storeEntries([$newEntry]); | ||
|
||
// check that entry is in DB | ||
$this->assertTrue($subjectUnderTest->hasEntry($newEntry->getOntologyIri())); | ||
|
||
// update entry in the meantime | ||
$newEntry->setVersion('CHANGED version'); | ||
|
||
// update entry in DB | ||
$subjectUnderTest->updateEntry($newEntry); | ||
|
||
$entryArr = $subjectUnderTest->getEntryDataAsArray($newEntry->getOntologyIri()); | ||
|
||
$this->assertEquals('test version', $entryArr['version']); | ||
} | ||
} |