Skip to content

Commit

Permalink
Merge pull request #606 from ergebnis/fix/split
Browse files Browse the repository at this point in the history
Fix: Split test case
  • Loading branch information
ergebnis-bot authored Oct 31, 2020
2 parents 25cdddc + f7a5fc8 commit 4d0f20f
Show file tree
Hide file tree
Showing 32 changed files with 1,150 additions and 862 deletions.
2 changes: 1 addition & 1 deletion phpstan.neon
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ parameters:
classesAllowedToBeExtended:
- Composer\Command\BaseCommand
- Composer\Console\Application
- Ergebnis\Composer\Normalize\Test\Integration\Command\AbstractTestCase
- Ergebnis\Composer\Normalize\Test\Integration\Command\NormalizeCommand\AbstractTestCase
- LogicException
inferPrivatePropertyTypeFromConstructor: true
level: max
Expand Down
9 changes: 1 addition & 8 deletions psalm-baseline.xml
Original file line number Diff line number Diff line change
Expand Up @@ -54,21 +54,14 @@
<code>$composerFile</code>
</PossiblyInvalidArgument>
</file>
<file src="test/Integration/Command/AbstractTestCase.php">
<file src="test/Integration/Command/NormalizeCommand/AbstractTestCase.php">
<MixedArrayAccess occurrences="1">
<code>$decoded['plugin-api-version']</code>
</MixedArrayAccess>
<MixedAssignment occurrences="1">
<code>$decoded</code>
</MixedAssignment>
</file>
<file src="test/Integration/Command/NormalizeCommandTest.php">
<MixedArgumentTypeCoercion occurrences="1"/>
<UnnecessaryVarAnnotation occurrences="2">
<code>string</code>
<code>string</code>
</UnnecessaryVarAnnotation>
</file>
<file src="test/Util/File.php">
<PropertyNotSetInConstructor occurrences="1">
<code>$path</code>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
* @see https://github.com/ergebnis/composer-normalize
*/

namespace Ergebnis\Composer\Normalize\Test\Integration\Command;
namespace Ergebnis\Composer\Normalize\Test\Integration\Command\NormalizeCommand;

use Composer\Console\Application;
use Ergebnis\Composer\Normalize\Command\NormalizeCommand;
Expand Down Expand Up @@ -212,7 +212,7 @@ private static function fileSystem(): Filesystem\Filesystem

private static function temporaryDirectory(): string
{
return __DIR__ . '/../../../.build/test';
return __DIR__ . '/../../../../.build/test';
}

private static function normalizeLockFileContents(string $contents): string
Expand Down
58 changes: 58 additions & 0 deletions test/Integration/Command/NormalizeCommand/Json/NotValid/Test.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
<?php

declare(strict_types=1);

/**
* Copyright (c) 2018-2020 Andreas Möller
*
* For the full copyright and license information, please view
* the LICENSE.md file that was distributed with this source code.
*
* @see https://github.com/ergebnis/composer-normalize
*/

namespace Ergebnis\Composer\Normalize\Test\Integration\Command\NormalizeCommand\Json\NotValid;

use Ergebnis\Composer\Normalize\Test\Integration;
use Ergebnis\Composer\Normalize\Test\Util;
use Symfony\Component\Console;

/**
* @internal
*
* @covers \Ergebnis\Composer\Normalize\Command\NormalizeCommand
* @covers \Ergebnis\Composer\Normalize\NormalizePlugin
*/
final class Test extends Integration\Command\NormalizeCommand\AbstractTestCase
{
/**
* @dataProvider \Ergebnis\Composer\Normalize\Test\DataProvider\Command\NormalizeCommandProvider::commandInvocation()
*/
public function testFailsWhenComposerJsonIsValidAccordingToLaxValidation(Util\CommandInvocation $commandInvocation): void
{
$scenario = self::createScenario(
$commandInvocation,
__DIR__ . '/fixture'
);

$initialState = $scenario->initialState();

self::assertComposerJsonFileExists($initialState);
self::assertComposerLockFileNotExists($initialState);

$application = self::createApplicationWithNormalizeCommandAsProvidedByNormalizePlugin();

$output = new Console\Output\BufferedOutput();

$input = new Console\Input\ArrayInput($scenario->consoleParameters());

$exitCode = $application->run(
$input,
$output
);

self::assertExitCodeSame(1, $exitCode);
self::assertStringContainsString('does not match the expected JSON schema', $output->fetch());
self::assertEquals($initialState, $scenario->currentState());
}
}
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
<?php

declare(strict_types=1);

/**
* Copyright (c) 2018-2020 Andreas Möller
*
* For the full copyright and license information, please view
* the LICENSE.md file that was distributed with this source code.
*
* @see https://github.com/ergebnis/composer-normalize
*/

namespace Ergebnis\Composer\Normalize\Test\Integration\Command\NormalizeCommand\Json\Valid\Lock\NotPresent\Json\AlreadyNormalized;

use Ergebnis\Composer\Normalize\Test\Integration;
use Ergebnis\Composer\Normalize\Test\Util;
use Symfony\Component\Console;

/**
* @internal
*
* @covers \Ergebnis\Composer\Normalize\Command\NormalizeCommand
* @covers \Ergebnis\Composer\Normalize\NormalizePlugin
*/
final class Test extends Integration\Command\NormalizeCommand\AbstractTestCase
{
/**
* @dataProvider \Ergebnis\Composer\Normalize\Test\DataProvider\Command\NormalizeCommandProvider::commandInvocation()
*/
public function testSucceeds(Util\CommandInvocation $commandInvocation): void
{
$scenario = self::createScenario(
$commandInvocation,
__DIR__ . '/fixture'
);

$initialState = $scenario->initialState();

self::assertComposerJsonFileExists($initialState);
self::assertComposerLockFileNotExists($initialState);

$application = self::createApplicationWithNormalizeCommandAsProvidedByNormalizePlugin();

$output = new Console\Output\BufferedOutput();

$input = new Console\Input\ArrayInput($scenario->consoleParameters());

$exitCode = $application->run(
$input,
$output
);

self::assertExitCodeSame(0, $exitCode);

$expected = \sprintf(
'%s is already normalized.',
$scenario->composerJsonFileReference()
);

self::assertStringContainsString($expected, $output->fetch());
self::assertEquals($initialState, $scenario->currentState());
}
}
Loading

0 comments on commit 4d0f20f

Please sign in to comment.