Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: Tweak the SpecFormatter #1002

Merged
merged 1 commit into from
Apr 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,10 @@

namespace Humbug\PhpScoper\Scoper\Spec;

use Humbug\PhpScoper\Configuration\SymbolsConfiguration;
use Humbug\PhpScoper\NotInstantiable;
use Humbug\PhpScoper\Symbol\NamespaceRegistry;
use Humbug\PhpScoper\Symbol\SymbolRegistry;
use Humbug\PhpScoper\Symbol\SymbolsRegistry;
use PHPUnit\Framework\Attributes\Group;
use PHPUnit\Framework\TestCase;
use function array_map;
use function count;
Expand All @@ -34,26 +32,23 @@
/**
* @internal
*/
#[Group('integration')]
class SpecFormatter extends TestCase
final class SpecPrinter extends TestCase
{
use NotInstantiable;

/**
* @param string[][] $expectedRegisteredClasses
* @param string[][] $expectedRegisteredFunctions
*/
public static function createSpecMessage(
string $file,
string $spec,
string $contents,
SymbolsConfiguration $symbolsConfiguration,
SpecScenario $scenario,
SymbolsRegistry $symbolsRegistry,
?string $expected,
?string $actual,
array $expectedRegisteredClasses,
array $expectedRegisteredFunctions
?string $actualCode,
): string {
$file = $scenario->file;
$title = $scenario->title;
$inputCode = $scenario->inputCode;
$symbolsConfiguration = $scenario->symbolsConfiguration;
$expectedCode = $scenario->expectedCode;
$expectedRegisteredClasses = $scenario->expectedRegisteredClasses;
$expectedRegisteredFunctions = $scenario->expectedRegisteredFunctions;

$formattedExposeGlobalClasses = self::convertBoolToString($symbolsConfiguration->shouldExposeGlobalClasses());
$formattedExposeGlobalConstants = self::convertBoolToString($symbolsConfiguration->shouldExposeGlobalConstants());
$formattedExposeGlobalFunctions = self::convertBoolToString($symbolsConfiguration->shouldExposeGlobalFunctions());
Expand All @@ -78,7 +73,7 @@ public static function createSpecMessage(
$titleSeparator = str_repeat(
'=',
min(
strlen($spec),
strlen($title),
80,
),
);
Expand All @@ -87,7 +82,7 @@ public static function createSpecMessage(
{$titleSeparator}
SPECIFICATION
{$titleSeparator}
{$spec}
{$title}
{$file}

{$titleSeparator}
Expand All @@ -107,20 +102,20 @@ public static function createSpecMessage(
(raw) internal functions: {$formattedInternalFunctions}
(raw) internal constants: {$formattedInternalConstants}
{$titleSeparator}
{$contents}
{$inputCode}

{$titleSeparator}
EXPECTED
{$titleSeparator}
{$expected}
{$expectedCode}
----------------
recorded functions: {$formattedExpectedRegisteredFunctions}
recorded classes: {$formattedExpectedRegisteredClasses}

{$titleSeparator}
ACTUAL
{$titleSeparator}
{$actual}
{$actualCode}
----------------
recorded functions: {$formattedActualRegisteredFunctions}
recorded classes: {$formattedActualRegisteredClasses}
Expand Down
Loading
Loading