Skip to content

Commit

Permalink
Refactor phpunit dataprovider to be static (#7415)
Browse files Browse the repository at this point in the history
  • Loading branch information
mamazu committed May 9, 2024
1 parent df87d1c commit e3545a6
Show file tree
Hide file tree
Showing 128 changed files with 190 additions and 190 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ public function setUp(): void
/**
* @return \Generator<mixed[]>
*/
public function provideCgetAction(): \Generator
public static function provideCgetAction(): \Generator
{
yield [
[],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public function testBuildFormOverlayListViewWithoutListAdapters(): void
->getView();
}

public function provideBuildFormOverlayListView()
public static function provideBuildFormOverlayListView()
{
return [
[
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public function testBuildFormViewWithoutResourceKey(): void
->getView();
}

public function provideBuildFormView()
public static function provideBuildFormView()
{
return [
[
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public function testBuildListViewWithoutListAdapters(): void
->getView();
}

public function provideBuildListView()
public static function provideBuildListView()
{
return [
[
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public function testBuildPreviewFormViewWithoutResourceKey(): void
->getView();
}

public function provideBuildPreviewFormView()
public static function provideBuildPreviewFormView()
{
return [
[
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public function testBuildResourceTabViewWithoutResourceKey(): void
->getView();
}

public function provideBuildResourceTabView()
public static function provideBuildResourceTabView()
{
return [
[
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public function testBuildTabViewWithClone(): void
$this->assertNotSame($viewBuilder->getView(), $viewBuilder->getView());
}

public function provideBuildTabView()
public static function provideBuildTabView()
{
return [
[
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

class ViewBuilderTest extends TestCase
{
public function provideBuildView()
public static function provideBuildView()
{
return [
[
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,7 @@ public function testMetadataActionWithOptions(): void
$this->adminController->metadataAction('form', 'pages', $request);
}

public function provideTranslationsAction()
public static function provideTranslationsAction()
{
return [
[
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ public function testFindWithNotExistingCacheItem(): void
$this->assertNull($result);
}

public function provideUpdate()
public static function provideUpdate()
{
return [
[
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

class ArrayMetadataTest extends TestCase
{
public function provideToJsonSchema()
public static function provideToJsonSchema()
{
return [
[
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

class ConstMetadataTest extends TestCase
{
public function provideToJsonSchema()
public static function provideToJsonSchema()
{
return [
['Homepage', ['const' => 'Homepage']],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

class PropertyMetadataTest extends TestCase
{
public function provideGetter()
public static function provideGetter()
{
return [
['title', true],
Expand All @@ -36,7 +36,7 @@ public function testGetter($name, $mandatory): void
$this->assertEquals($mandatory, $property->isMandatory());
}

public function provideToJsonSchema()
public static function provideToJsonSchema()
{
return [
['title', false, null, null],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public function testTargetGroupAction($header, $currentTargetGroup, $targetGroup
$this->assertEquals($targetGroupId, $response->headers->get($header));
}

public function provideTargetGroup()
public static function provideTargetGroup()
{
$targetGroup1 = new TargetGroup();

Expand Down Expand Up @@ -128,7 +128,7 @@ public function testTargetGroupHitAction($oldTargetGroup, $newTargetGroup, $newT
$targetGroupEvaluationController->targetGroupHitAction();
}

public function provideTargetGroupHit()
public static function provideTargetGroupHit()
{
$oldTargetGroup1 = new TargetGroup();
self::setPrivateProperty($oldTargetGroup1, 'id', 1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ public function testSetTargetGroupFromHeader(
$targetGroupSubscriber->setTargetGroup($event);
}

public function provideSetTargetGroupFromHeader()
public static function provideSetTargetGroupFromHeader()
{
return [
['X-Sulu-Target-Group', '1', '1'],
Expand Down Expand Up @@ -209,7 +209,7 @@ public function testSetTargetGroupFromCookie(
$targetGroupSubscriber->setTargetGroup($event);
}

public function provideSetTargetGroupFromCookie()
public static function provideSetTargetGroupFromCookie()
{
return [
['sulu-visitor-target-group', 'visitor-session', '1', true, null, '1', false],
Expand Down Expand Up @@ -253,7 +253,7 @@ public function testSetTargetGroupFromEvaluation($evaluatedTargetGroup, $result)
$this->assertCount(0, $request->headers->all());
}

public function provideSetTargetGroupFromEvaluation()
public static function provideSetTargetGroupFromEvaluation()
{
$targetGroup1 = new TargetGroup();
self::setPrivateProperty($targetGroup1, 'id', 1);
Expand Down Expand Up @@ -328,7 +328,7 @@ public function testAddVaryHeader($targetGroupUrl, $requestUrl, $hasInfluencedCo
$this->assertEquals($varyHeaders, $response->getVary());
}

public function provideAddVaryHeader()
public static function provideAddVaryHeader()
{
return [
['/_target_group', '/test', true, 'X-Sulu-Target-Group-Hash', ['X-Sulu-Target-Group-Hash']],
Expand Down Expand Up @@ -381,7 +381,7 @@ public function testAddSetCookieHeader($targetGroupCookie, $visitorSession, $has
}
}

public function provideAddSetCookieHeader()
public static function provideAddSetCookieHeader()
{
return [
['sulu-visitor-target-group', 'visitor-session', false, '/_target_group_hit', null],
Expand Down Expand Up @@ -441,7 +441,7 @@ public function testAddTargetGroupHitScript(
$this->assertEquals('<body><script></script></body>', $response->getContent());
}

public function provideAddTargetGroupHitScript()
public static function provideAddTargetGroupHitScript()
{
return [
['/_target_group_hit', 'X-Forwarded-URL', 'X-Fowarded-Referer', 'X-Forwarded-UUID', 'some-uuid'],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public function testProcess($urlHeader, $url, $host, $port, $path): void
$this->assertEquals($path, $requestAttributes->getAttribute('path'));
}

public function provideProcess()
public static function provideProcess()
{
return [
['X-Forwarded-Url', 'http://127.0.0.1:8000/en/test', '127.0.0.1', 8000, '/en/test'],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public function testEvaluate($browserShortName, $options, $result): void
$this->assertEquals($result, $this->browserRule->evaluate($options));
}

public function provideEvaluate()
public static function provideEvaluate()
{
return [
['CH', ['browser' => 'Chrome'], true],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public function testEvaluate($deviceType, $options, $result): void
$this->assertSame($result, $this->deviceTypeRule->evaluate($options));
}

public function provideEvaluate()
public static function provideEvaluate()
{
return [
[null, ['device_type' => DeviceTypeRule::DESKTOP], false],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public function testEvaluate($languages, $options, $result): void
$this->assertEquals($result, $this->localeRule->evaluate($options));
}

public function provideEvaluationData()
public static function provideEvaluationData()
{
return [
[['de'], ['locale' => 'de'], true],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public function testEvaluate($operatingSystemShortName, $options, $result): void
$this->assertEquals($result, $this->operatingSystemRule->evaluate($options));
}

public function provideEvaluate()
public static function provideEvaluate()
{
return [
['LIN', ['os' => 'GNU/Linux'], true],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public function testEvaluate($url, $urlHeader, $urlHeaderValue, $options, $resul
$this->assertEquals($result, $queryStringRule->evaluate($options));
}

public function provideEvaluate()
public static function provideEvaluate()
{
return [
[
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public function testEvaluate($referrerHeader, $referrer, $options, $result): voi
$this->assertEquals($result, $referrerRule->evaluate($options));
}

public function provideEvaluationData()
public static function provideEvaluationData()
{
return [
[null, 'https://www.google.com/test', ['referrer' => 'https://www.google.com/*'], true],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ public function testEvaluate(
$this->assertEquals($evaluatedTargetGroup, $this->targetGroupEvaluator->evaluate($frequency, $currentTargetGroup));
}

public function provideEvaluationData()
public static function provideEvaluationData()
{
$targetGroup1 = new TargetGroup();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class KeywordManagerTest extends TestCase
{
use ProphecyTrait;

public function provideSaveData()
public static function provideSaveData()
{
return [
[],
Expand Down Expand Up @@ -154,7 +154,7 @@ public function testSaveWithNotExistingCategoryTranslation(): void
$this->assertEquals($keyword->reveal(), $result);
}

public function provideDeleteData()
public static function provideDeleteData()
{
return [
[],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ private function createCategoryApi(array $data)
/**
* @return array<array{0:array<mixed>, 1?:string, 2?:string, 3?:int}>
*/
public function getProvider(): array
public static function getProvider(): array
{
return [
[[]],
Expand Down Expand Up @@ -135,7 +135,7 @@ public function testGet(array $categoryData, string $locale = 'en', ?string $par
/**
* @return array<array{string, string, string, string}>
*/
public function appendProvider(): array
public static function appendProvider(): array
{
return [
['c', '/test', '1,2', '1,2,3'],
Expand Down Expand Up @@ -207,7 +207,7 @@ public function testAppendUrl(string $parameter, string $url, string $string, st
/**
* @return array<array{string, string, string, string}>
*/
public function setProvider(): array
public static function setProvider(): array
{
return [
['c', '/test', '1,2', '3'],
Expand Down Expand Up @@ -253,7 +253,7 @@ public function testSetUrl(string $parameter, string $url, string $string, strin
}

/** @return array<array{string, string, string}> */
public function clearProvider(): array
public static function clearProvider(): array
{
return [
['c', '/test', '1,2'],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ protected function setUp(): void
$this->listener = new CacheInvalidationListener($this->cacheManager->reveal());
}

public function provideData()
public static function provideData()
{
return [
[ContactInterface::class, 'contact'],
Expand Down Expand Up @@ -123,7 +123,7 @@ public function testPreRemove($class, $alias): void
$this->listener->preRemove($eventArgs->reveal());
}

public function provideDataWithTagsAndCategories()
public static function provideDataWithTagsAndCategories()
{
return [
[ContactInterface::class, 'contact'],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

class CustomerIdConverterTest extends TestCase
{
public function convertIdsToGroupedIdsProvider()
public static function convertIdsToGroupedIdsProvider()
{
return [
[[], [], []],
Expand All @@ -40,7 +40,7 @@ public function testConvertIdsToGroupedIds(array $ids, array $default, $expected
$this->assertEquals($expected, $result);
}

public function convertGroupedIdsToIdsProvider()
public static function convertGroupedIdsToIdsProvider()
{
return [
[[], []],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class IndexComparatorTest extends TestCase
/**
* @return array
*/
public function usortProvider()
public static function usortProvider()
{
return [
[[5, 4, 3, 1, 2], [1, 2, 3, 4, 5], [1, 2, 3, 4, 5], []],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class ListBuilderMetadataProviderCompilerPassTest extends TestCase
{
use ProphecyTrait;

public function dataProcessProvider()
public static function dataProcessProvider()
{
return [
[false],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

class RemoveForeignContextServicesPassTest extends AbstractCompilerPassTestCase
{
public function provideWebsiteServices()
public static function provideWebsiteServices()
{
return [
[
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public function testLoad(): void
);
}

public function examplesDataProvider()
public static function examplesDataProvider()
{
return [
['default', ' ', '-'],
Expand Down

0 comments on commit e3545a6

Please sign in to comment.