Skip to content

Commit

Permalink
#1196 Reactivated tests; Merge tests using @dataProvider
Browse files Browse the repository at this point in the history
  • Loading branch information
j3nsch committed Apr 12, 2024
1 parent 43208d7 commit c9472b1
Showing 1 changed file with 30 additions and 68 deletions.
98 changes: 30 additions & 68 deletions tests/modules/citationExport/controller/IndexControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -150,16 +150,11 @@ public function testIndexActionWithUnpublishedDocument()

public function testIndexActionRis()
{
$this->markTestSkipped('Frontdoor URL is no longer exported');
$this->dispatch('/citationExport/index/index/output/ris/docId/' . $this->documentId);
$this->assertResponseCode(200);
$response = $this->getResponse();
$this->assertContains('UR - ', $response->getBody());
$this->assertContains('/frontdoor/index/index/docId/' . $this->documentId, $response->getBody());
$this->assertContains(
'/citationExport/index/download/output/ris/docId/' . $this->documentId,
$response->getBody()
);
$body = $this->getResponse()->getBody();
$this->assertContains('TY - GEN', $body);
$this->assertContains('U1 - Sonstiges', $body);
}

public function testIndexActionRisDoctypeArticle()
Expand Down Expand Up @@ -546,75 +541,42 @@ public function testDownloadActionWithUnpublishedDocument()

public function testDownloadActionRis()
{
$this->markTestSkipped('Frontdoor URL is no longer exported');
$this->dispatch('/citationExport/index/download/output/ris/docId/' . $this->documentId);
$this->assertResponseCode(200);
$response = $this->getResponse();
$this->assertContains('UR - ', $response->getBody());
$this->assertContains('/frontdoor/index/index/docId/' . $this->documentId, $response->getBody());
}

public function testDownloadActionBibtexDoctypeArticle()
{
$this->setDocumentType('article');
$this->dispatch('/citationExport/index/download/output/bibtex/docId/' . $this->documentId);
$this->checkBibtexAssertions('@article', false);
}

public function testDownloadActionBibtexDoctypeBook()
{
$this->setDocumentType('book');
$this->dispatch('/citationExport/index/download/output/bibtex/docId/' . $this->documentId);
$this->checkBibtexAssertions('@book', false);
}

public function testDownloadActionBibtexDoctypeBookpart()
{
$this->setDocumentType('bookpart');
$this->dispatch('/citationExport/index/download/output/bibtex/docId/' . $this->documentId);
$this->checkBibtexAssertions('@incollection', false);
}

public function testDownloadActionBibtexDoctypeConferenceobject()
{
$this->setDocumentType('conferenceobject');
$this->dispatch('/citationExport/index/download/output/bibtex/docId/' . $this->documentId);
$this->checkBibtexAssertions('@inproceedings', false);
$body = $this->getResponse()->getBody();
$this->assertContains('TY - GEN', $body);
$this->assertContains('U1 - Sonstiges', $body);
}

public function testDownloadActionBibtexDoctypeDoctoralthesis()
{
$this->setDocumentType('doctoralthesis');
$this->dispatch('/citationExport/index/download/output/bibtex/docId/' . $this->documentId);
$this->checkBibtexAssertions('@phdthesis', false);
}

public function testDownloadActionBibtexDoctypeMasterthesis()
{
$this->setDocumentType('masterthesis');
$this->dispatch('/citationExport/index/download/output/bibtex/docId/' . $this->documentId);
$this->checkBibtexAssertions('@mastersthesis', false);
}

public function testDownloadActionBibtexDoctypePreprint()
{
$this->setDocumentType('preprint');
$this->dispatch('/citationExport/index/download/output/bibtex/docId/' . $this->documentId);
$this->checkBibtexAssertions('@unpublished', false);
}

public function testDownloadActionBibtexDoctypeReport()
/**
* @return array[]
*/
public function bibtexDoctypeDataProvider()
{
$this->setDocumentType('report');
$this->dispatch('/citationExport/index/download/output/bibtex/docId/' . $this->documentId);
$this->checkBibtexAssertions('@techreport', false);
return [
['article', '@article'],
['book', '@book'],
['bookpart', '@incollection'],
['conferenceobject', '@inproceedings'],
['doctoralthesis', '@phdthesis'],
['masterthesis', '@mastersthesis'],
['preprint', '@unpublished'],
['report', '@techreport'],
['foo', '@misc'],
];
}

public function testDownloadActionBibtexMisc()
/**
* @param string $docType
* @param string $bibtexType
* @throws NotFoundException
* @dataProvider bibtexDoctypeDataProvider
*/
public function testDownloadActionBibtexDoctype($docType, $bibtexType)
{
$this->setDocumentType('foo');
$this->setDocumentType($docType);
$this->dispatch('/citationExport/index/download/output/bibtex/docId/' . $this->documentId);
$this->checkBibtexAssertions('@misc', false);
$this->checkBibtexAssertions($bibtexType, false);
}

/**
Expand Down

0 comments on commit c9472b1

Please sign in to comment.