function myErrorHandler($errno, $errstr, $errfile, $errline)
{
    echo "WARNING: myErrorHandler({$errno}, '{$errstr}', '{$errfile}', {$errline})\n";
    return true;
}
// set to the user defined error handler
$oldErrorHandler = set_error_handler("myErrorHandler");
//
// Creating document, filling static fields.
//
$doc = new Opus_Document();
$doc->setType(randString($counter++));
$doc->setServerState('published');
$doc->setServerDatePublished('01.01.1900');
$doc->setLanguage('deu' . randString($counter++));
$doc->setThesisDateAccepted('01.02.2003');
$doc->setPublishedYear('2010');
$doc->setPublishedDate('28.09.2010');
$doc->setCompletedYear('2010');
$doc->setCompletedDate('27.09.2010');
$doc->setPublisherName(randString($counter++));
$doc->setPublisherPlace(randString($counter++));
$doc->setPageNumber(randString($counter++));
$doc->setPageFirst(randString($counter++));
$doc->setPageLast(randString($counter++));
$doc->setVolume(randString($counter++));
$doc->setIssue(randString($counter++));
$doc->setCreatingCorporation(randString($counter++));
$doc->setContributingCorporation(randString($counter++));
//
// Persons
$urn->setValue('urn:nbn:de:kobv:nn-opus-173');
$isbn = $doc->addIdentifierIsbn();
$isbn->setValue('978-3-86680-192-9');
$issn = $doc->addIdentifierIssn();
$issn->setValue('1234-5678');
$doc->addIdentifierOpac()->setValue('OPAC-ID 001 1237890654');
// Valid Arxiv-Identifier from ArXiv.org Homepage: http://arxiv.org/help/arxiv_identifier
$arxiv = $doc->addIdentifierArxiv();
$arxiv->setValue('arXiv:0706.0001');
// Valid DOI Identifier from DOI Homepage: http://www.doi.org/
$doi = $doc->addIdentifierDoi();
$doi->setValue('10.1000/182');
// Valid Pubmed-Identifier from official Pubmed Tutorial: http://www.nlm.nih.gov/bsd/disted/pubmedtutorial/020_830.html
$pubmed = $doc->addIdentifierPubmed();
$pubmed->setValue('9382368');
$doc->setThesisDateAccepted('2003-02-01');
$dnbInstitute = new Opus_DnbInstitute();
$dnbInstitute->setName('Forschungsinstitut für Code Coverage');
foreach (Opus_DnbInstitute::getGrantors() as $grantor) {
    if ($dnbInstitute->getName() === $grantor->getName()) {
        $dnbInstitute = $grantor;
        break;
    }
}
if (is_null($dnbInstitute->getId()) === true) {
    $dnbInstitute->setCity('Mousetown')->setIsGrantor(1)->store();
}
$doc->setThesisGrantor($dnbInstitute);
$doc->setThesisPublisher($dnbInstitute);
$referee = new Opus_Person();
$referee->setFirstName('Gyro');