Skip to content

Commit

Permalink
Fix: Split test case
Browse files Browse the repository at this point in the history
  • Loading branch information
localheinz committed Oct 31, 2020
1 parent 25cdddc commit e5bce6b
Show file tree
Hide file tree
Showing 32 changed files with 1,148 additions and 860 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
7 changes: 0 additions & 7 deletions psalm-baseline.xml
Original file line number Diff line number Diff line change
Expand Up @@ -62,13 +62,6 @@
<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
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__ . '/files'
);

$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__ . '/files'
);

$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 e5bce6b

Please sign in to comment.