Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/php.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:

strategy:
matrix:
versions: [{php: '8.1', solr: '9.10.1'}, {php: '8.2', solr: '9.10.1'}, {php: '8.3', solr: '9.10.1'}, {php: '8.4', solr: '9.10.1'}]
versions: [{php: '8.1', solr: '9.10.1'}, {php: '8.2', solr: '9.10.1'}, {php: '8.3', solr: '9.10.1'}, {php: '8.4', solr: '9.10.1'}, {php: '8.5', solr: '9.10.1'}]
fail-fast: false

name: PHP ${{ matrix.versions.php }} Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ public function getAllDocumentTypes()
*/
public function isValid($documentType)
{
return array_key_exists($documentType, $this->getDocumentTypes());
return null !== $documentType && array_key_exists($documentType, $this->getDocumentTypes());
}

/**
Expand Down
1 change: 0 additions & 1 deletion library/Application/Controller/Action/Helper/Version.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,6 @@ public function getLatestReleaseFromServer()
curl_setopt($ch, CURLOPT_USERAGENT, 'OPUS 4');
curl_setopt($ch, CURLOPT_TIMEOUT, 5);
$response = curl_exec($ch);
curl_close($ch);

if (! $response) {
// TODO no response
Expand Down
4 changes: 2 additions & 2 deletions library/Application/Form/Element/Language.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,15 +61,15 @@ public function init()
*/
public function setValue($value)
{
if ($value !== null) {
if (null !== $value) {
$language = Languages::getLanguage($value);

if (null !== $language) {
$value = $language->getId();
}
}

if (! in_array($value, array_keys(self::getLanguageList()))) {
if (null !== $value && ! in_array($value, array_keys(self::getLanguageList()))) {
$label = Locale::getDisplayName($value);
if ($label !== $value) {
$label .= " ({$value})";
Expand Down
2 changes: 1 addition & 1 deletion library/Application/Form/Element/PublicationState.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public function setValue($value)

$publicationState = new PublicationState();

if (! array_key_exists($value, $options) && in_array($value, $publicationState->getAllValues())) {
if (null !== $value && ! array_key_exists($value, $options) && in_array($value, $publicationState->getAllValues())) {
$additionalOption[$value] = $this->translateValue($value);

$options = array_merge(
Expand Down
1 change: 0 additions & 1 deletion library/Application/Translate/TmxParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ public function __construct()

public function __destruct()
{
xml_parser_free($this->parser);
unset($this->parser);
}

Expand Down
7 changes: 4 additions & 3 deletions modules/admin/forms/Document/MultiSubForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -582,9 +582,10 @@ public function isValid($data, $context = null)
$result = true;

if ($this->subformValidator !== null) {
if (array_key_exists($this->getName(), $data)) {
$this->subformValidator->prepareValidation($this, $data[$this->getName()], $context);
$result = $this->subformValidator->isValid($data[$this->getName()], $context);
$name = $this->getName();
if (null !== $name && array_key_exists($name, $data)) {
$this->subformValidator->prepareValidation($this, $data[$name], $context);
$result = $this->subformValidator->isValid($data[$name], $context);
}
}

Expand Down
2 changes: 1 addition & 1 deletion modules/frontdoor/models/HtmlMetaTags.php
Original file line number Diff line number Diff line change
Expand Up @@ -566,7 +566,7 @@ public function getMetatagsType($document)
{
$mappingConfig = $this->getMappingConfig();
$docType = $document->getType();
if (isset($mappingConfig[$docType])) {
if (null !== $docType && isset($mappingConfig[$docType])) {
return $mappingConfig[$docType];
} else {
return 'other';
Expand Down
2 changes: 1 addition & 1 deletion modules/oai/models/Set/PublicationStateSets.php
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ protected function getSubsetNames()
*/
public function getSubsetName($publicationState)
{
if (array_key_exists($publicationState, $this->subsetMapping)) {
if (null !== $publicationState && array_key_exists($publicationState, $this->subsetMapping)) {
return $this->subsetMapping[$publicationState];
} else {
return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,7 @@ public function testListFilesAllFileTypes()

public function testGetAllowedFileTypes()
{
$method = new ReflectionMethod('Application_Controller_Action_Helper_Files', 'getAllowedFileTypes');
$method->setAccessible(true);

$method = new ReflectionMethod('Application_Controller_Action_Helper_Files', 'getAllowedFileTypes');
$fileTypes = $method->invoke($this->helper);

$this->assertEquals(4, count($fileTypes));
Expand Down
8 changes: 0 additions & 8 deletions tests/library/Application/Form/Model/AbstractTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -183,25 +183,19 @@ public function testSetGetVerifyModelIdIsNumeric()
public function testValidateModelIdValidMustBeNumeric()
{
$method = new ReflectionMethod('Application_Form_Model_Abstract', 'validateModelId');
$method->setAccessible(true);

$this->assertNull($method->invoke($this->form, '123'));
}

public function testValidateModelIdValidNonNumeric()
{
$method = new ReflectionMethod('Application_Form_Model_Abstract', 'validateModelId');
$method->setAccessible(true);

$this->form->setVerifyModelIdIsNumeric(false);
$this->assertNull($method->invoke($this->form, 'enrichment'));
}

public function testValidateModelIdNotValidNonNumeric()
{
$method = new ReflectionMethod('Application_Form_Model_Abstract', 'validateModelId');
$method->setAccessible(true);

$this->expectException(ApplicationException::class);
$this->expectExceptionMessage('Model-ID must be numeric.');
$method->invoke($this->form, 'enrichment');
Expand All @@ -210,8 +204,6 @@ public function testValidateModelIdNotValidNonNumeric()
public function testValidateModelIdForNull()
{
$method = new ReflectionMethod('Application_Form_Model_Abstract', 'validateModelId');
$method->setAccessible(true);

$this->assertNull($method->invoke($this->form, null));

$this->form->setVerifyModelIdIsNumeric(false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,7 @@ public function testGetModel()
$collectionRole->store();

$method = new ReflectionMethod(Application_Form_Validate_CollectionRoleOaiNameUnique::class, 'getModel');
$method->setAccessible(true);

$model = $method->invoke($this->validator, ['NewTestColRoleOaiName']);
$model = $method->invoke($this->validator, ['NewTestColRoleOaiName']);

$this->assertNotNull($model);
$this->assertEquals('NewTestColRoleOaiName', $model->getOaiName());
Expand Down
9 changes: 3 additions & 6 deletions tests/library/Application/Job/CheckWorkspaceFilesJobTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,7 @@ public function testGetFilePath()
$job = $this->job;
$reflector = new ReflectionClass($job);
$getPath = $reflector->getMethod('getFilesPath');
$getPath->setAccessible(true);
$path = $getPath->invokeArgs($job, []);
$path = $getPath->invokeArgs($job, []);

$expectedPath = realpath(Config::get()->workspacePath . DIRECTORY_SEPARATOR . "files");

Expand All @@ -84,8 +83,7 @@ public function testRunException()
$job = $this->job;
$reflector = new ReflectionClass($job);
$getPath = $reflector->getMethod('getFilesPath');
$getPath->setAccessible(true);
$path = $getPath->invokeArgs($job, []);
$path = $getPath->invokeArgs($job, []);

$file = $this->createTestFile('/0909', null, $path);

Expand All @@ -105,8 +103,7 @@ public function testSetFilesPath()

$reflector = new ReflectionClass($job);
$getPath = $reflector->getMethod('getFilesPath');
$getPath->setAccessible(true);
$path = $getPath->invokeArgs($job, []);
$path = $getPath->invokeArgs($job, []);

$this->assertSame($expectedPath, $path);
}
Expand Down
3 changes: 1 addition & 2 deletions tests/library/Application/Job/CleanTemporariesJobTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,7 @@ public function testGetPreviousDate()
$job = $this->job;
$reflector = new ReflectionClass($job);
$getDate = $reflector->getMethod('getPreviousDate');
$getDate->setAccessible(true);
$date = $getDate->invokeArgs($job, []);
$date = $getDate->invokeArgs($job, []);

$dateTime = new DateTime();
$expected = $dateTime->sub(new DateInterval('P2D'))->format('Y-m-d');
Expand Down
1 change: 0 additions & 1 deletion tests/library/Application/Security/HttpAuthAdapterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ public function testSecureStringCompare()
]);

$method = new ReflectionMethod('Application_Security_HttpAuthAdapter', '_secureStringCompare');
$method->setAccessible(true);

$this->assertFalse($method->invoke($adapter, 'password', 'password'));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1216,7 +1216,6 @@ public function testGetLanguageOrderRef()

$class = new ReflectionClass(get_class($manager));
$method = $class->getMethod('getLanguageOrderRef');
$method->setAccessible(true);

$order = $method->invoke($manager);

Expand Down Expand Up @@ -1246,7 +1245,6 @@ public function testSortLanguages()

$class = new ReflectionClass(get_class($manager));
$method = $class->getMethod('sortLanguages');
$method->setAccessible(true);

$sorted = $method->invoke($manager, [
'en' => 'English',
Expand Down
6 changes: 2 additions & 4 deletions tests/library/Application/Util/NotificationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -283,10 +283,8 @@ public function testCreateWorkerJobIfAsyncEnabled()
*/
protected function getMethod($methodName)
{
$class = new ReflectionClass('Application_Util_Notification');
$method = $class->getMethod($methodName);
$method->setAccessible(true);
return $method;
$class = new ReflectionClass('Application_Util_Notification');
return $class->getMethod($methodName);
}

public function testGetSubjectTemplate()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -245,10 +245,8 @@ public function testGetRecipientsForPublicationContextWithoutSubmitter()
*/
protected function getMethod($methodName)
{
$class = new ReflectionClass('Application_Util_PublicationNotification');
$method = $class->getMethod($methodName);
$method->setAccessible(true);
return $method;
$class = new ReflectionClass('Application_Util_PublicationNotification');
return $class->getMethod($methodName);
}

public function testGetPublicationMailBodyWithEmptyAuthorsAndEmptyTitle()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -447,7 +447,6 @@ public function testConstructWithTableHeader()
public function testPrepareSubFormDecoratorsForTableRendering()
{
$method = new ReflectionMethod('Admin_Form_Document_MultiSubForm', 'prepareSubFormDecorators');
$method->setAccessible(true);

$columns = [
[],
Expand Down Expand Up @@ -494,7 +493,6 @@ public function testAddRemoveButtonForTableRendering()
]);

$method = new ReflectionMethod('Admin_Form_Document_MultiSubForm', 'addRemoveButton');
$method->setAccessible(true);

$subform = new Zend_Form_SubForm();
$subform->addElement('hidden', 'Id');
Expand Down
1 change: 0 additions & 1 deletion tests/modules/admin/forms/Document/FilesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@ public function testColumnLabelTranslations()
$form = new Admin_Form_Document_Files();

$property = new ReflectionProperty(Admin_Form_Document_Files::class, 'header');
$property->setAccessible(true);

$header = $property->getValue($form);

Expand Down
2 changes: 0 additions & 2 deletions tests/modules/admin/forms/Document/MultiSubFormTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -443,7 +443,6 @@ public function testConstructWithTableHeader()
public function testPrepareSubFormDecoratorsForTableRendering()
{
$method = new ReflectionMethod('Admin_Form_Document_MultiSubForm', 'prepareSubFormDecorators');
$method->setAccessible(true);

$columns = [
[],
Expand Down Expand Up @@ -490,7 +489,6 @@ public function testAddRemoveButtonForTableRendering()
]);

$method = new ReflectionMethod('Admin_Form_Document_MultiSubForm', 'addRemoveButton');
$method->setAccessible(true);

$subform = new Zend_Form_SubForm();
$subform->addElement('hidden', 'Id');
Expand Down
6 changes: 2 additions & 4 deletions tests/modules/admin/forms/Document/PersonRoleTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -716,9 +716,7 @@ protected function getFormForSorting()
*/
private function getMethod($className, $methodName)
{
$class = new ReflectionClass($className);
$method = $class->getMethod($methodName);
$method->setAccessible(true);
return $method;
$class = new ReflectionClass($className);
return $class->getMethod($methodName);
}
}
1 change: 0 additions & 1 deletion tests/modules/export/controllers/IndexControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,6 @@ public function testSolrIndexIsNotUpToDate()

// add document to search index
// TODO fix $methodSendSolrXmlToServer = $class->getMethod('sendSolrXmlToServer');
// $methodSendSolrXmlToServer->setAccessible(true);
// $methodSendSolrXmlToServer->invoke($indexer, $solrXml);
// $indexer->commit();

Expand Down
25 changes: 10 additions & 15 deletions tests/modules/solrsearch/models/CollectionRolesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,8 @@ public function testHasVisibleChildrenForEmptyCollectionRole()
{
$collectionRoles = new Solrsearch_Model_CollectionRoles();

$class = new ReflectionClass('Solrsearch_Model_CollectionRoles');
$method = $class->getMethod('hasVisibleChildren');
$method->setAccessible(true);
$class = new ReflectionClass('Solrsearch_Model_CollectionRoles');
$method = $class->getMethod('hasVisibleChildren');
$hasChildren = $method->invokeArgs($collectionRoles, [CollectionRole::get(17)]);

$this->assertFalse($hasChildren);
Expand All @@ -59,9 +58,8 @@ public function testHasVisibleChildrenForNonEmptyCollectionRole()
{
$collectionRoles = new Solrsearch_Model_CollectionRoles();

$class = new ReflectionClass('Solrsearch_Model_CollectionRoles');
$method = $class->getMethod('hasVisibleChildren');
$method->setAccessible(true);
$class = new ReflectionClass('Solrsearch_Model_CollectionRoles');
$method = $class->getMethod('hasVisibleChildren');
$hasChildren = $method->invokeArgs($collectionRoles, [CollectionRole::get(7)]);

$this->assertTrue($hasChildren);
Expand All @@ -71,9 +69,8 @@ public function testHasPublishedDocsForEmptyCollectionRole()
{
$collectionRoles = new Solrsearch_Model_CollectionRoles();

$class = new ReflectionClass('Solrsearch_Model_CollectionRoles');
$method = $class->getMethod('hasPublishedDocs');
$method->setAccessible(true);
$class = new ReflectionClass('Solrsearch_Model_CollectionRoles');
$method = $class->getMethod('hasPublishedDocs');
$hasChildren = $method->invokeArgs($collectionRoles, [CollectionRole::get(17)]);

$this->assertFalse($hasChildren);
Expand All @@ -83,9 +80,8 @@ public function testHasPublishedDocsForNonEmptyCollectionRoleWithoutPublishedDoc
{
$collectionRoles = new Solrsearch_Model_CollectionRoles();

$class = new ReflectionClass('Solrsearch_Model_CollectionRoles');
$method = $class->getMethod('hasPublishedDocs');
$method->setAccessible(true);
$class = new ReflectionClass('Solrsearch_Model_CollectionRoles');
$method = $class->getMethod('hasPublishedDocs');
$hasChildren = $method->invokeArgs($collectionRoles, [CollectionRole::get(7)]);

$this->assertFalse($hasChildren);
Expand All @@ -95,9 +91,8 @@ public function testHasPublishedDocsForNonEmptyCollectionRoleWithPublishedDocs()
{
$collectionRoles = new Solrsearch_Model_CollectionRoles();

$class = new ReflectionClass('Solrsearch_Model_CollectionRoles');
$method = $class->getMethod('hasPublishedDocs');
$method->setAccessible(true);
$class = new ReflectionClass('Solrsearch_Model_CollectionRoles');
$method = $class->getMethod('hasPublishedDocs');
$hasChildren = $method->invokeArgs($collectionRoles, [CollectionRole::get(5)]);

$this->assertTrue($hasChildren);
Expand Down