Skip to content

Commit

Permalink
PHPUnit: make all dataProviders static
Browse files Browse the repository at this point in the history
  • Loading branch information
klees committed Apr 30, 2024
1 parent 7fc5638 commit 1d1730e
Show file tree
Hide file tree
Showing 134 changed files with 418 additions and 400 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
*/
final class ilWhiteListUrlValidatorTest extends TestCase
{
public function domainProvider(): array
public static function domainProvider(): array
{
return [
'Empty String / Empty Whitelist' => ['', [], false],
Expand Down
2 changes: 1 addition & 1 deletion components/ILIAS/Badge/tests/PresentationHeaderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ public function testShow(bool $additional = false): void
$head->show('tile_view', ...($additional_component[0] ?? []));
}

public function showProvider(): array
public static function showProvider(): array
{
return [
'Without additional component' => [],
Expand Down
2 changes: 1 addition & 1 deletion components/ILIAS/Badge/tests/SortingTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public function testOptions(): void
], array_keys((new Sorting())->options()));
}

public function sortProvider(): array
public static function sortProvider(): array
{
return [
'Default sort is title_asc' => [[], 'title_asc', 'sort_by_title_asc', 'badge', 'getTitle', ['A', 'a'], ['f', 'G'], ['d', 'c']],
Expand Down
2 changes: 1 addition & 1 deletion components/ILIAS/Badge/tests/TileTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ public function testAs(string $method, array $expected_components): void
array_map($this->assertInstanceOf(...), $expected_components, $components);
}

public function provideAsVariants(): array
public static function provideAsVariants(): array
{
return [
'Test asImage.' => ['asImage', [ModalComponent::class, ImageComponent::class]],
Expand Down
2 changes: 1 addition & 1 deletion components/ILIAS/Cache/tests/CacheTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ public function testLock(): void
$this->assertFalse($container->isLocked());
}

private function getInvalidLockTimes(): array
private static function getInvalidLockTimes(): array
{
return [
[-10],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ public function testNoSubitemDefinedForEvaluation(): void
$this->assertSame([], $completedCourses);
}

public function globalLearningProgressStateProvder(): array
public static function globalLearningProgressStateProvder(): array
{
return [
'LP globally enabled' => [true, []],
Expand Down
2 changes: 1 addition & 1 deletion components/ILIAS/Certificate/tests/ilXlsFoParserTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -433,7 +433,7 @@ public function testCommasWillBeConvertedToPointInDecimalSepartor(): void
$this->assertSame('Something Processed', $output);
}

public function nonBreakingSpaceIsAddedDataProvider(): Generator
public static function nonBreakingSpaceIsAddedDataProvider(): Generator
{
$expected_fo_with_centered_block = <<<EOT
<?xml version="1.0"?>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class ilChatroomServerSettingsTest extends TestCase
{
protected ilChatroomServerSettings $settings;

public function setterAndGettersProvider(): array
public static function setterAndGettersProvider(): array
{
$assertIsString = function ($actual): void {
$this->assertIsString($actual, 'The actual return value is not a type of "string"');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ public function testGetChatNameSuggestionsIfNotAnonymous(): void
$this->assertSame('jdoe', $suggestions['login']);
}

public function usernameDataProvider(): array
public static function usernameDataProvider(): array
{
return [
['username', 'username'],
Expand Down
2 changes: 1 addition & 1 deletion components/ILIAS/Component/tests/Dependencies/NameTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public function testImproperNames(string $name): void
$n = new Name($name);
}

public function properNames(): array
public static function properNames(): array
{
return [
[\ILIAS\Component\Tests::class],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public function testScenario($scenario_file, $result_file, $components)
$this->assertEquals($expected, $result);
}

public function scenarios()
public static function scenarios()
{
return [
"no dependencies" => ["scenario1.php", "result1.php",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public function testCreateObject(): void
$this->assertInstanceOf(ilPluginsOverviewTable::class, $obj);
}

public function getImportantFieldData(): array
public static function getImportantFieldData(): array
{
return [
[true, true],
Expand Down
8 changes: 4 additions & 4 deletions components/ILIAS/Component/tests/ilPluginInfoTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ public function testIsCompliantToILIAS(Data\Version $version, bool $is_compliant
$this->assertSame($is_compliant, $plugin->isCompliantToILIAS());
}

public function versionCompliance(): array
public static function versionCompliance(): array
{
$data_factory = new Data\Factory();
return [
Expand Down Expand Up @@ -318,7 +318,7 @@ public function isVersionToOld(): bool
$this->assertEquals($is_activation_possible, $plugin->isActivationPossible());
}

public function isActivationPossibleTruthTable(): array
public static function isActivationPossibleTruthTable(): array
{
// is_installed, supports_current_ilias, needs_update, is_version_to_old => is_activation_possible
return [
Expand Down Expand Up @@ -402,7 +402,7 @@ public function isVersionToOld(): bool
$this->assertEquals($is_activation_possible, $plugin->isActive());
}

public function isActiveTruthTable(): array
public static function isActiveTruthTable(): array
{
// is_installed, supports_current_ilias, needs_update, is_activated, is_version_to_old => is_active
return [
Expand Down Expand Up @@ -527,7 +527,7 @@ public function isActive(): bool
$plugin->getReasonForInactivity();
}

public function inactivityReasonTable(): array
public static function inactivityReasonTable(): array
{
// is_installed, supports_current_ilias, needs_update, is_activated, is_version_to_old => inactivity_reason
return [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ public function testElementsCanBeFiltered(): void
/**
* @return array{indexed: int[][], associative: array<int, array{A: string, B: string, C: string}>, mixed: array<int, array<int|string, int|string>>, relations: \ilBuddySystemRelation&\PHPUnit\Framework\MockObject\MockObject[][]}
*/
public function provideElements(): array
public static function provideElements(): array
{
$relation1 = $this->getMockBuilder(ilBuddySystemRelation::class)->disableOriginalConstructor()->getMock();
$relation2 = $this->getMockBuilder(ilBuddySystemRelation::class)->disableOriginalConstructor()->getMock();
Expand Down
2 changes: 1 addition & 1 deletion components/ILIAS/ContentPage/tests/PageReadingTimeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
*/
class PageReadingTimeTest extends TestCase
{
public function mixedReadingTypesProvider(): array
public static function mixedReadingTypesProvider(): array
{
return [
'Float Type' => [4.0],
Expand Down
2 changes: 1 addition & 1 deletion components/ILIAS/Context/tests/ilContextTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public function testInit(string $context, string $className): void
$this->assertEquals(ilContextExtended::getClassName(), $className);
}

public function contextProvider(): array
public static function contextProvider(): array
{
return [
[ilContext::CONTEXT_WEB, ilContextWeb::class],
Expand Down
Loading

0 comments on commit 1d1730e

Please sign in to comment.