Skip to content

Commit

Permalink
[Tests] Migrate data providers to static ones
Browse files Browse the repository at this point in the history
  • Loading branch information
alexandre-daubois authored and nicolas-grekas committed Feb 6, 2023
1 parent fd78f92 commit 8ae1b60
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 25 deletions.
26 changes: 13 additions & 13 deletions Tests/Descriptor/AbstractDescriptorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,40 +51,40 @@ public function testDescribeApplication(Application $application, $expectedDescr
$this->assertDescription($expectedDescription, $application);
}

public function getDescribeInputArgumentTestData()
public static function getDescribeInputArgumentTestData()
{
return $this->getDescriptionTestData(ObjectsProvider::getInputArguments());
return static::getDescriptionTestData(ObjectsProvider::getInputArguments());
}

public function getDescribeInputOptionTestData()
public static function getDescribeInputOptionTestData()
{
return $this->getDescriptionTestData(ObjectsProvider::getInputOptions());
return static::getDescriptionTestData(ObjectsProvider::getInputOptions());
}

public function getDescribeInputDefinitionTestData()
public static function getDescribeInputDefinitionTestData()
{
return $this->getDescriptionTestData(ObjectsProvider::getInputDefinitions());
return static::getDescriptionTestData(ObjectsProvider::getInputDefinitions());
}

public function getDescribeCommandTestData()
public static function getDescribeCommandTestData()
{
return $this->getDescriptionTestData(ObjectsProvider::getCommands());
return static::getDescriptionTestData(ObjectsProvider::getCommands());
}

public function getDescribeApplicationTestData()
public static function getDescribeApplicationTestData()
{
return $this->getDescriptionTestData(ObjectsProvider::getApplications());
return static::getDescriptionTestData(ObjectsProvider::getApplications());
}

abstract protected function getDescriptor();

abstract protected function getFormat();
abstract protected static function getFormat();

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

Expand Down
2 changes: 1 addition & 1 deletion Tests/Descriptor/JsonDescriptorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ protected function getDescriptor()
return new JsonDescriptor();
}

protected function getFormat()
protected static function getFormat()
{
return 'json';
}
Expand Down
10 changes: 5 additions & 5 deletions Tests/Descriptor/MarkdownDescriptorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,17 @@

class MarkdownDescriptorTest extends AbstractDescriptorTest
{
public function getDescribeCommandTestData()
public static function getDescribeCommandTestData()
{
return $this->getDescriptionTestData(array_merge(
return self::getDescriptionTestData(array_merge(
ObjectsProvider::getCommands(),
['command_mbstring' => new DescriptorCommandMbString()]
));
}

public function getDescribeApplicationTestData()
public static function getDescribeApplicationTestData()
{
return $this->getDescriptionTestData(array_merge(
return self::getDescriptionTestData(array_merge(
ObjectsProvider::getApplications(),
['application_mbstring' => new DescriptorApplicationMbString()]
));
Expand All @@ -38,7 +38,7 @@ protected function getDescriptor()
return new MarkdownDescriptor();
}

protected function getFormat()
protected static function getFormat()
{
return 'md';
}
Expand Down
10 changes: 5 additions & 5 deletions Tests/Descriptor/TextDescriptorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,17 @@

class TextDescriptorTest extends AbstractDescriptorTest
{
public function getDescribeCommandTestData()
public static function getDescribeCommandTestData()
{
return $this->getDescriptionTestData(array_merge(
return self::getDescriptionTestData(array_merge(
ObjectsProvider::getCommands(),
['command_mbstring' => new DescriptorCommandMbString()]
));
}

public function getDescribeApplicationTestData()
public static function getDescribeApplicationTestData()
{
return $this->getDescriptionTestData(array_merge(
return self::getDescriptionTestData(array_merge(
ObjectsProvider::getApplications(),
['application_mbstring' => new DescriptorApplicationMbString()]
));
Expand All @@ -46,7 +46,7 @@ protected function getDescriptor()
return new TextDescriptor();
}

protected function getFormat()
protected static function getFormat()
{
return 'txt';
}
Expand Down
2 changes: 1 addition & 1 deletion Tests/Descriptor/XmlDescriptorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ protected function getDescriptor()
return new XmlDescriptor();
}

protected function getFormat()
protected static function getFormat()
{
return 'xml';
}
Expand Down

0 comments on commit 8ae1b60

Please sign in to comment.