Skip to content

Commit

Permalink
Also apply php-cs-fixer to tests
Browse files Browse the repository at this point in the history
  • Loading branch information
pjcdawkins committed Dec 23, 2024
1 parent 3030d41 commit 41ed512
Show file tree
Hide file tree
Showing 23 changed files with 46 additions and 34 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ lint-phpstan: composer-dev

.PHONY: lint-php-cs-fixer
lint-php-cs-fixer: composer-dev
./vendor/bin/php-cs-fixer check src
./vendor/bin/php-cs-fixer check src tests

.PHONY: lint-gofmt
lint-gofmt:
Expand Down
9 changes: 5 additions & 4 deletions tests/Command/App/AppConfigGetTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
#[Group('commands')]
class AppConfigGetTest extends TestCase
{
public function testGetConfig(): void {
public function testGetConfig(): void
{
$app = base64_encode((string) json_encode([
'type' => 'php:7.3',
'name' => 'app',
Expand All @@ -21,19 +22,19 @@ public function testGetConfig(): void {
putenv('PLATFORM_APPLICATION=' . $app);
$this->assertEquals(
'app',
(new Parser)->parse(MockApp::runAndReturnOutput('app:config', [
(new Parser())->parse(MockApp::runAndReturnOutput('app:config', [
'--property' => 'name',
]))
);
$this->assertEquals(
[],
(new Parser)->parse(MockApp::runAndReturnOutput('app:config', [
(new Parser())->parse(MockApp::runAndReturnOutput('app:config', [
'--property' => 'mounts',
]))
);
$this->assertEquals(
'',
(new Parser)->parse(MockApp::runAndReturnOutput('app:config', [
(new Parser())->parse(MockApp::runAndReturnOutput('app:config', [
'--property' => 'blank',
]))
);
Expand Down
9 changes: 6 additions & 3 deletions tests/Command/DecodeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
#[Group('commands')]
class DecodeTest extends TestCase
{
public function testDecode(): void {
public function testDecode(): void
{
$var = base64_encode((string) json_encode([
'foo' => 'bar',
'fee' => 'bor',
Expand All @@ -31,7 +32,8 @@ public function testDecode(): void {
);
}

public function testDecodeEmptyObject(): void {
public function testDecodeEmptyObject(): void
{
$this->assertEquals(
'{}',
rtrim(MockApp::runAndReturnOutput('decode', [
Expand All @@ -47,6 +49,7 @@ public function testDecodeEmptyObject(): void {
'--property' => 'nonexistent'
]), "\n")
);
} catch (\RuntimeException) {}
} catch (\RuntimeException) {
}
}
}
6 changes: 4 additions & 2 deletions tests/Command/Environment/EnvironmentRelationshipsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ public function tearDown(): void
putenv('PLATFORM_RELATIONSHIPS=');
}

public function testGetRelationshipHost(): void {
public function testGetRelationshipHost(): void
{
$this->assertEquals(
'database.internal',
rtrim(MockApp::runAndReturnOutput('rel', [
Expand All @@ -43,7 +44,8 @@ public function testGetRelationshipHost(): void {
);
}

public function testGetRelationshipUrl(): void {
public function testGetRelationshipUrl(): void
{
$this->assertEquals(
'mysql://main:123@database.internal:3306/main',
rtrim(MockApp::runAndReturnOutput('rel', [
Expand Down
6 changes: 4 additions & 2 deletions tests/Command/Environment/EnvironmentUrlTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ public function tearDown(): void
putenv('PLATFORM_ROUTES=');
}

public function testUrl(): void {
public function testUrl(): void
{
$this->assertEquals(
"https://example.com\n"
. "http://example.com\n",
Expand All @@ -42,7 +43,8 @@ public function testUrl(): void {
);
}

public function testPrimaryUrl(): void {
public function testPrimaryUrl(): void
{
$this->assertEquals(
'https://example.com',
rtrim(MockApp::runAndReturnOutput('env:url', [
Expand Down
6 changes: 4 additions & 2 deletions tests/Command/Route/RouteGetTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ public function tearDown(): void
putenv('PLATFORM_ROUTES=');
}

public function testGetPrimaryRouteUrl(): void {
public function testGetPrimaryRouteUrl(): void
{
$this->assertEquals(
'https://example.com',
rtrim(MockApp::runAndReturnOutput('route:get', [
Expand All @@ -42,7 +43,8 @@ public function testGetPrimaryRouteUrl(): void {
);
}

public function testGetRouteByOriginalUrl(): void {
public function testGetRouteByOriginalUrl(): void
{
$this->assertEquals(
'false',
rtrim(MockApp::runAndReturnOutput('route:get', [
Expand Down
3 changes: 2 additions & 1 deletion tests/Command/Route/RouteListTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ public function tearDown(): void
putenv('PLATFORM_ROUTES=');
}

public function testListRoutes(): void {
public function testListRoutes(): void
{
$this->assertEquals(
"https://{default}\tupstream\tapp:http\n"
. "http://{default}\tredirect\thttps://{default}\n",
Expand Down
3 changes: 2 additions & 1 deletion tests/Command/WelcomeCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
#[Group('commands')]
class WelcomeCommandTest extends TestCase
{
public function testWelcomeOnLocalContainer(): void {
public function testWelcomeOnLocalContainer(): void
{
chdir('/');
putenv('PLATFORM_PROJECT=test-project');
putenv('PLATFORM_BRANCH=test-environment');
Expand Down
4 changes: 2 additions & 2 deletions tests/ConfigTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@ public function testGetHomeDirectory(): void
$this->assertNotEmpty($homeDir, 'Home directory returned');
$this->assertNotEquals('.', $homeDir, 'Home directory not relative');

$homeDir = (new Config(['MOCK_CLI_HOME' => __DIR__ . '/data', 'HOME' => __DIR__], $this->configFile))->getHomeDirectory();
$homeDir = (new Config(['MOCK_CLI_HOME' => __DIR__ . '/data', 'HOME' => __DIR__], $this->configFile))->getHomeDirectory();
$this->assertEquals(__DIR__ . '/data', $homeDir, 'Home directory overridden');

$homeDir = (new Config(['MOCK_CLI_HOME' => '', 'HOME' => __DIR__], $this->configFile))->getHomeDirectory();
$homeDir = (new Config(['MOCK_CLI_HOME' => '', 'HOME' => __DIR__], $this->configFile))->getHomeDirectory();
$this->assertEquals(__DIR__, $homeDir, 'Empty value treated as nonexistent');
}

Expand Down
1 change: 0 additions & 1 deletion tests/InstallerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

class InstallerTest extends TestCase
{

public function setUp(): void
{
require_once CLI_ROOT . '/dist/installer.php';
Expand Down
1 change: 0 additions & 1 deletion tests/Local/BuildFlavor/ComposerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
#[Group('slow')]
class ComposerTest extends BuildFlavorTestBase
{

public function testBuildComposer(): void
{
$projectRoot = $this->assertBuildSucceeds('tests/data/apps/composer');
Expand Down
1 change: 0 additions & 1 deletion tests/Local/LocalApplicationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@

class LocalApplicationTest extends TestCase
{

private Config $config;

public function setUp(): void
Expand Down
1 change: 0 additions & 1 deletion tests/Local/LocalProjectTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@

class LocalProjectTest extends TestCase
{

use HasTempDirTrait;

public function testGetLegacyProjectRoot(): void
Expand Down
1 change: 1 addition & 0 deletions tests/MockApp.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

declare(strict_types=1);

namespace Platformsh\Cli\Tests;
Expand Down
9 changes: 6 additions & 3 deletions tests/Model/VariableTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,19 +52,22 @@ public function testParseInvalidVariableName(): void
(new Variable())->parse('a:b(c)=d');
}

public function testParseVariableWithNoDelimiter(): void {
public function testParseVariableWithNoDelimiter(): void
{
$this->expectException(\InvalidArgumentException::class);
$this->expectExceptionMessage($this->invalidMessage);
(new Variable())->parse('foo');
}

public function testParseVariableWithWrongDelimiterOrder(): void {
public function testParseVariableWithWrongDelimiterOrder(): void
{
$this->expectException(\InvalidArgumentException::class);
$this->expectExceptionMessage($this->invalidMessage);
(new Variable())->parse('a=b:c');
}

public function testParseVariableWithEmptyType(): void {
public function testParseVariableWithEmptyType(): void
{
$this->expectException(\InvalidArgumentException::class);
$this->expectExceptionMessage($this->invalidMessage);
(new Variable())->parse(':b=c');
Expand Down
1 change: 0 additions & 1 deletion tests/Service/GitDataApiServiceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

class GitDataApiServiceTest extends TestCase
{

/**
* Test GitDataApi::parseParents().
*/
Expand Down
1 change: 0 additions & 1 deletion tests/Service/GitServiceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
#[Group('slow')]
class GitServiceTest extends TestCase
{

use HasTempDirTrait;

protected Git $git;
Expand Down
1 change: 0 additions & 1 deletion tests/Service/ShellServiceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

class ShellServiceTest extends TestCase
{

/**
* Test Shell::execute().
*/
Expand Down
3 changes: 2 additions & 1 deletion tests/Service/SshTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
use Symfony\Component\Console\Output\BufferedOutput;
use Symfony\Component\Console\Output\OutputInterface;

class SshTest extends TestCase {
class SshTest extends TestCase
{
private ?Ssh $ssh;

public function setUp(): void
Expand Down
3 changes: 1 addition & 2 deletions tests/Util/PortUtilTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@ public function testGetPortDoesNotReturnPortInUse(): void
if ($returnVar === 0 && preg_match('/127\.0\.0\.1:([0-9]+)/', (string) end($output), $matches)) {
$openPort = (int) $matches[1];
$this->assertNotEquals($util->getPort($openPort), $openPort);
}
else {
} else {
$this->markTestIncomplete('Failed to find open port');
}
}
Expand Down
6 changes: 4 additions & 2 deletions tests/Util/SortTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@

class SortTest extends TestCase
{
public function testSortObjects(): void {
public function testSortObjects(): void
{
$objects = [
1 => (object) ['foo' => 'a', 'bar' => '1', 'num' => 5],
2 => (object) ['foo' => 'd', 'bar' => '10', 'num' => 10],
Expand Down Expand Up @@ -48,7 +49,8 @@ public function testSortObjects(): void {
}
}

public function testCompareDomains(): void {
public function testCompareDomains(): void
{
$arr = [
'region-1.fxample.com',
'region-4.example.com',
Expand Down
2 changes: 1 addition & 1 deletion tests/Util/TimezoneUtilTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public function testGetTimezoneReturnsSomething(): void
public function testConvertTz(): void
{
$util = new TimezoneUtil();
$method = new \ReflectionMethod($util,'convertTz');
$method = new \ReflectionMethod($util, 'convertTz');
$method->setAccessible(true);
$dataDir = dirname(__DIR__) . DIRECTORY_SEPARATOR . 'data';
$cases = [
Expand Down
1 change: 1 addition & 0 deletions tests/bootstrap.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/**
* @file
* A script containing any set-up steps required for PHPUnit testing.
Expand Down

0 comments on commit 41ed512

Please sign in to comment.