public function testGetModel() { $form = new Admin_Form_Document_Institute(Admin_Form_Document_Institute::ROLE_PUBLISHER); $doc = new Opus_Document(146); $publishers = $doc->getThesisPublisher(); $publisher = $publishers[0]; $publisherId = $publisher->getModel()->getId(); $form->getElement('Id')->setValue($doc->getId()); $form->getElement('Institute')->setValue($publisherId); $model = $form->getModel(); $modelId = $model->getId(); $this->assertNotNull($model); $this->assertNotNull($modelId); $this->assertEquals($doc->getId(), $modelId[0]); $this->assertEquals($publisherId, $modelId[1]); $this->assertEquals('publisher', $modelId[2]); $this->assertEquals($publisherId, $model->getModel()->getId()); }
/** * Regression test for existing thesis:* and ddb:* elements */ public function testGetRecordXMetaDissPlusDoc146ThesisAndDdb() { $doc = new Opus_Document(146); $this->assertEquals('masterthesis', $doc->getType(), 'testdata changed: document type changed'); $this->assertEquals('published', $doc->getServerState(), 'testdata changed: document state changed'); $this->assertEquals(2, count($doc->getThesisGrantor()), 'testdata changed: thesis grantor added to document'); $this->assertEquals(2, count($doc->getThesisPublisher()), 'testdata changed: thesis publisher added to document'); $this->dispatch('/oai?verb=GetRecord&metadataPrefix=XMetaDissPlus&identifier=oai::146'); $this->assertResponseCode(200); $response = $this->getResponse(); $xpath = $this->prepareXpathFromResultString($response->getBody()); // Regression test for OPUSVIER-2452 - existing thesis:grantor element $elements = $xpath->query('//thesis:degree/thesis:grantor'); $this->assertEquals(2, $elements->length, "Unexpected thesis:grantor count"); // Regression test for OPUSVIER-2523 - existing ddb:contact element $elements = $xpath->query('//ddb:contact/@ddb:contactID'); $this->assertEquals(1, $elements->length, "Unexpected ddb:contact count"); $this->assertEquals('Lxxxx-xxxx', $elements->item(0)->nodeValue, "Wrong ddb:contact"); // Testing for other existing elements $elements = $xpath->query('//thesis:degree/thesis:level[text()="master"]'); $this->assertEquals(1, $elements->length, "Unexpected thesis:level=='master' count"); $elements = $xpath->query('//thesis:degree/thesis:grantor/cc:universityOrInstitution/cc:name'); $this->assertEquals(2, $elements->length, "Unexpected thesis:level=='master' count"); }
$docFinder = new Opus_DocumentFinder(); $docIds = $docFinder->setServerState('published'); if ($documentType != false) { $docFinder->setType($documentType); } $docIds = $docFinder->ids(); _log(count($docIds) . " documents " . ($documentType != false ? "of type '{$documentType}' " : '') . "found"); foreach ($docIds as $docId) { try { $doc = new Opus_Document($docId); if (count($doc->getFile()) == 0) { _log("Document <{$docId}> has no files, skipping.."); continue; } if (!is_null($thesisPublisherId)) { $thesisPublisher = $doc->getThesisPublisher(); if (empty($thesisPublisher)) { if (!$dryrun) { $doc->setThesisPublisher($dnbInstitute); $doc->store(); } _log("Setting ThesisPublisher <{$thesisPublisherId}> on Document <{$docId}>"); } else { $existingThesisPublisherId = $thesisPublisher[0]->getId(); _log("ThesisPublisher <{$existingThesisPublisherId[1]}> already set for Document <{$docId}>"); } } if (!is_null($thesisGrantorId)) { $thesisGrantor = $doc->getThesisGrantor(); if (empty($thesisGrantor)) { if (!$dryrun) {