Skip to content

Commit

Permalink
#1238 Tests for searches with slash char
Browse files Browse the repository at this point in the history
  • Loading branch information
j3nsch committed Jul 24, 2024
1 parent 8edba7e commit 9732adb
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions tests/modules/solrsearch/controllers/IndexControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@

use Opus\Common\CollectionRole;
use Opus\Common\Date;
use Opus\Common\Document;
use Opus\Common\DocumentInterface;
use Opus\Common\Identifier;
use Opus\Common\Model\ModelException;
Expand Down Expand Up @@ -87,6 +88,44 @@ public function testEmptySearch()
$this->assertNotContains('search_results', $this->getResponse()->getBody());
}

public function testSearchWithSlashInDoi()
{
$doc = $this->createTestDocument();
$doc->setServerState(Document::STATE_PUBLISHED);
$doc->addIdentifierDoi()->setValue('10.000/testDoi');
$docId = $doc->store();

$this->dispatch('/solrsearch/index/search/searchtype/simple/query/10.000%2FtestDoi');
$this->assertXpath('//div[contains(@class, "result_box")]');
$this->assertXpath('//div[contains(@class, "search_results")]');
$this->assertXpath("//a[contains(@href, 'docId/{$docId}')]");
}

public function testSearchWithSlash()
{
$doc = $this->createTestDocument();
$doc->setServerState(Document::STATE_PUBLISHED);
$doc->addTitleAbstract()->setValue('10/20')->setLanguage('eng');
$docId = $doc->store();

$this->dispatch('/solrsearch/index/search/start/0/rows/10/sortfield/score/sortorder/desc/searchtype/simple/query/10%2F20');
$this->assertXpath('//div[contains(@class, "result_box")]');
$this->assertXpath('//div[contains(@class, "search_results")]');
$this->assertXpath("//a[contains(@href, 'docId/{$docId}')]");
}

public function testSearchDispatchWithSlash()
{
$this->getRequest()
->setMethod('POST')
->setPost([
'searchtype' => 'simple',
'query' => '10%2F20',
]);
$this->dispatch('/solrsearch/dispatch');
$this->assertRedirect();
}

public function testLatestAction()
{
$this->doStandardControllerTest('/solrsearch/index/search/searchtype/latest', 'index', 'search');
Expand Down

0 comments on commit 9732adb

Please sign in to comment.