From c9472b1a41dbc3fcdb2499c5f7a46a4e44f2bc64 Mon Sep 17 00:00:00 2001 From: j3nsch Date: Fri, 12 Apr 2024 17:37:35 +0200 Subject: [PATCH] #1196 Reactivated tests; Merge tests using @dataProvider --- .../controller/IndexControllerTest.php | 98 ++++++------------- 1 file changed, 30 insertions(+), 68 deletions(-) diff --git a/tests/modules/citationExport/controller/IndexControllerTest.php b/tests/modules/citationExport/controller/IndexControllerTest.php index dc2947ae8..1cd01cfb0 100644 --- a/tests/modules/citationExport/controller/IndexControllerTest.php +++ b/tests/modules/citationExport/controller/IndexControllerTest.php @@ -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() @@ -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); } /**