Skip to content

Commit dcad6dc

Browse files
[MAINTENANCE] Adjustments in unit test classes (kitodo#1659)
1 parent eec43a5 commit dcad6dc

12 files changed

+111
-13
lines changed

Tests/Functional/Api/OaiPmhTest.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@ class OaiPmhTest extends FunctionalTestCase
4545
/**
4646
* Sets up the test case environment.
4747
*
48+
* @access public
49+
*
4850
* @return void
4951
*
5052
* @access public
@@ -293,6 +295,10 @@ public function canListAndResumeIdentifiers()
293295
/**
294296
* Parses a UTC date string into a DateTime object.
295297
*
298+
* @access protected
299+
*
300+
* @static
301+
*
296302
* @param string $dateTime The date string in UTC format (e.g., '2023-10-01T12:00:00Z')
297303
*
298304
* @return DateTime|false Returns a DateTime object or false on failure
@@ -309,6 +315,10 @@ protected static function parseUtc(string $dateTime): DateTime|false
309315
/**
310316
* Asserts that a given date string is a valid UTC date string.
311317
*
318+
* @access protected
319+
*
320+
* @static
321+
*
312322
* @param string $dateTime The date string to check
313323
*
314324
* @return void
@@ -325,6 +335,10 @@ protected static function assertUtcDateString(string $dateTime): void
325335
/**
326336
* Asserts that a given date string is in the future.
327337
*
338+
* @access protected
339+
*
340+
* @static
341+
*
328342
* @param string $dateTime The date string to check
329343
*
330344
* @return void

Tests/Functional/Api/PageViewProxyDisabledTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ class PageViewProxyDisabledTest extends FunctionalTestCase
2323
/**
2424
* Query the page view proxy with the given parameters.
2525
*
26+
* @access protected
27+
*
2628
* @param array $query The query parameters to send
2729
* @param string $method The HTTP method to use (default: 'GET')
2830
*

Tests/Functional/Api/PageViewProxyTest.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ class PageViewProxyTest extends FunctionalTestCase
2626
* This configuration is loaded from a .env file in the test directory.
2727
* It includes general settings, file groups, and Solr settings.
2828
*
29+
* @access protected
30+
*
2931
* @return array The DLF configuration
3032
*
3133
* @access protected
@@ -42,6 +44,8 @@ protected function getDlfConfiguration(): array
4244
/**
4345
* Query the page view proxy with the given parameters.
4446
*
47+
* @access protected
48+
*
4549
* @param array $query The query parameters to send
4650
* @param string $method The HTTP method to use (default: 'GET')
4751
*

Tests/Functional/FunctionalTestCase.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,8 @@ public function __construct()
108108
/**
109109
* Sets up the test case environment.
110110
*
111+
* @access public
112+
*
111113
* @return void
112114
*
113115
* @access public
@@ -133,6 +135,8 @@ public function setUp(): void
133135
* This configuration is loaded from a .env file in the test directory.
134136
* It includes general settings, file groups, and Solr settings.
135137
*
138+
* @access protected
139+
*
136140
* @return array The DLF configuration
137141
*
138142
* @access protected
@@ -197,6 +201,8 @@ protected function getDlfConfiguration(): array
197201
* The configuration is loaded from a YAML file and includes
198202
* the base URL and language settings.
199203
*
204+
* @access protected
205+
*
200206
* @param string $identifier The identifier for the site configuration
201207
*
202208
* @return void
@@ -251,6 +257,8 @@ protected function initializeRepository(string $className, int $storagePid): Rep
251257
* This method reads a JSON file containing an array of documents,
252258
* creates Solr documents from them, and adds them to the Solr index.
253259
*
260+
* @access protected
261+
*
254262
* @param Solr $solr The Solr instance to import documents into
255263
* @param string $path The path to the JSON file containing the documents
256264
*
@@ -285,6 +293,8 @@ protected function importSolrDocuments(Solr $solr, string $path): void
285293
* which is then used by the LanguageServiceFactory to load the language
286294
* in backend mode.
287295
*
296+
* @access protected
297+
*
288298
* @param string $locale The locale to set for the backend user
289299
*
290300
* @return void
@@ -356,6 +366,10 @@ protected function setUpSolr(int $uid, int $storagePid, array $solrFixtures): So
356366
/**
357367
* Assert that $sub is recursively contained within $super.
358368
*
369+
* @access protected
370+
*
371+
* @static
372+
*
359373
* @param array $sub
360374
* @param array $super
361375
* @param string $message

Tests/Unit/Common/HelperTest.php

Lines changed: 30 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,20 @@ class HelperTest extends UnitTestCase
2929
/**
3030
* @var LogManager|MockObject
3131
*/
32-
protected $logManagerMock;
32+
protected LogManager|MockObject $logManagerMock;
3333

3434
/**
3535
* @var Logger|MockObject
3636
*/
37-
protected $loggerMock;
37+
protected Logger|MockObject $loggerMock;
3838

39+
/**
40+
* Sets up the test environment.
41+
*
42+
* @access protected
43+
*
44+
* @return void
45+
*/
3946
protected function setUp(): void
4047
{
4148
parent::setUp();
@@ -50,16 +57,32 @@ protected function setUp(): void
5057
GeneralUtility::setSingletonInstance(LogManager::class, $this->logManagerMock);
5158
}
5259

60+
/**
61+
* Cleans up the test environment.
62+
*
63+
* @access protected
64+
*
65+
* @return void
66+
*/
5367
protected function tearDown(): void
5468
{
5569
GeneralUtility::purgeInstances();
5670
parent::tearDown();
5771
}
5872

59-
public function assertInvalidXml($xml)
73+
/**
74+
* Asserts that the given XML is invalid.
75+
*
76+
* @access private
77+
*
78+
* @param mixed $xml The XML to check
79+
*
80+
* @return void
81+
*/
82+
private static function assertInvalidXml(mixed $xml): void
6083
{
6184
$result = Helper::getXmlFileAsString($xml);
62-
self::assertEquals(false, $result);
85+
self::assertFalse($result);
6386
}
6487

6588
/**
@@ -115,22 +138,19 @@ public function filterFilesByMimeTypeHandlesInvalidInput(): void
115138
// Empty categories and types
116139
self::assertFalse(Helper::filterFilesByMimeType(
117140
['mimetype' => 'image/jpeg'],
118-
[],
119-
null
141+
[]
120142
));
121143

122144
// Invalid file input
123145
self::assertFalse(Helper::filterFilesByMimeType(
124146
null,
125-
['image'],
126-
null
147+
['image']
127148
));
128149

129150
// Missing mime type key
130151
self::assertFalse(Helper::filterFilesByMimeType(
131152
['wrong_key' => 'image/jpeg'],
132-
['image'],
133-
null
153+
['image']
134154
));
135155
}
136156

Tests/Unit/Format/AudioVideoMDTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
class AudioVideoMDTest extends UnitTestCase
1919
{
20-
protected $metadata = [];
20+
protected array $metadata = [];
2121

2222
public function setUp(): void
2323
{

Tests/Unit/Format/ModsTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
class ModsTest extends UnitTestCase
1919
{
20-
protected $metadata = [];
20+
protected array $metadata = [];
2121

2222
public function setUp(): void
2323
{

Tests/Unit/Format/TeiHeaderTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
class TeiHeaderTest extends UnitTestCase
1818
{
19-
protected $metadata = [];
19+
protected array $metadata = [];
2020

2121
public function setUp(): void
2222
{

Tests/Unit/Validation/DOMDocumentValidationStackTest.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,13 @@
3030
*/
3131
class DOMDocumentValidationStackTest extends UnitTestCase
3232
{
33+
/**
34+
* Sets up the test case environment.
35+
*
36+
* @access public
37+
*
38+
* @return void
39+
*/
3340
public function setUp(): void
3441
{
3542
parent::setUp();

Tests/Unit/Validation/DocumentValidatorTest.php

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,13 @@
1717

1818
class DocumentValidatorTest extends UnitTestCase
1919
{
20+
/**
21+
* Sets up the test case environment.
22+
*
23+
* @access public
24+
*
25+
* @return void
26+
*/
2027
public function setUp(): void
2128
{
2229
parent::setUp();
@@ -125,13 +132,29 @@ public function notPassesHasCorrectPhysicalStructure()
125132
self::assertFalse($documentValidator->hasCorrectPhysicalStructure());
126133
}
127134

135+
/**
136+
* Returns an array of required metadata fields for validation.
137+
*
138+
* @access private
139+
*
140+
* @return array The required metadata fields.
141+
*/
128142
private function getRequiredMetadataFields(): array
129143
{
130144
return [
131145
'record_id'
132146
];
133147
}
134148

149+
/**
150+
* Loads an XML file from the fixtures directory and returns it as a SimpleXMLElement.
151+
*
152+
* @access private
153+
*
154+
* @param string $file The name of the XML file to load.
155+
*
156+
* @return SimpleXMLElement The loaded XML as a SimpleXMLElement object.
157+
*/
135158
private function getXml(string $file): SimpleXMLElement
136159
{
137160
$xml = simplexml_load_file(__DIR__ . '/../../Fixtures/MetsDocument/' . $file);

0 commit comments

Comments
 (0)