Skip to content

Commit

Permalink
add plugin integration test run
Browse files Browse the repository at this point in the history
  • Loading branch information
IonBazan committed Jun 15, 2021
1 parent 38aa4c3 commit b44fcd2
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ jobs:
- '8.0'
- '8.1'
include:
- php-versions: '7.0'
composer-flags: '--prefer-lowest'
operating-system: ubuntu-latest
- php-versions: '5.3'
composer-flags: '--prefer-lowest'
operating-system: ubuntu-latest
Expand Down
1 change: 1 addition & 0 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
>
<php>
<env name="SYMFONY_DEPRECATIONS_HELPER" value="weak"/>
<env name="COMPOSER_DISABLE_XDEBUG_WARN" value="1"/>
</php>
<testsuites>
<testsuite name="Composer Diff Test Suite">
Expand Down
36 changes: 36 additions & 0 deletions tests/Integration/DiffCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,14 @@

namespace IonBazan\ComposerDiff\Tests\Integration;

use Composer\Composer;
use Composer\Console\Application;
use Composer\IO\IOInterface;
use Composer\IO\NullIO;
use IonBazan\ComposerDiff\Command\DiffCommand;
use IonBazan\ComposerDiff\PackageDiff;
use IonBazan\ComposerDiff\Tests\TestCase;
use Symfony\Component\Console\Tester\ApplicationTester;
use Symfony\Component\Console\Tester\CommandTester;

class DiffCommandTest extends TestCase
Expand All @@ -22,6 +27,29 @@ public function testCommand($expectedOutput, array $input)
$this->assertSame($expectedOutput, $tester->getDisplay());
}

/**
* @param string $expectedOutput
*
* @dataProvider commandArgumentsDataProvider
*/
public function testComposerApplication($expectedOutput, array $input)
{
if (version_compare('2.0', Composer::VERSION, '>=')) {
$this->markTestSkipped('This test works properly only on Composer 2');
}

array_unshift($input, 'diff');
$app = new ComposerApplication();
$app->setIO(new NullIO());
$app->setAutoExit(false);
$composer = $app->getComposer();
$composer->getPluginManager()->registerPackage($composer->getPackage(), true);
$tester = new ApplicationTester($app);
$result = $tester->run($input);
$this->assertSame(0, $result);
$this->assertSame($expectedOutput, $tester->getDisplay());
}

public function commandArgumentsDataProvider()
{
return array(
Expand Down Expand Up @@ -194,3 +222,11 @@ public function commandArgumentsDataProvider()
);
}
}

class ComposerApplication extends Application
{
public function setIO(IOInterface $io)
{
$this->io = $io;
}
}

0 comments on commit b44fcd2

Please sign in to comment.