Skip to content

Commit b44fcd2

Browse files
committed
add plugin integration test run
1 parent 38aa4c3 commit b44fcd2

File tree

3 files changed

+40
-0
lines changed

3 files changed

+40
-0
lines changed

.github/workflows/test.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@ jobs:
2121
- '8.0'
2222
- '8.1'
2323
include:
24+
- php-versions: '7.0'
25+
composer-flags: '--prefer-lowest'
26+
operating-system: ubuntu-latest
2427
- php-versions: '5.3'
2528
composer-flags: '--prefer-lowest'
2629
operating-system: ubuntu-latest

phpunit.xml.dist

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
>
1717
<php>
1818
<env name="SYMFONY_DEPRECATIONS_HELPER" value="weak"/>
19+
<env name="COMPOSER_DISABLE_XDEBUG_WARN" value="1"/>
1920
</php>
2021
<testsuites>
2122
<testsuite name="Composer Diff Test Suite">

tests/Integration/DiffCommandTest.php

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,14 @@
22

33
namespace IonBazan\ComposerDiff\Tests\Integration;
44

5+
use Composer\Composer;
6+
use Composer\Console\Application;
7+
use Composer\IO\IOInterface;
8+
use Composer\IO\NullIO;
59
use IonBazan\ComposerDiff\Command\DiffCommand;
610
use IonBazan\ComposerDiff\PackageDiff;
711
use IonBazan\ComposerDiff\Tests\TestCase;
12+
use Symfony\Component\Console\Tester\ApplicationTester;
813
use Symfony\Component\Console\Tester\CommandTester;
914

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

30+
/**
31+
* @param string $expectedOutput
32+
*
33+
* @dataProvider commandArgumentsDataProvider
34+
*/
35+
public function testComposerApplication($expectedOutput, array $input)
36+
{
37+
if (version_compare('2.0', Composer::VERSION, '>=')) {
38+
$this->markTestSkipped('This test works properly only on Composer 2');
39+
}
40+
41+
array_unshift($input, 'diff');
42+
$app = new ComposerApplication();
43+
$app->setIO(new NullIO());
44+
$app->setAutoExit(false);
45+
$composer = $app->getComposer();
46+
$composer->getPluginManager()->registerPackage($composer->getPackage(), true);
47+
$tester = new ApplicationTester($app);
48+
$result = $tester->run($input);
49+
$this->assertSame(0, $result);
50+
$this->assertSame($expectedOutput, $tester->getDisplay());
51+
}
52+
2553
public function commandArgumentsDataProvider()
2654
{
2755
return array(
@@ -194,3 +222,11 @@ public function commandArgumentsDataProvider()
194222
);
195223
}
196224
}
225+
226+
class ComposerApplication extends Application
227+
{
228+
public function setIO(IOInterface $io)
229+
{
230+
$this->io = $io;
231+
}
232+
}

0 commit comments

Comments
 (0)