Skip to content

Commit

Permalink
Merge pull request #137 from oat-sa/fix/release-v1.16.2
Browse files Browse the repository at this point in the history
Fix/release v1.16.2
  • Loading branch information
gabrielfs7 authored Oct 21, 2024
2 parents e165c05 + 6ea0bf8 commit c0721f0
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 0 deletions.
20 changes: 20 additions & 0 deletions model/Index/Service/AdvancedSearchIndexDocumentBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ class AdvancedSearchIndexDocumentBuilder implements IndexDocumentBuilderInterfac
{
private const ASSETS_KEY = 'asset_uris';
private const TEST_KEY = 'test_uri';
private const PROPERTY_MARKING_TEST = 'http://www.tao.lu/Ontologies/TAOTest.rdf#TestTestModel';
private const PROPERTY_MARKING_ITEM = 'http://www.tao.lu/Ontologies/TAOItem.rdf#ItemModel';

private ElementReferencesExtractor $itemElementReferencesExtractor;
private QtiItemService $qtiItemService;
Expand Down Expand Up @@ -178,6 +180,14 @@ private function getResolverForResource(

private function isA(string $type, core_kernel_classes_Resource $resource): bool
{
if ($type === TaoOntology::CLASS_URI_TEST && $this->isTest($resource)) {
return true;
}

if ($type === TaoOntology::CLASS_URI_ITEM && $this->isItem($resource)) {
return true;
}

$rootClass = $resource->getClass($type);

foreach ($resource->getTypes() as $type) {
Expand All @@ -188,4 +198,14 @@ private function isA(string $type, core_kernel_classes_Resource $resource): bool

return false;
}

private function isTest(core_kernel_classes_Resource $resource): bool
{
return !!$resource->getOnePropertyValue($resource->getProperty(self::PROPERTY_MARKING_TEST));
}

private function isItem(core_kernel_classes_Resource $resource): bool
{
return !!$resource->getOnePropertyValue($resource->getProperty(self::PROPERTY_MARKING_ITEM));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,23 @@ private function mockResource(array $types): MockObject
[TaoOntology::CLASS_URI_OBJECT, $this->genericType],
]);

$testProp = new \core_kernel_classes_Property(TaoOntology::CLASS_URI_TEST);
$itemProp = new \core_kernel_classes_Property(TaoOntology::CLASS_URI_ITEM);
$anItem
->method('getProperty')
->willReturnMap([
['http://www.tao.lu/Ontologies/TAOTest.rdf#TestTestModel', $testProp],
['http://www.tao.lu/Ontologies/TAOItem.rdf#ItemModel', $itemProp],
]);

$anItem
->method('getOnePropertyValue')
->willReturnCallback(
function (\core_kernel_classes_Property $res) use ($types) {
return in_array($res->getUri(), $types);
}
);

return $anItem;
}

Expand Down

0 comments on commit c0721f0

Please sign in to comment.