Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 7d3175e

Browse filesBrowse files
minor #49244 [Tests] Migrate data providers to static ones (alexandre-daubois)
This PR was merged into the 5.4 branch. Discussion ---------- [Tests] Migrate data providers to static ones | Q | A | ------------- | --- | Branch? | 5.4 | Bug fix? | yes-ish | New feature? | no | Deprecations? | no | Tickets | Related to #48668 | License | MIT | Doc PR | _NA_ Migrating data providers to static ones, based on the failing CI of #48668 cc `@OskarStark` 👋 Commits ------- 36bc5ae [Tests] Migrate data providers to static ones
2 parents 26d0014 + 36bc5ae commit 7d3175e
Copy full SHA for 7d3175e
Expand file treeCollapse file tree

27 files changed

+160
-147
lines changed

‎src/Symfony/Bridge/Doctrine/Tests/Form/DoctrineOrmTypeGuesserTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Bridge/Doctrine/Tests/Form/DoctrineOrmTypeGuesserTest.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public function testTypeGuesser(string $type, $expected)
3535
$this->assertEquals($expected, $this->getGuesser($classMetadata)->guessType('TestEntity', 'field'));
3636
}
3737

38-
public function requiredType()
38+
public static function requiredType()
3939
{
4040
yield [Types::DATE_IMMUTABLE, new TypeGuess('Symfony\Component\Form\Extension\Core\Type\DateType', ['input' => 'datetime_immutable'], Guess::HIGH_CONFIDENCE)];
4141
yield [Types::DATE_MUTABLE, new TypeGuess('Symfony\Component\Form\Extension\Core\Type\DateType', [], Guess::HIGH_CONFIDENCE)];

‎src/Symfony/Bundle/SecurityBundle/Tests/DataCollector/SecurityDataCollectorTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/SecurityBundle/Tests/DataCollector/SecurityDataCollectorTest.php
+19-6Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
use Symfony\Component\HttpKernel\HttpKernelInterface;
2525
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorage;
2626
use Symfony\Component\Security\Core\Authentication\Token\SwitchUserToken;
27+
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
2728
use Symfony\Component\Security\Core\Authentication\Token\UsernamePasswordToken;
2829
use Symfony\Component\Security\Core\Authorization\TraceableAccessDecisionManager;
2930
use Symfony\Component\Security\Core\Authorization\Voter\TraceableVoter;
@@ -222,12 +223,17 @@ public function testGetListeners()
222223
$this->assertSame(1, $listenerCalled);
223224
}
224225

225-
public function providerCollectDecisionLog(): \Generator
226+
public static function providerCollectDecisionLog(): \Generator
226227
{
227-
$voter1 = $this->getMockBuilder(VoterInterface::class)->getMockForAbstractClass();
228-
$voter2 = $this->getMockBuilder(VoterInterface::class)->getMockForAbstractClass();
229-
230-
$eventDispatcher = $this->getMockBuilder(EventDispatcherInterface::class)->getMockForAbstractClass();
228+
$voter1 = new DummyVoter();
229+
$voter2 = new DummyVoter();
230+
231+
$eventDispatcher = new class() implements EventDispatcherInterface {
232+
public function dispatch(object $event, string $eventName = null): object
233+
{
234+
return new \stdClass();
235+
}
236+
};
231237
$decoratedVoter1 = new TraceableVoter($voter1, $eventDispatcher);
232238

233239
yield [
@@ -352,7 +358,7 @@ public function testCollectDecisionLog(string $strategy, array $decisionLog, arr
352358
$this->assertSame($dataCollector->getVoterStrategy(), $strategy, 'Wrong value returned by getVoterStrategy');
353359
}
354360

355-
public function provideRoles()
361+
public static function provideRoles()
356362
{
357363
return [
358364
// Basic roles
@@ -383,3 +389,10 @@ private function getRoleHierarchy()
383389
]);
384390
}
385391
}
392+
393+
class DummyVoter implements VoterInterface
394+
{
395+
public function vote(TokenInterface $token, $subject, array $attributes)
396+
{
397+
}
398+
}

‎src/Symfony/Component/Console/Tests/Descriptor/AbstractDescriptorTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Console/Tests/Descriptor/AbstractDescriptorTest.php
+13-13Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -51,40 +51,40 @@ public function testDescribeApplication(Application $application, $expectedDescr
5151
$this->assertDescription($expectedDescription, $application);
5252
}
5353

54-
public function getDescribeInputArgumentTestData()
54+
public static function getDescribeInputArgumentTestData()
5555
{
56-
return $this->getDescriptionTestData(ObjectsProvider::getInputArguments());
56+
return static::getDescriptionTestData(ObjectsProvider::getInputArguments());
5757
}
5858

59-
public function getDescribeInputOptionTestData()
59+
public static function getDescribeInputOptionTestData()
6060
{
61-
return $this->getDescriptionTestData(ObjectsProvider::getInputOptions());
61+
return static::getDescriptionTestData(ObjectsProvider::getInputOptions());
6262
}
6363

64-
public function getDescribeInputDefinitionTestData()
64+
public static function getDescribeInputDefinitionTestData()
6565
{
66-
return $this->getDescriptionTestData(ObjectsProvider::getInputDefinitions());
66+
return static::getDescriptionTestData(ObjectsProvider::getInputDefinitions());
6767
}
6868

69-
public function getDescribeCommandTestData()
69+
public static function getDescribeCommandTestData()
7070
{
71-
return $this->getDescriptionTestData(ObjectsProvider::getCommands());
71+
return static::getDescriptionTestData(ObjectsProvider::getCommands());
7272
}
7373

74-
public function getDescribeApplicationTestData()
74+
public static function getDescribeApplicationTestData()
7575
{
76-
return $this->getDescriptionTestData(ObjectsProvider::getApplications());
76+
return static::getDescriptionTestData(ObjectsProvider::getApplications());
7777
}
7878

7979
abstract protected function getDescriptor();
8080

81-
abstract protected function getFormat();
81+
abstract protected static function getFormat();
8282

83-
protected function getDescriptionTestData(array $objects)
83+
protected static function getDescriptionTestData(array $objects)
8484
{
8585
$data = [];
8686
foreach ($objects as $name => $object) {
87-
$description = file_get_contents(sprintf('%s/../Fixtures/%s.%s', __DIR__, $name, $this->getFormat()));
87+
$description = file_get_contents(sprintf('%s/../Fixtures/%s.%s', __DIR__, $name, static::getFormat()));
8888
$data[] = [$object, $description];
8989
}
9090

‎src/Symfony/Component/Console/Tests/Descriptor/JsonDescriptorTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Console/Tests/Descriptor/JsonDescriptorTest.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ protected function getDescriptor()
2020
return new JsonDescriptor();
2121
}
2222

23-
protected function getFormat()
23+
protected static function getFormat()
2424
{
2525
return 'json';
2626
}

‎src/Symfony/Component/Console/Tests/Descriptor/MarkdownDescriptorTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Console/Tests/Descriptor/MarkdownDescriptorTest.php
+5-5Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,17 +17,17 @@
1717

1818
class MarkdownDescriptorTest extends AbstractDescriptorTest
1919
{
20-
public function getDescribeCommandTestData()
20+
public static function getDescribeCommandTestData()
2121
{
22-
return $this->getDescriptionTestData(array_merge(
22+
return self::getDescriptionTestData(array_merge(
2323
ObjectsProvider::getCommands(),
2424
['command_mbstring' => new DescriptorCommandMbString()]
2525
));
2626
}
2727

28-
public function getDescribeApplicationTestData()
28+
public static function getDescribeApplicationTestData()
2929
{
30-
return $this->getDescriptionTestData(array_merge(
30+
return self::getDescriptionTestData(array_merge(
3131
ObjectsProvider::getApplications(),
3232
['application_mbstring' => new DescriptorApplicationMbString()]
3333
));
@@ -38,7 +38,7 @@ protected function getDescriptor()
3838
return new MarkdownDescriptor();
3939
}
4040

41-
protected function getFormat()
41+
protected static function getFormat()
4242
{
4343
return 'md';
4444
}

‎src/Symfony/Component/Console/Tests/Descriptor/TextDescriptorTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Console/Tests/Descriptor/TextDescriptorTest.php
+5-5Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,17 +18,17 @@
1818

1919
class TextDescriptorTest extends AbstractDescriptorTest
2020
{
21-
public function getDescribeCommandTestData()
21+
public static function getDescribeCommandTestData()
2222
{
23-
return $this->getDescriptionTestData(array_merge(
23+
return self::getDescriptionTestData(array_merge(
2424
ObjectsProvider::getCommands(),
2525
['command_mbstring' => new DescriptorCommandMbString()]
2626
));
2727
}
2828

29-
public function getDescribeApplicationTestData()
29+
public static function getDescribeApplicationTestData()
3030
{
31-
return $this->getDescriptionTestData(array_merge(
31+
return self::getDescriptionTestData(array_merge(
3232
ObjectsProvider::getApplications(),
3333
['application_mbstring' => new DescriptorApplicationMbString()]
3434
));
@@ -46,7 +46,7 @@ protected function getDescriptor()
4646
return new TextDescriptor();
4747
}
4848

49-
protected function getFormat()
49+
protected static function getFormat()
5050
{
5151
return 'txt';
5252
}

‎src/Symfony/Component/Console/Tests/Descriptor/XmlDescriptorTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Console/Tests/Descriptor/XmlDescriptorTest.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ protected function getDescriptor()
2020
return new XmlDescriptor();
2121
}
2222

23-
protected function getFormat()
23+
protected static function getFormat()
2424
{
2525
return 'xml';
2626
}

‎src/Symfony/Component/CssSelector/Tests/Node/AbstractNodeTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/CssSelector/Tests/Node/AbstractNodeTest.php
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public function testSpecificityValue(NodeInterface $node, $value)
2828
$this->assertEquals($value, $node->getSpecificity()->getValue());
2929
}
3030

31-
abstract public function getToStringConversionTestData();
31+
abstract public static function getToStringConversionTestData();
3232

33-
abstract public function getSpecificityValueTestData();
33+
abstract public static function getSpecificityValueTestData();
3434
}

‎src/Symfony/Component/CssSelector/Tests/Node/AttributeNodeTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/CssSelector/Tests/Node/AttributeNodeTest.php
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
class AttributeNodeTest extends AbstractNodeTest
1818
{
19-
public function getToStringConversionTestData()
19+
public static function getToStringConversionTestData()
2020
{
2121
return [
2222
[new AttributeNode(new ElementNode(), null, 'attribute', 'exists', null), 'Attribute[Element[*][attribute]]'],
@@ -25,7 +25,7 @@ public function getToStringConversionTestData()
2525
];
2626
}
2727

28-
public function getSpecificityValueTestData()
28+
public static function getSpecificityValueTestData()
2929
{
3030
return [
3131
[new AttributeNode(new ElementNode(), null, 'attribute', 'exists', null), 10],

‎src/Symfony/Component/CssSelector/Tests/Node/ClassNodeTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/CssSelector/Tests/Node/ClassNodeTest.php
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,14 @@
1616

1717
class ClassNodeTest extends AbstractNodeTest
1818
{
19-
public function getToStringConversionTestData()
19+
public static function getToStringConversionTestData()
2020
{
2121
return [
2222
[new ClassNode(new ElementNode(), 'class'), 'Class[Element[*].class]'],
2323
];
2424
}
2525

26-
public function getSpecificityValueTestData()
26+
public static function getSpecificityValueTestData()
2727
{
2828
return [
2929
[new ClassNode(new ElementNode(), 'class'), 10],

‎src/Symfony/Component/CssSelector/Tests/Node/CombinedSelectorNodeTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/CssSelector/Tests/Node/CombinedSelectorNodeTest.php
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,15 @@
1616

1717
class CombinedSelectorNodeTest extends AbstractNodeTest
1818
{
19-
public function getToStringConversionTestData()
19+
public static function getToStringConversionTestData()
2020
{
2121
return [
2222
[new CombinedSelectorNode(new ElementNode(), '>', new ElementNode()), 'CombinedSelector[Element[*] > Element[*]]'],
2323
[new CombinedSelectorNode(new ElementNode(), ' ', new ElementNode()), 'CombinedSelector[Element[*] <followed> Element[*]]'],
2424
];
2525
}
2626

27-
public function getSpecificityValueTestData()
27+
public static function getSpecificityValueTestData()
2828
{
2929
return [
3030
[new CombinedSelectorNode(new ElementNode(), '>', new ElementNode()), 0],

‎src/Symfony/Component/CssSelector/Tests/Node/ElementNodeTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/CssSelector/Tests/Node/ElementNodeTest.php
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
class ElementNodeTest extends AbstractNodeTest
1717
{
18-
public function getToStringConversionTestData()
18+
public static function getToStringConversionTestData()
1919
{
2020
return [
2121
[new ElementNode(), 'Element[*]'],
@@ -24,7 +24,7 @@ public function getToStringConversionTestData()
2424
];
2525
}
2626

27-
public function getSpecificityValueTestData()
27+
public static function getSpecificityValueTestData()
2828
{
2929
return [
3030
[new ElementNode(), 0],

‎src/Symfony/Component/CssSelector/Tests/Node/FunctionNodeTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/CssSelector/Tests/Node/FunctionNodeTest.php
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
class FunctionNodeTest extends AbstractNodeTest
1919
{
20-
public function getToStringConversionTestData()
20+
public static function getToStringConversionTestData()
2121
{
2222
return [
2323
[new FunctionNode(new ElementNode(), 'function'), 'Function[Element[*]:function()]'],
@@ -31,7 +31,7 @@ public function getToStringConversionTestData()
3131
];
3232
}
3333

34-
public function getSpecificityValueTestData()
34+
public static function getSpecificityValueTestData()
3535
{
3636
return [
3737
[new FunctionNode(new ElementNode(), 'function'), 10],

‎src/Symfony/Component/CssSelector/Tests/Node/HashNodeTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/CssSelector/Tests/Node/HashNodeTest.php
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,14 @@
1616

1717
class HashNodeTest extends AbstractNodeTest
1818
{
19-
public function getToStringConversionTestData()
19+
public static function getToStringConversionTestData()
2020
{
2121
return [
2222
[new HashNode(new ElementNode(), 'id'), 'Hash[Element[*]#id]'],
2323
];
2424
}
2525

26-
public function getSpecificityValueTestData()
26+
public static function getSpecificityValueTestData()
2727
{
2828
return [
2929
[new HashNode(new ElementNode(), 'id'), 100],

‎src/Symfony/Component/CssSelector/Tests/Node/NegationNodeTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/CssSelector/Tests/Node/NegationNodeTest.php
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,14 @@
1717

1818
class NegationNodeTest extends AbstractNodeTest
1919
{
20-
public function getToStringConversionTestData()
20+
public static function getToStringConversionTestData()
2121
{
2222
return [
2323
[new NegationNode(new ElementNode(), new ClassNode(new ElementNode(), 'class')), 'Negation[Element[*]:not(Class[Element[*].class])]'],
2424
];
2525
}
2626

27-
public function getSpecificityValueTestData()
27+
public static function getSpecificityValueTestData()
2828
{
2929
return [
3030
[new NegationNode(new ElementNode(), new ClassNode(new ElementNode(), 'class')), 10],

‎src/Symfony/Component/CssSelector/Tests/Node/PseudoNodeTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/CssSelector/Tests/Node/PseudoNodeTest.php
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,14 @@
1616

1717
class PseudoNodeTest extends AbstractNodeTest
1818
{
19-
public function getToStringConversionTestData()
19+
public static function getToStringConversionTestData()
2020
{
2121
return [
2222
[new PseudoNode(new ElementNode(), 'pseudo'), 'Pseudo[Element[*]:pseudo]'],
2323
];
2424
}
2525

26-
public function getSpecificityValueTestData()
26+
public static function getSpecificityValueTestData()
2727
{
2828
return [
2929
[new PseudoNode(new ElementNode(), 'pseudo'), 10],

‎src/Symfony/Component/CssSelector/Tests/Node/SelectorNodeTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/CssSelector/Tests/Node/SelectorNodeTest.php
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,15 @@
1616

1717
class SelectorNodeTest extends AbstractNodeTest
1818
{
19-
public function getToStringConversionTestData()
19+
public static function getToStringConversionTestData()
2020
{
2121
return [
2222
[new SelectorNode(new ElementNode()), 'Selector[Element[*]]'],
2323
[new SelectorNode(new ElementNode(), 'pseudo'), 'Selector[Element[*]::pseudo]'],
2424
];
2525
}
2626

27-
public function getSpecificityValueTestData()
27+
public static function getSpecificityValueTestData()
2828
{
2929
return [
3030
[new SelectorNode(new ElementNode()), 0],

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.