Skip to content

Commit

Permalink
Refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastianbergmann committed Mar 31, 2024
1 parent 13ed8a0 commit 58c3825
Showing 1 changed file with 20 additions and 59 deletions.
79 changes: 20 additions & 59 deletions tests/ExporterTest.php
Expand Up @@ -212,6 +212,18 @@ public static function exportProvider(): array
)
EOF
],
'enum' => [
ExampleEnum::Value,
'SebastianBergmann\Exporter\ExampleEnum Enum #%d (Value)',
],
'backed enum (string)' => [
ExampleStringBackedEnum::Value,
'SebastianBergmann\Exporter\ExampleStringBackedEnum Enum #%d (Value, \'value\')',
],
'backed enum (integer)' => [
ExampleIntegerBackedEnum::Value,
'SebastianBergmann\Exporter\ExampleIntegerBackedEnum Enum #%d (Value, 0)',
],
];
}

Expand All @@ -234,11 +246,14 @@ public static function shortenedExportProvider(): array
'float 1 - 2 / 3' => [1 - 2 / 3, '0.33333333333333337'],
'numeric string' => ['1', "'1'"],
// \n\r and \r is converted to \n
'multilinestring' => ["this\nis\na\nvery\nvery\nvery\nvery\nvery\nvery\rlong\n\rtext", "'this\\nis\\na\\nvery\\nvery\\nvery...\\rtext'"],
'empty stdClass' => [new stdClass, 'stdClass Object ()'],
'not empty stdClass' => [$obj, 'stdClass Object (...)'],
'empty array' => [[], '[]'],
'not empty array' => [$array, '[...]'],
'multilinestring' => ["this\nis\na\nvery\nvery\nvery\nvery\nvery\nvery\rlong\n\rtext", "'this\\nis\\na\\nvery\\nvery\\nvery...\\rtext'"],
'empty stdClass' => [new stdClass, 'stdClass Object ()'],
'not empty stdClass' => [$obj, 'stdClass Object (...)'],
'empty array' => [[], '[]'],
'not empty array' => [$array, '[...]'],
'enum' => [ExampleEnum::Value, 'SebastianBergmann\Exporter\ExampleEnum Enum (Value)'],
'backed enum (string)' => [ExampleStringBackedEnum::Value, 'SebastianBergmann\Exporter\ExampleStringBackedEnum Enum (Value, \'value\')'],
'backen enum (integer)' => [ExampleIntegerBackedEnum::Value, 'SebastianBergmann\Exporter\ExampleIntegerBackedEnum Enum (Value, 0)'],
];
}

Expand Down Expand Up @@ -390,60 +405,6 @@ public function testShortenedExportForMultibyteCharacters(): void
mb_language($oldMbLanguage);
}

public function testEnumExport(): void
{
// FIXME: Merge test into testExport once we drop support for PHP 8.0
$this->assertStringMatchesFormat(
'SebastianBergmann\Exporter\ExampleEnum Enum #%d (Value)',
$this->trimNewline((new Exporter)->export(ExampleEnum::Value)),
);
}

public function testStringBackedEnumExport(): void
{
// FIXME: Merge test into testExport once we drop support for PHP 8.0
$this->assertStringMatchesFormat(
'SebastianBergmann\Exporter\ExampleStringBackedEnum Enum #%d (Value, \'value\')',
$this->trimNewline((new Exporter)->export(ExampleStringBackedEnum::Value)),
);
}

public function testIntegerBackedEnumExport(): void
{
// FIXME: Merge test into testExport once we drop support for PHP 8.0
$this->assertStringMatchesFormat(
'SebastianBergmann\Exporter\ExampleIntegerBackedEnum Enum #%d (Value, 0)',
$this->trimNewline((new Exporter)->export(ExampleIntegerBackedEnum::Value)),
);
}

public function testEnumShortenedExport(): void
{
// FIXME: Merge test into testExport once we drop support for PHP 8.0
$this->assertStringMatchesFormat(
'SebastianBergmann\Exporter\ExampleEnum Enum (Value)',
$this->trimNewline((new Exporter)->shortenedExport(ExampleEnum::Value)),
);
}

public function testStringBackedEnumShortenedExport(): void
{
// FIXME: Merge test into testExport once we drop support for PHP 8.0
$this->assertStringMatchesFormat(
'SebastianBergmann\Exporter\ExampleStringBackedEnum Enum (Value, \'value\')',
$this->trimNewline((new Exporter)->shortenedExport(ExampleStringBackedEnum::Value)),
);
}

public function testIntegerBackedEnumShortenedExport(): void
{
// FIXME: Merge test into testExport once we drop support for PHP 8.0
$this->assertStringMatchesFormat(
'SebastianBergmann\Exporter\ExampleIntegerBackedEnum Enum (Value, 0)',
$this->trimNewline((new Exporter)->shortenedExport(ExampleIntegerBackedEnum::Value)),
);
}

#[DataProvider('provideNonBinaryMultibyteStrings')]
public function testNonBinaryStringExport($value, $expectedLength): void
{
Expand Down

0 comments on commit 58c3825

Please sign in to comment.