~~NOCACHE~~
====== Tests: Loki ASK Queries ======
* //Delete ''lib/plugins/loki/temp/loki/tests/loki-ask.txt'' file before tests//
* Tests are performed manually - you have to compare if sections "Expected result" and "Actual result" represent the same thing!
===== Standard table results =====
**Description:** Simple table with results and additional headers. All elements in ''querytest'' category are shown.
**Code:**
{{#ask: [[category:querytest]] |
?test_title=Title |
?test_year=Year |
?test_lang |
?test_location |
?test_length |
?test_other_page |
default=No results! |
mainlabel=Main label |
intro=Text before results |
outro=Text after results
}}
**Expected result:**
Text before results
^ Main label ^ [[special:attribute:test_title|Title]] ^ [[special:attribute:test_year|Year]] ^ [[special:attribute:test_lang|Test_lang]] ^ [[special:attribute:test_location|Test_location]] ^ [[special:attribute:test_length|Test_length]] ^ [[special:relation:test_other_page|Test_other_page]] ^
| [[.:page1]] | Długi tytuł testowy | 2015 | english polish | | 100 | [[.:page2]] |
| [[.:page2]] | | 1900 | | internet | 140 | [[.:nonexisting-page]] \\ [[.:page1]] |
| [[.:page3]] | Krzysztof Trzeci Kutt homepage | 2013 \\ 2016 | | | 123 \\ 124 | [[.:ask]] \\ [[.:sparql]] |
| [[.:page4]] | Lorem Ipsum! | 1410 | latin | Wszędzie | 666 | |
| [[.:page5]] | Pięć Cztery Trzy Dwa Jeden | 1633 | latin | Kraków \\ Moskwa | 1234 | |
| [[.:page6]] | I jeszcze jeden test | 1999 | polish | Kraków | abc | |
| [[.:page7]] | Miejsce na twoją reklamę | dzisiaj | english | internet | 1 | [[.:page1]] |
Text after results
**Actual result:**
{{#ask: [[category:querytest]] |
?test_title=Title |
?test_year=Year |
?test_lang |
?test_location |
?test_length |
?test_other_page |
default=No results! |
mainlabel=Main label |
intro=Text before results |
outro=Text after results
}}
===== Results as a list =====
**Description:** Results as a enumeration + ''AND'' and ''OR'' conjunctions used in query. Query lists all pages which have ''test_length'' equal 1 or 123.
**Code:**
{{#ask: [[category:querytest]] [[test_length:=1||123]] |
?test_title=Title |
?test_lang |
?test_length |
default=No results! |
format=ol
}}
**Expected result:**
Nazwy stron i nazwy atrybutów powinny być linkami (nazwy stron do istniejących stron, nazwy atrybutów do nieistniejących stron tych atrybutów)
- [[.:page3|page3]] ([[special:attribute:test_title|Title]] Krzysztof Trzeci Kutt homepage, [[special:attribute:test_lang|Test_lang]] , [[special:attribute:test_length|Test_length]] 123, 124, )
- [[.:page7|page7]] ([[special:attribute:test_title|Title]] Miejsce na twoją reklamę, [[special:attribute:test_lang|Test_lang]] english, [[special:attribute:test_length|Test_length]] 1, )
**Test:**
{{#ask: [[category:querytest]] [[test_length:=1||123]] |
?test_title=Title |
?test_lang |
?test_length |
default=No results! |
format=ol
}}
===== Subqueries =====
**Opis:** Subqueries + result as a row count. Subquery returns pages which have ''test_lang'' equal to english -> page1 and page7. Next, "external" query returns pages that have ''test_other_page'' set to found pages page1 or page7 -> page2 and page7. Result is displayed as a row count -> 2.
**Code:**
{{#ask: [[category:querytest]] [[test_other_page::[[category:querytest]] [[test_lang:=english]]
]] |
?test_title=Title |
?test_lang |
?test_length |
default=No results! |
format=count
}}
**Expected result:**
2
**Actual result:**
{{#ask: [[category:querytest]] [[test_other_page::[[category:querytest]] [[test_lang:=english]]
]] |
?test_title=Title |
?test_lang |
?test_length |
default=No results! |
format=count
}}
===== Partial tables =====
**Opis:** Row sort (lexically, 100 is before 2) + partial table using ''offset'' and ''limit''; here results consist of 7 rows; we simulate showing 2nd page, with 3 results on each (so, we show rows 4-6) + links not placed in results
**Code:**
{{#ask: [[category:querytest]] |
?test_title=Title |
?test_length |
?test_other_page |
default=No results! |
sort=test_length |
link=none |
limit=3 |
offset=4
}}
**Expected result:**
^ ^ [[special:attribute:test_title|Title]] ^ [[special:attribute:test_length|Test_length]] ^ [[special:relation:test_other_page|Test_other_page]] ^
| tests:loki-queries:page2 | | 140 | tests:loki-queries:nonexist-page \\ tests:loki-queries:page1 |
| tests:loki-queries:page4 | Lorem Ipsum! | 666 |
| tests:loki-queries:page5 | Pięć Cztery Trzy Dwa Jeden | 1234 |
**Actual result:**
{{#ask: [[category:querytest]] |
?test_title=Title |
?test_length |
?test_other_page |
default=No results! |
sort=test_length |
link=none |
limit=3 |
offset=4
}}