|
| 1 | +<?php |
| 2 | + |
| 3 | +namespace IonBazan\ComposerDiff\Tests\Integration; |
| 4 | + |
| 5 | +use IonBazan\ComposerDiff\Command\DiffCommand; |
| 6 | +use IonBazan\ComposerDiff\PackageDiff; |
| 7 | +use PHPUnit\Framework\TestCase; |
| 8 | +use Symfony\Component\Console\Tester\CommandTester; |
| 9 | + |
| 10 | +class DiffCommandTest extends TestCase |
| 11 | +{ |
| 12 | + /** |
| 13 | + * @param string $expectedOutput |
| 14 | + * @param array $input |
| 15 | + * |
| 16 | + * @dataProvider commandArgumentsDataProvider |
| 17 | + */ |
| 18 | + public function testCommand($expectedOutput, array $input) |
| 19 | + { |
| 20 | + $tester = new CommandTester(new DiffCommand(new PackageDiff())); |
| 21 | + $result = $tester->execute($input); |
| 22 | + $this->assertSame(0, $result); |
| 23 | + $this->assertSame($expectedOutput, $tester->getDisplay()); |
| 24 | + } |
| 25 | + |
| 26 | + public function commandArgumentsDataProvider() |
| 27 | + { |
| 28 | + return array( |
| 29 | + 'with platform' => array( |
| 30 | + <<<OUTPUT |
| 31 | +| Prod Packages | Base | Target | |
| 32 | +|------------------------------------|---------|---------| |
| 33 | +| psr/event-dispatcher | New | 1.0.0 | |
| 34 | +| symfony/deprecation-contracts | New | v2.1.2 | |
| 35 | +| symfony/event-dispatcher | v2.8.52 | v5.1.2 | |
| 36 | +| symfony/event-dispatcher-contracts | New | v2.1.2 | |
| 37 | +| symfony/polyfill-php80 | New | v1.17.1 | |
| 38 | +| php | New | >=5.3 | |
| 39 | +
|
| 40 | +| Dev Packages | Base | Target | |
| 41 | +|------------------------------------|-------|---------| |
| 42 | +| phpunit/php-code-coverage | 8.0.2 | 7.0.10 | |
| 43 | +| phpunit/php-file-iterator | 3.0.2 | 2.0.2 | |
| 44 | +| phpunit/php-text-template | 2.0.1 | 1.2.1 | |
| 45 | +| phpunit/php-timer | 5.0.0 | 2.1.2 | |
| 46 | +| phpunit/php-token-stream | 4.0.2 | 3.1.1 | |
| 47 | +| phpunit/phpunit | 9.2.5 | 8.5.8 | |
| 48 | +| sebastian/code-unit-reverse-lookup | 2.0.1 | 1.0.1 | |
| 49 | +| sebastian/comparator | 4.0.2 | 3.0.2 | |
| 50 | +| sebastian/diff | 4.0.1 | 3.0.2 | |
| 51 | +| sebastian/environment | 5.1.1 | 4.2.3 | |
| 52 | +| sebastian/exporter | 4.0.1 | 3.1.2 | |
| 53 | +| sebastian/global-state | 4.0.0 | 3.0.0 | |
| 54 | +| sebastian/object-enumerator | 4.0.1 | 3.0.3 | |
| 55 | +| sebastian/object-reflector | 2.0.1 | 1.1.1 | |
| 56 | +| sebastian/recursion-context | 4.0.1 | 3.0.0 | |
| 57 | +| sebastian/resource-operations | 3.0.1 | 2.0.1 | |
| 58 | +| sebastian/type | 2.1.0 | 1.1.3 | |
| 59 | +| sebastian/version | 3.0.0 | 2.0.1 | |
| 60 | +| phpunit/php-invoker | 3.0.1 | Removed | |
| 61 | +| sebastian/code-unit | 1.0.3 | Removed | |
| 62 | +
|
| 63 | +
|
| 64 | +OUTPUT |
| 65 | + , |
| 66 | + array( |
| 67 | + '--base' => __DIR__.'/../fixtures/base/composer.lock', |
| 68 | + '--target' => __DIR__.'/../fixtures/target/composer.lock', |
| 69 | + '-p' => null, |
| 70 | + ) |
| 71 | + ), |
| 72 | + 'no-dev' => array( |
| 73 | + <<<OUTPUT |
| 74 | +| Prod Packages | Base | Target | |
| 75 | +|------------------------------------|---------|---------| |
| 76 | +| psr/event-dispatcher | New | 1.0.0 | |
| 77 | +| symfony/deprecation-contracts | New | v2.1.2 | |
| 78 | +| symfony/event-dispatcher | v2.8.52 | v5.1.2 | |
| 79 | +| symfony/event-dispatcher-contracts | New | v2.1.2 | |
| 80 | +| symfony/polyfill-php80 | New | v1.17.1 | |
| 81 | +
|
| 82 | +
|
| 83 | +OUTPUT |
| 84 | + , |
| 85 | + array( |
| 86 | + '--base' => __DIR__.'/../fixtures/base/composer.lock', |
| 87 | + '--target' => __DIR__.'/../fixtures/target/composer.lock', |
| 88 | + '--no-dev' => null, |
| 89 | + ) |
| 90 | + ), |
| 91 | + 'no-prod' => array( |
| 92 | + <<<OUTPUT |
| 93 | +| Dev Packages | Base | Target | |
| 94 | +|------------------------------------|-------|---------| |
| 95 | +| phpunit/php-code-coverage | 8.0.2 | 7.0.10 | |
| 96 | +| phpunit/php-file-iterator | 3.0.2 | 2.0.2 | |
| 97 | +| phpunit/php-text-template | 2.0.1 | 1.2.1 | |
| 98 | +| phpunit/php-timer | 5.0.0 | 2.1.2 | |
| 99 | +| phpunit/php-token-stream | 4.0.2 | 3.1.1 | |
| 100 | +| phpunit/phpunit | 9.2.5 | 8.5.8 | |
| 101 | +| sebastian/code-unit-reverse-lookup | 2.0.1 | 1.0.1 | |
| 102 | +| sebastian/comparator | 4.0.2 | 3.0.2 | |
| 103 | +| sebastian/diff | 4.0.1 | 3.0.2 | |
| 104 | +| sebastian/environment | 5.1.1 | 4.2.3 | |
| 105 | +| sebastian/exporter | 4.0.1 | 3.1.2 | |
| 106 | +| sebastian/global-state | 4.0.0 | 3.0.0 | |
| 107 | +| sebastian/object-enumerator | 4.0.1 | 3.0.3 | |
| 108 | +| sebastian/object-reflector | 2.0.1 | 1.1.1 | |
| 109 | +| sebastian/recursion-context | 4.0.1 | 3.0.0 | |
| 110 | +| sebastian/resource-operations | 3.0.1 | 2.0.1 | |
| 111 | +| sebastian/type | 2.1.0 | 1.1.3 | |
| 112 | +| sebastian/version | 3.0.0 | 2.0.1 | |
| 113 | +| phpunit/php-invoker | 3.0.1 | Removed | |
| 114 | +| sebastian/code-unit | 1.0.3 | Removed | |
| 115 | +
|
| 116 | +
|
| 117 | +OUTPUT |
| 118 | + , |
| 119 | + array( |
| 120 | + '--base' => __DIR__.'/../fixtures/base/composer.lock', |
| 121 | + '--target' => __DIR__.'/../fixtures/target/composer.lock', |
| 122 | + '--no-prod' => null, |
| 123 | + ) |
| 124 | + ), |
| 125 | + 'reversed, with platform' => array( |
| 126 | + <<<OUTPUT |
| 127 | +| Prod Packages | Base | Target | |
| 128 | +|------------------------------------|---------|---------| |
| 129 | +| symfony/event-dispatcher | v5.1.2 | v2.8.52 | |
| 130 | +| psr/event-dispatcher | 1.0.0 | Removed | |
| 131 | +| symfony/deprecation-contracts | v2.1.2 | Removed | |
| 132 | +| symfony/event-dispatcher-contracts | v2.1.2 | Removed | |
| 133 | +| symfony/polyfill-php80 | v1.17.1 | Removed | |
| 134 | +| php | >=5.3 | Removed | |
| 135 | +
|
| 136 | +| Dev Packages | Base | Target | |
| 137 | +|------------------------------------|--------|--------| |
| 138 | +| phpunit/php-code-coverage | 7.0.10 | 8.0.2 | |
| 139 | +| phpunit/php-file-iterator | 2.0.2 | 3.0.2 | |
| 140 | +| phpunit/php-invoker | New | 3.0.1 | |
| 141 | +| phpunit/php-text-template | 1.2.1 | 2.0.1 | |
| 142 | +| phpunit/php-timer | 2.1.2 | 5.0.0 | |
| 143 | +| phpunit/php-token-stream | 3.1.1 | 4.0.2 | |
| 144 | +| phpunit/phpunit | 8.5.8 | 9.2.5 | |
| 145 | +| sebastian/code-unit | New | 1.0.3 | |
| 146 | +| sebastian/code-unit-reverse-lookup | 1.0.1 | 2.0.1 | |
| 147 | +| sebastian/comparator | 3.0.2 | 4.0.2 | |
| 148 | +| sebastian/diff | 3.0.2 | 4.0.1 | |
| 149 | +| sebastian/environment | 4.2.3 | 5.1.1 | |
| 150 | +| sebastian/exporter | 3.1.2 | 4.0.1 | |
| 151 | +| sebastian/global-state | 3.0.0 | 4.0.0 | |
| 152 | +| sebastian/object-enumerator | 3.0.3 | 4.0.1 | |
| 153 | +| sebastian/object-reflector | 1.1.1 | 2.0.1 | |
| 154 | +| sebastian/recursion-context | 3.0.0 | 4.0.1 | |
| 155 | +| sebastian/resource-operations | 2.0.1 | 3.0.1 | |
| 156 | +| sebastian/type | 1.1.3 | 2.1.0 | |
| 157 | +| sebastian/version | 2.0.1 | 3.0.0 | |
| 158 | +
|
| 159 | +
|
| 160 | +OUTPUT |
| 161 | + , |
| 162 | + array( |
| 163 | + '--base' => __DIR__.'/../fixtures/target/composer.lock', |
| 164 | + '--target' => __DIR__.'/../fixtures/base/composer.lock', |
| 165 | + '-p' => null, |
| 166 | + ) |
| 167 | + ), |
| 168 | + 'no changes' => array( |
| 169 | + '', |
| 170 | + array( |
| 171 | + '--base' => __DIR__.'/../fixtures/base/composer.lock', |
| 172 | + '--target' => __DIR__.'/../fixtures/base/composer.lock', |
| 173 | + '-p' => null, |
| 174 | + ) |
| 175 | + ), |
| 176 | + ); |
| 177 | + } |
| 178 | +} |
0 commit comments