/** * Tests, that the sortfields in browsing are still working. * see Opusvier-3334. */ public function testSortOrderOfDocumentsInBrowsingWithSortfield() { $olderDoc = $this->createTestDocument(); $olderDoc->setServerState('published'); $olderDoc->setLanguage('eng'); $date = new Opus_Date(); $date->setNow(); $date->setDay($date->getDay() - 1); $olderDoc->setServerDatePublished($date); $olderDoc->setType('article'); $title = new Opus_Title(); $title->setValue('zzzOlderDoc'); // 'zzz' to show the document at the first page $title->setLanguage('eng'); $olderDoc->addTitleMain($title); $olderDocId = $olderDoc->store(); $newerDoc = $this->createTestDocument(); $newerDoc->setServerState('published'); $newerDoc->setLanguage('eng'); $newerDoc->setType('article'); $title = new Opus_Title(); $title->setValue('zzzNewerDoc'); $title->setLanguage('eng'); $newerDoc->addTitleMain($title); $newerDocId = $newerDoc->store(); $this->dispatch('/solrsearch/index/search/searchtype/simple/query/*%3A*/browsing/true/doctypefq/article/sortfield/title/sortorder/desc'); $responseBody = $this->getResponse()->getBody(); preg_match("\$/frontdoor/index/index.*/docId/{$olderDocId}\$", $responseBody, $matches, PREG_OFFSET_CAPTURE); $this->assertNotEmpty($matches, "Document {$olderDocId} not found!"); $olderDocPosition = $matches[0][1]; preg_match("\$/frontdoor/index/index.*/docId/{$newerDocId}\$", $responseBody, $matches, PREG_OFFSET_CAPTURE); $this->assertNotEmpty($matches, "Document {$newerDocId} not found!"); $newerDocPosition = $matches[0][1]; $this->assertTrue($newerDocPosition > $olderDocPosition, "Documents are not sorted by sortfield (title)."); }