Skip to content

Commit

Permalink
chore: fix unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
shpran committed Nov 15, 2024
1 parent c8f39ad commit e3906af
Showing 1 changed file with 50 additions and 36 deletions.
86 changes: 50 additions & 36 deletions tests/Unit/SearchEngine/Driver/Elasticsearch/QueryBuilderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -160,8 +160,8 @@ public function queryResultsWithAccessControl(): array
'\\"test\\" OR TextArea_custom_field:\\"test\\" OR ' .
'TextBox_custom_field:\\"test\\" OR ComboBox_custom_field:\\"test\\" ' .
'OR CheckBox_custom_field:\\"test\\" OR RadioBox_custom_field:\\"test\\" ' .
'OR SearchTextBox_custom_field:\\"test\\" OR SearchDropdown_custom_field:\\"test\\")' .
' AND (read_access:(\\"https:\\/\\/tao.docker.localhost\\/' .
'OR SearchTextBox_custom_field:\\"test\\" OR SearchDropdown_custom_field:\\"test\\" ' .
'OR Readonly_custom_field:\\"test\\") AND (read_access:(\\"https:\\/\\/tao.docker.localhost\\/' .
'ontologies\\/tao.rdf#i5f64514f1c36110793759fc28c0105b\\" OR \\"http:\\/\\/www.tao.lu\\/Ontologies\\/' .
'TAOItem.rdf#BackOfficeRole\\" OR ' .
'\\"http:\\/\\/www.tao.lu\\/Ontologies\\/TAOItem.rdf#ItemsManagerRole\\"))"}},' .
Expand All @@ -174,8 +174,8 @@ public function queryResultsWithAccessControl(): array
'(HTMLArea_custom_field:\\"test\\" OR TextArea_custom_field:\\"test\\" OR ' .
'TextBox_custom_field:\\"test\\" OR ComboBox_custom_field:\\"test\\"' .
' OR CheckBox_custom_field:\\"test\\" OR RadioBox_custom_field:\\"test\\" ' .
'OR SearchTextBox_custom_field:\\"test\\" OR SearchDropdown_custom_field:\\' .
'"test\\") AND (read_access:(\\"https:\\/\\/tao.docker.localhost\\/' .
'OR SearchTextBox_custom_field:\\"test\\" OR SearchDropdown_custom_field:\\"test\\" ' .
'OR Readonly_custom_field:\\"test\\") AND (read_access:(\\"https:\\/\\/tao.docker.localhost\\/' .
'ontologies\\/tao.rdf#i5f64514f1c36110793759fc28c0105b\\" OR ' .
'\\"http:\\/\\/www.tao.lu\\/Ontologies\\/TAOItem.rdf#BackOfficeRole\\" OR ' .
'\\"http:\\/\\/www.tao.lu\\/Ontologies\\/TAOItem.rdf#ItemsManagerRole\\"))"}},' .
Expand All @@ -191,8 +191,8 @@ public function queryResultsWithAccessControl(): array
'field:\"test\" OR ComboBox_custom field:\"test\" ' .
'OR CheckBox_custom field:\"test\" OR RadioBox_custom ' .
'field:\"test\" OR SearchTextBox_custom field:\"test\" ' .
'OR SearchDropdown_custom field:\"test\") AND ' .
'(read_access:(\"https:\/\/tao.docker.localhost\/ontologies\/tao.rdf' .
'OR SearchDropdown_custom field:\"test\" OR Readonly_custom field:\\"test\\")' .
' AND (read_access:(\"https:\/\/tao.docker.localhost\/ontologies\/tao.rdf' .
'#i5f64514f1c36110793759fc28c0105b\" OR ' .
'\"http:\/\/www.tao.lu\/Ontologies\/TAOItem.rdf#BackOfficeRole\" ' .
'OR \"http:\/\/www.tao.lu\/Ontologies\/TAOItem.rdf#ItemsManagerRole\"))"}},' .
Expand All @@ -207,7 +207,8 @@ public function queryResultsWithAccessControl(): array
'field:\\"test\\" OR TextBox_custom_field:\\"test\\" OR ' .
'ComboBox_custom_field:\\"test\\" OR CheckBox_custom_field:\\"test\\" OR RadioBox_' .
'custom_field:\\"test\\" OR SearchTextBox_custom_field:\\"test\\" ' .
'OR SearchDropdown_custom_field:\\"test\\") AND (read_access:(\\"https:\\/' .
'OR SearchDropdown_custom_field:\\"test\\" OR Readonly_custom_field:\\"test\\")' .
' AND (read_access:(\\"https:\\/' .
'\\/tao.docker.localhost\\/ontologies\\/tao.rdf#i5f64514f1c36110793759fc28c0105b\\"' .
' OR \\"http:\\/\\/www.tao.lu\\/Ontologies\\/TAOItem.rdf#' .
'BackOfficeRole\\" OR \\"http:\\/\\/www.tao.lu\\/Ontologies\\/TAOItem.rdf#ItemsManagerRole\\"))"}}' .
Expand All @@ -221,7 +222,8 @@ public function queryResultsWithAccessControl(): array
'(HTMLArea_custom_field:\"test\" OR TextArea_custom_field:\"test\" OR TextBox_custom_field:\"test\" ' .
'OR ComboBox_custom_field:\"test\" OR CheckBox_custom_field:\"test\" ' .
'OR RadioBox_custom_field:\"test\" ' .
'OR SearchTextBox_custom_field:\"test\" OR SearchDropdown_custom_field:\"test\") AND (read_access:' .
'OR SearchTextBox_custom_field:\"test\" OR SearchDropdown_custom_field:\"test\" ' .
'OR Readonly_custom_field:\"test\") AND (read_access:' .
'(\"https:\/\/tao.docker.localhost\/ontologies\/tao.rdf#i5f64514f1c36110793759fc28c0105b\" OR ' .
'\"http:\/\/www.tao.lu\/Ontologies\/TAOItem.rdf#BackOfficeRole\" OR ' .
'\"http:\/\/www.tao.lu\/Ontologies\/TAOItem.rdf#ItemsManagerRole\"))"}},' .
Expand All @@ -235,7 +237,8 @@ public function queryResultsWithAccessControl(): array
'(HTMLArea_custom_field:\"test\" OR TextArea_custom_field:\"test\" OR TextBox_custom_field:\"test\" ' .
'OR ComboBox_custom_field:\"test\" OR CheckBox_custom_field:\"test\"' .
' OR RadioBox_custom_field:\"test\" ' .
'OR SearchTextBox_custom_field:\"test\" OR SearchDropdown_custom_field:\"test\") AND (read_access:' .
'OR SearchTextBox_custom_field:\"test\" OR SearchDropdown_custom_field:\"test\" ' .
'OR Readonly_custom_field:\"test\") AND (read_access:' .
'(\"https:\/\/tao.docker.localhost\/ontologies\/tao.rdf#i5f64514f1c36110793759fc28c0105b\" OR ' .
'\"http:\/\/www.tao.lu\/Ontologies\/TAOItem.rdf#BackOfficeRole\" OR ' .
'\"http:\/\/www.tao.lu\/Ontologies\/TAOItem.rdf#ItemsManagerRole\"))"}},' .
Expand All @@ -249,12 +252,14 @@ public function queryResultsWithAccessControl(): array
'((HTMLArea_custom_field:\"test\" OR TextArea_custom_field:\"test\" OR TextBox_custom_field:\"test\" ' .
'OR ComboBox_custom_field:\"test\" OR CheckBox_custom_field:\"test\" ' .
'OR RadioBox_custom_field:\"test\" ' .
'OR SearchTextBox_custom_field:\"test\" OR SearchDropdown_custom_field:\"test\") ' .
'OR SearchTextBox_custom_field:\"test\" OR SearchDropdown_custom_field:\"test\" ' .
'OR Readonly_custom_field:\"test\") ' .
'OR (HTMLArea_custom_field:\"test1\" OR TextArea_custom_field:\"test1\" ' .
'OR TextBox_custom_field:\"test1\" ' .
'OR ComboBox_custom_field:\"test1\" OR CheckBox_custom_field:\"test1\"' .
' OR RadioBox_custom_field:\"test1\" ' .
'OR SearchTextBox_custom_field:\"test1\" OR SearchDropdown_custom_field:\"test1\")) AND (read_access:' .
'OR SearchTextBox_custom_field:\"test1\" OR SearchDropdown_custom_field:\"test1\" ' .
'OR Readonly_custom_field:\"test1\")) AND (read_access:' .
'(\"https:\/\/tao.docker.localhost\/ontologies\/tao.rdf#i5f64514f1c36110793759fc28c0105b\" OR ' .
'\"http:\/\/www.tao.lu\/Ontologies\/TAOItem.rdf#BackOfficeRole\" OR ' .
'\"http:\/\/www.tao.lu\/Ontologies\/TAOItem.rdf#ItemsManagerRole\"))"}},"sort":{"_id":' .
Expand All @@ -267,12 +272,14 @@ public function queryResultsWithAccessControl(): array
'((HTMLArea_custom_field:\"test\" OR TextArea_custom_field:\"test\" OR TextBox_custom_field:\"test\" ' .
'OR ComboBox_custom_field:\"test\" OR CheckBox_custom_field:\"test\" ' .
'OR RadioBox_custom_field:\"test\" ' .
'OR SearchTextBox_custom_field:\"test\" OR SearchDropdown_custom_field:\"test\") ' .
'OR SearchTextBox_custom_field:\"test\" OR SearchDropdown_custom_field:\"test\" ' .
'OR Readonly_custom_field:\"test\") ' .
'AND (HTMLArea_custom_field:\"test1\" OR TextArea_custom_field:\"test1\" ' .
'OR TextBox_custom_field:\"test1\" ' .
'OR ComboBox_custom_field:\"test1\" OR CheckBox_custom_field:\"test1\"' .
' OR RadioBox_custom_field:\"test1\" ' .
'OR SearchTextBox_custom_field:\"test1\" OR SearchDropdown_custom_field:\"test1\")) AND (read_access:' .
'OR SearchTextBox_custom_field:\"test1\" OR SearchDropdown_custom_field:\"test1\" ' .
'OR Readonly_custom_field:\"test1\")) AND (read_access:' .
'(\"https:\/\/tao.docker.localhost\/ontologies\/tao.rdf#i5f64514f1c36110793759fc28c0105b\" OR ' .
'\"http:\/\/www.tao.lu\/Ontologies\/TAOItem.rdf#BackOfficeRole\" OR ' .
'\"http:\/\/www.tao.lu\/Ontologies\/TAOItem.rdf#ItemsManagerRole\"))"}},"sort":{"_id":' .
Expand All @@ -287,12 +294,13 @@ public function queryResultsWithAccessControl(): array
'OR ComboBox_custom_field:\"test\" OR CheckBox_custom_field:\"test\" ' .
'OR RadioBox_custom_field:\"test\" ' .
'OR SearchTextBox_custom_field:\"test\" ' .
'OR SearchDropdown_custom_field:\"test\") ' .
'OR SearchDropdown_custom_field:\"test\" OR Readonly_custom_field:\"test\") ' .
'OR (HTMLArea_custom_field:\"test1\" OR TextArea_custom_field:\"test1\" ' .
'OR TextBox_custom_field:\"test1\" ' .
'OR ComboBox_custom_field:\"test1\" OR CheckBox_custom_field:\"test1\"' .
' OR RadioBox_custom_field:\"test1\" ' .
'OR SearchTextBox_custom_field:\"test1\" OR SearchDropdown_custom_field:\"test1\")) AND (read_access:' .
'OR SearchTextBox_custom_field:\"test1\" OR SearchDropdown_custom_field:\"test1\" ' .
'OR Readonly_custom_field:\"test1\")) AND (read_access:' .
'(\"https:\/\/tao.docker.localhost\/ontologies\/tao.rdf#i5f64514f1c36110793759fc28c0105b\" OR ' .
'\"http:\/\/www.tao.lu\/Ontologies\/TAOItem.rdf#BackOfficeRole\" OR ' .
'\"http:\/\/www.tao.lu\/Ontologies\/TAOItem.rdf#ItemsManagerRole\"))"}},"sort":{"_id":' .
Expand Down Expand Up @@ -391,7 +399,7 @@ public function queryResultsWithoutAccessControl(): array
':\"test\" OR ComboBox_custom_field:\"test\" ' .
'OR CheckBox_custom_field:\"test\" OR RadioBox_custom_field:' .
'\"test\" OR SearchTextBox_custom_field:\"test\" ' .
'OR SearchDropdown_custom_field:\"test\")"}},' .
'OR SearchDropdown_custom_field:\"test\" OR Readonly_custom_field:\"test\")"}},' .
'"sort":{"_id":{"order":"DESC","missing":"_last",' .
'"unmapped_type":"long"},"label.raw":{"order":' .
'"DESC","missing":"_last","unmapped_type":"long"}}}'
Expand All @@ -401,8 +409,8 @@ public function queryResultsWithoutAccessControl(): array
'{"query":{"query_string":{"default_operator":"AND","query":"(HTMLArea_custom_field:\"test\" OR ' .
'TextArea_custom_field:\"test\" OR TextBox_custom_field:\"test\" OR ComboBox_custom_field:\"test\" ' .
'OR CheckBox_custom_field:\"test\" OR RadioBox_custom_field:' .
'\"test\" OR SearchTextBox_custom_field:\"test\" ' .
'OR SearchDropdown_custom_field:\"test\")"}},"sort":{"_id":{"order":"DESC","missing":"_last",' .
'\"test\" OR SearchTextBox_custom_field:\"test\" OR SearchDropdown_custom_field:\"test\" ' .
'OR Readonly_custom_field:\"test\")"}},"sort":{"_id":{"order":"DESC","missing":"_last",' .
'"unmapped_type":"long"},"label.raw":{"order":"DESC","missing":"_last","unmapped_type":"long"}}}'
],
'Query custom field (using space)' => [
Expand All @@ -411,34 +419,37 @@ public function queryResultsWithoutAccessControl(): array
'field:\"test\" OR TextArea_custom field:\"test\" OR TextBox_custom field:\"test\" ' .
'OR ComboBox_custom field:\"test\" OR CheckBox_custom field:\"test\" OR RadioBox_custom ' .
'field:\"test\" OR SearchTextBox_custom field:\"test\" OR SearchDropdown_custom field:' .
'\"test\")"}},"sort":{"_id":{"order":"DESC","missing":"_last","unmapped_type":"long"},' .
'"label.raw":{"order":"DESC","missing":"_last","unmapped_type":"long"}}}',
'\"test\" OR Readonly_custom field:\"test\")"}},"sort":{"_id":{"order":"DESC","missing":"_last",' .
'"unmapped_type":"long"},"label.raw":{"order":"DESC","missing":"_last","unmapped_type":"long"}}}',
],
'Query logic operator (Uppercase)' => [
'label:test AND custom_field:test',
'{"query":{"query_string":{"default_operator":"AND","query":"(label:\"test\") ' .
'AND (HTMLArea_custom_field:\"test\" OR TextArea_custom_field:\"test\" OR ' .
'TextBox_custom_field:\"test\" OR ComboBox_custom_field:\"test\" OR CheckBox_custom_field:' .
'\"test\" OR RadioBox_custom_field:\"test\" OR SearchTextBox_custom_field:\"test\" OR ' .
'SearchDropdown_custom_field:\"test\")"}},"sort":{"_id":{"order":"DESC","missing":"_last"' .
',"unmapped_type":"long"},"label.raw":{"order":"DESC","missing":"_last","unmapped_type":"long"}}}',
'SearchDropdown_custom_field:\"test\" OR Readonly_custom_field:\"test\")"}},"sort":{"_id":{"order":' .
'"DESC","missing":"_last","unmapped_type":"long"},"label.raw":{"order":"DESC","missing":"_last",' .
'"unmapped_type":"long"}}}',
],
'Query logic operator (Lowercase)' => [
'label:test and custom_field:test',
'{"query":{"query_string":{"default_operator":"AND","query":"(label:\"test\") AND ' .
'(HTMLArea_custom_field:\"test\" OR TextArea_custom_field:\"test\" OR TextBox_custom_field:' .
'\"test\" OR ComboBox_custom_field:\"test\" OR CheckBox_custom_field:\"test\" OR ' .
'RadioBox_custom_field:\"test\" OR SearchTextBox_custom_field:\"test\" OR ' .
'SearchDropdown_custom_field:\"test\")"}},"sort":{"_id":{"order":"DESC","missing":"_last",' .
'"unmapped_type":"long"},"label.raw":{"order":"DESC","missing":"_last","unmapped_type":"long"}}}',
'SearchDropdown_custom_field:\"test\" OR Readonly_custom_field:\"test\")"}},"sort":{"_id":{"order":' .
'"DESC","missing":"_last","unmapped_type":"long"},"label.raw":{"order":"DESC","missing":"_last",' .
'"unmapped_type":"long"}}}',
],
'Query logic operator (Mixed)' => [
'label:test aNd custom_field:test',
'{"query":{"query_string":{"default_operator":"AND","query":"(label:\"test\") AND ' .
'(HTMLArea_custom_field:\"test\" OR TextArea_custom_field:\"test\" OR TextBox_custom_field:\"test\" ' .
'OR ComboBox_custom_field:\"test\" OR CheckBox_custom_field:\"test\"' .
' OR RadioBox_custom_field:\"test\" ' .
'OR SearchTextBox_custom_field:\"test\" OR SearchDropdown_custom_field:\"test\")"}},"sort":{"_id":' .
'OR SearchTextBox_custom_field:\"test\" OR SearchDropdown_custom_field:\"test\" ' .
'OR Readonly_custom_field:\"test\")"}},"sort":{"_id":' .
'{"order":"DESC","missing":"_last","unmapped_type":"long"},"label.raw":{"order":"DESC","missing"' .
':"_last","unmapped_type":"long"}}}',
],
Expand All @@ -448,12 +459,12 @@ public function queryResultsWithoutAccessControl(): array
'((HTMLArea_custom_field:\"test\" OR TextArea_custom_field:\"test\" OR TextBox_custom_field:\"test\" ' .
'OR ComboBox_custom_field:\"test\" OR CheckBox_custom_field:\"test\" ' .
'OR RadioBox_custom_field:\"test\" ' .
'OR SearchTextBox_custom_field:\"test\" OR SearchDropdown_custom_field:\"test\") ' .
'OR (HTMLArea_custom_field:\"test1\" OR TextArea_custom_field:\"test1\" ' .
'OR TextBox_custom_field:\"test1\" ' .
'OR SearchTextBox_custom_field:\"test\" OR SearchDropdown_custom_field:\"test\" ' .
'OR Readonly_custom_field:\"test\") OR (HTMLArea_custom_field:\"test1\" ' .
'OR TextArea_custom_field:\"test1\" OR TextBox_custom_field:\"test1\" ' .
'OR ComboBox_custom_field:\"test1\" OR CheckBox_custom_field:\"test1\"' .
' OR RadioBox_custom_field:\"test1\" ' .
'OR SearchTextBox_custom_field:\"test1\" OR SearchDropdown_custom_field:\"test1\"))"}},"sort":{"_id":' .
' OR RadioBox_custom_field:\"test1\" OR SearchTextBox_custom_field:\"test1\" ' .
'OR SearchDropdown_custom_field:\"test1\" OR Readonly_custom_field:\"test1\"))"}},"sort":{"_id":' .
'{"order":"DESC","missing":"_last","unmapped_type":"long"},"label.raw":{"order":"DESC","missing"' .
':"_last","unmapped_type":"long"}}}',
],
Expand All @@ -463,12 +474,14 @@ public function queryResultsWithoutAccessControl(): array
'((HTMLArea_custom_field:\"test\" OR TextArea_custom_field:\"test\" OR TextBox_custom_field:\"test\" ' .
'OR ComboBox_custom_field:\"test\" OR CheckBox_custom_field:\"test\" ' .
'OR RadioBox_custom_field:\"test\" ' .
'OR SearchTextBox_custom_field:\"test\" OR SearchDropdown_custom_field:\"test\") ' .
'OR SearchTextBox_custom_field:\"test\" OR SearchDropdown_custom_field:\"test\" ' .
'OR Readonly_custom_field:\"test\") ' .
'AND (HTMLArea_custom_field:\"test1\" OR TextArea_custom_field:\"test1\" ' .
'OR TextBox_custom_field:\"test1\" ' .
'OR ComboBox_custom_field:\"test1\" OR CheckBox_custom_field:\"test1\"' .
' OR RadioBox_custom_field:\"test1\" ' .
'OR SearchTextBox_custom_field:\"test1\" OR SearchDropdown_custom_field:\"test1\"))"}},"sort":{"_id":' .
'OR SearchTextBox_custom_field:\"test1\" OR SearchDropdown_custom_field:\"test1\" ' .
'OR Readonly_custom_field:\"test1\"))"}},"sort":{"_id":' .
'{"order":"DESC","missing":"_last","unmapped_type":"long"},"label.raw":{"order":"DESC","missing"' .
':"_last","unmapped_type":"long"}}}',
],
Expand All @@ -479,12 +492,13 @@ public function queryResultsWithoutAccessControl(): array
'OR TextBox_custom_field:\"test\" ' .
'OR ComboBox_custom_field:\"test\" OR CheckBox_custom_field:\"test\" ' .
'OR RadioBox_custom_field:\"test\" ' .
'OR SearchTextBox_custom_field:\"test\" OR SearchDropdown_custom_field:\"test\") ' .
'OR (HTMLArea_custom_field:\"test1\" OR TextArea_custom_field:\"test1\" ' .
'OR TextBox_custom_field:\"test1\" ' .
'OR SearchTextBox_custom_field:\"test\" OR SearchDropdown_custom_field:\"test\" ' .
'OR Readonly_custom_field:\"test\") OR (HTMLArea_custom_field:\"test1\" ' .
'OR TextArea_custom_field:\"test1\" OR TextBox_custom_field:\"test1\" ' .
'OR ComboBox_custom_field:\"test1\" OR CheckBox_custom_field:\"test1\"' .
' OR RadioBox_custom_field:\"test1\" ' .
'OR SearchTextBox_custom_field:\"test1\" OR SearchDropdown_custom_field:\"test1\"))"}},"sort":{"_id":' .
'OR SearchTextBox_custom_field:\"test1\" OR SearchDropdown_custom_field:\"test1\" ' .
'OR Readonly_custom_field:\"test1\"))"}},"sort":{"_id":' .
'{"order":"DESC","missing":"_last","unmapped_type":"long"},"label.raw":{"order":"DESC","missing"' .
':"_last","unmapped_type":"long"}}}',
],
Expand Down

0 comments on commit e3906af

Please sign in to comment.