From e3906af5cf53652685a3e6bf336b4518d04b8636 Mon Sep 17 00:00:00 2001 From: Andrei Shapiro Date: Fri, 15 Nov 2024 09:57:20 +0300 Subject: [PATCH] chore: fix unit tests --- .../Driver/Elasticsearch/QueryBuilderTest.php | 86 +++++++++++-------- 1 file changed, 50 insertions(+), 36 deletions(-) diff --git a/tests/Unit/SearchEngine/Driver/Elasticsearch/QueryBuilderTest.php b/tests/Unit/SearchEngine/Driver/Elasticsearch/QueryBuilderTest.php index 7f91541..ac16f78 100644 --- a/tests/Unit/SearchEngine/Driver/Elasticsearch/QueryBuilderTest.php +++ b/tests/Unit/SearchEngine/Driver/Elasticsearch/QueryBuilderTest.php @@ -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\\"))"}},' . @@ -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\\"))"}},' . @@ -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\"))"}},' . @@ -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\\"))"}}' . @@ -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\"))"}},' . @@ -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\"))"}},' . @@ -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":' . @@ -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":' . @@ -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":' . @@ -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"}}}' @@ -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)' => [ @@ -411,8 +419,8 @@ 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', @@ -420,8 +428,9 @@ public function queryResultsWithoutAccessControl(): array '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', @@ -429,8 +438,9 @@ 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\")"}},"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', @@ -438,7 +448,8 @@ 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\")"}},"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"}}}', ], @@ -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"}}}', ], @@ -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"}}}', ], @@ -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"}}}', ],