Skip to content

Commit

Permalink
chore: qa
Browse files Browse the repository at this point in the history
  • Loading branch information
Kocal committed May 17, 2024
1 parent 07c3044 commit a99552c
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 17 deletions.
9 changes: 5 additions & 4 deletions tests/BiomeJsBinaryTest.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

declare(strict_types=1);

namespace Kocal\BiomeJsBundle\Tests;
Expand All @@ -13,7 +14,7 @@ final class BiomeJsBinaryTest extends TestCase
{
public function testBinaryIsDownloadedIfNotExists(): void
{
$binaryDownloadDir = __DIR__.'/fixtures/var/download';
$binaryDownloadDir = __DIR__ . '/fixtures/var/download';
$fs = new Filesystem();
if (file_exists($binaryDownloadDir)) {
$fs->remove($binaryDownloadDir);
Expand All @@ -31,14 +32,14 @@ public function testBinaryIsDownloadedIfNotExists(): void
$client
);
$process = $binary->createProcess(['check', '--apply', '*.{js,ts}']);
$this->assertFileExists($binaryDownloadDir.'/fake-version/'.BiomeJsBinary::getBinaryName());
$this->assertFileExists($binaryDownloadDir . '/fake-version/' . BiomeJsBinary::getBinaryName());

// Windows doesn't wrap arguments in quotes
$expectedTemplate = '\\' === \DIRECTORY_SEPARATOR ? '"%s" check --apply *.{js,ts}' : "'%s' 'check' '--apply' '*.{js,ts}'";

$this->assertSame(
sprintf($expectedTemplate, $binaryDownloadDir.'/fake-version/'.BiomeJsBinary::getBinaryName()),
sprintf($expectedTemplate, $binaryDownloadDir . '/fake-version/' . BiomeJsBinary::getBinaryName()),
$process->getCommandLine()
);
}
}
}
11 changes: 7 additions & 4 deletions tests/FunctionalTest.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

declare(strict_types=1);

namespace Kocal\BiomeJsBundle\Tests;
Expand All @@ -14,21 +15,22 @@ final class FunctionalTest extends KernelTestCase
protected function setUp(): void
{
$fs = new Filesystem();
if (is_dir($biomejsVarDir = __DIR__.'/fixtures/var/biomejs')) {
if (is_dir($biomejsVarDir = __DIR__ . '/fixtures/var/biomejs')) {
$fs->remove($biomejsVarDir);
}
}

public function testCommandCheck(): void
{
self::bootKernel();
self::assertNotNull(self::$kernel);
$application = new Application(self::$kernel);

$command = $application->find('biomejs:check');
$commandTester = new CommandTester($command);

$statusCode = $commandTester->execute([
'path' => [__DIR__.'/fixtures/'],
'path' => [__DIR__ . '/fixtures/'],
]);
self::assertSame(Command::FAILURE, $statusCode, 'The command should return a non-zero exit code');

Expand All @@ -45,13 +47,14 @@ public function testCommandCheck(): void
public function testCommandCi(): void
{
self::bootKernel();
self::assertNotNull(self::$kernel);
$application = new Application(self::$kernel);

$command = $application->find('biomejs:ci');
$commandTester = new CommandTester($command);

$statusCode = $commandTester->execute([
'path' => [__DIR__.'/fixtures/'],
'path' => [__DIR__ . '/fixtures/'],
]);
self::assertSame(Command::FAILURE, $statusCode, 'The command should return a non-zero exit code');

Expand All @@ -64,4 +67,4 @@ public function testCommandCi(): void
self::assertStringContainsString('BiomeJsBundle/tests/fixtures/bootstrap.js format', $output);
self::assertStringContainsString('File content differs from formatting output', $output);
}
}
}
3 changes: 2 additions & 1 deletion tests/KocalBiomeJsBundleTest.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

declare(strict_types=1);

namespace Kocal\BiomeJsBundle\Tests;
Expand All @@ -15,4 +16,4 @@ public function testContainerExtension(): void

self::assertInstanceOf(BiomeJsExtension::class, $bundle->getContainerExtension());
}
}
}
16 changes: 8 additions & 8 deletions tests/fixtures/BiomeJsTestKernel.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

declare(strict_types=1);

namespace Kocal\BiomeJsBundle\Tests\fixtures;
Expand All @@ -19,13 +20,12 @@ public function __construct()
parent::__construct('test', true);
}

public function registerBundles(): array
public function registerBundles(): iterable
{
return [
new FrameworkBundle(),
new KocalBiomeJsBundle(),
];
yield new FrameworkBundle();
yield new KocalBiomeJsBundle();
}

protected function configureContainer(ContainerBuilder $container, LoaderInterface $loader): void
{
$container->setParameter('biomejs.use_tty', false);
Expand All @@ -43,16 +43,16 @@ protected function configureContainer(ContainerBuilder $container, LoaderInterfa

public function getCacheDir(): string
{
return sys_get_temp_dir().'/cache'.spl_object_hash($this);
return sys_get_temp_dir() . '/cache' . spl_object_hash($this);
}

public function getLogDir(): string
{
return sys_get_temp_dir().'/logs'.spl_object_hash($this);
return sys_get_temp_dir() . '/logs' . spl_object_hash($this);
}

public function getProjectDir(): string
{
return __DIR__;
}
}
}

0 comments on commit a99552c

Please sign in to comment.