Skip to content

Commit c5d1580

Browse files
authored
Merge pull request #10 from moufmouf/composer2
Upgrading plugin to Composer 2
2 parents 8bad73d + 50835d5 commit c5d1580

24 files changed

+142
-83
lines changed

.scrutinizer.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
checks:
2+
php: true
3+
4+
build:
5+
environment:
6+
php: 7.4
7+
nodes:
8+
my-tests:
9+
dependencies:
10+
before:
11+
- cd tests && ./run.sh
12+
analysis:
13+
tests:
14+
override:
15+
- php-scrutinizer-run
16+
17+
filter:
18+
paths:
19+
- "src/*"
20+
- "tests/*"
21+

.travis.yml

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
language: php
22
php:
3-
- 7.0
4-
- 7.1
5-
- 7.2
3+
- 7.3
4+
- 7.4
65
before_script:
7-
- composer self-update
6+
- composer self-update --2
87
- composer clear-cache
98
- composer update
109
env:
@@ -18,7 +17,7 @@ script:
1817
- cd ..; vendor/bin/phpunit
1918
- "./vendor/bin/phpcs --standard=PSR2 ./src/ ./tests/unitTests --config-set ignore_warnings_on_exit
2019
1"
21-
- "./vendor/bin/humbug"
20+
- "./vendor/bin/infection"
2221
after_script:
23-
- php vendor/bin/coveralls -v
22+
- php vendor/bin/php-coveralls -v
2423
- "./vendor/bin/couscous travis-auto-deploy --php-version=7.1"

composer.json

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,26 +13,32 @@
1313
}
1414
],
1515
"require": {
16-
"php": ">=7.0.0",
17-
"composer-plugin-api": "^1.0"
16+
"php": ">=7.2",
17+
"composer-plugin-api": "^1.0 || ^2.0"
1818
},
1919
"require-dev": {
20-
"composer/composer": "^1.0",
21-
"satooshi/php-coveralls": "^1.0",
22-
"phpunit/phpunit": "~5.0",
23-
"humbug/humbug": "~1.0",
24-
"squizlabs/php_codesniffer": "^2.7.0",
25-
"couscous/couscous": "^1.6"
20+
"composer/composer": "^1 || ^2",
21+
"composer/semver": "^1 || ^2 || ^3",
22+
"php-coveralls/php-coveralls": "^2.4.2",
23+
"phpunit/phpunit": "^8.5.8",
24+
"squizlabs/php_codesniffer": "^2.9.2",
25+
"couscous/couscous": "^1.8",
26+
"infection/infection": "^0.17.7 || ^1.18.2"
2627
},
2728
"autoload": {
2829
"psr-4": {
2930
"TheCodingMachine\\Discovery\\": "src/"
3031
}
3132
},
33+
"autoload-dev": {
34+
"psr-4": {
35+
"TheCodingMachine\\Discovery\\Tests\\": "tests/unitTests"
36+
}
37+
},
3238
"extra": {
3339
"class": "TheCodingMachine\\Discovery\\DiscoveryPlugin",
3440
"branch-alias": {
35-
"dev-master": "1.1.x-dev"
41+
"dev-master": "1.3.x-dev"
3642
}
3743
},
3844
"minimum-stability": "alpha",

infection.json.dist

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"source": {
3+
"directories": [
4+
"src"
5+
]
6+
},
7+
"timeout": 15,
8+
"logs": {
9+
"text": "infection-log.txt",
10+
"summary": "summary-log.txt",
11+
"debug": "debug-log.txt"
12+
},
13+
"phpUnit": {
14+
"configDir": "."
15+
}
16+
}

phpunit.xml.dist

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
convertWarningsToExceptions="true"
99
processIsolation="false"
1010
stopOnFailure="false"
11-
syntaxCheck="false"
1211
bootstrap="vendor/autoload.php"
1312
>
1413
<testsuites>
@@ -26,7 +25,7 @@
2625
</whitelist>
2726
</filter>
2827
<logging>
29-
<log type="coverage-html" target="build/coverage" charset="UTF-8" yui="true" highlight="true"/>
28+
<log type="coverage-html" target="build/coverage"/>
3029
<log type="coverage-clover" target="build/logs/clover.xml"/>
3130
</logging>
3231
</phpunit>

src/AssetsBuilder.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ private function getDiscoveryJson(PackageInterface $package) : array
116116

117117
$fileSystem = new Filesystem();
118118

119-
$packageDir = $fileSystem->makePathRelative($packageInstallPath, realpath($this->rootDir));
119+
$packageDir = $fileSystem->makePathRelative(realpath($packageInstallPath), realpath($this->rootDir));
120120

121121
$path = $packageInstallPath.'/discovery.json';
122122

src/DiscoveryPlugin.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,4 +94,20 @@ public function getCapabilities()
9494
CommandProvider::class => DiscoveryCommandProvider::class,
9595
];
9696
}
97+
98+
/**
99+
* @inheritDoc
100+
*/
101+
public function deactivate(Composer $composer, IOInterface $io)
102+
{
103+
104+
}
105+
106+
/**
107+
* @inheritDoc
108+
*/
109+
public function uninstall(Composer $composer, IOInterface $io)
110+
{
111+
112+
}
97113
}

tests/composer-test.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,4 @@
1818
"thecodingmachine/discovery": "*",
1919
"package/b": "*"
2020
}
21-
}
21+
}

tests/run.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,6 @@ set -e
55
# Lets copy the code in a subdirectory of the tests, otherwise Composer cannot require the package.
66
rsync -av .. fixtures/copy/ --exclude tests --exclude vendor
77

8-
COMPOSER=composer-test.json composer update -v
8+
COMPOSER=composer-test.json composer update -vvv
99

1010
#rm -rf fixtures/copy

tests/unitTests/AbstractDiscoveryTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?php
22

33

4-
namespace TheCodingMachine\Discovery;
4+
namespace TheCodingMachine\Discovery\Tests;
55

66

77
use Composer\Command\BaseCommand;
@@ -12,19 +12,19 @@
1212
use Composer\Package\RootPackage;
1313
use Composer\Repository\RepositoryInterface;
1414
use Composer\Repository\RepositoryManager;
15+
use PHPUnit\Framework\TestCase;
1516
use Symfony\Component\Console\Input\InputInterface;
1617
use Symfony\Component\Console\Output\BufferedOutput;
17-
use TheCodingMachine\Discovery\Commands\ListAssetTypesCommand;
1818

19-
abstract class AbstractDiscoveryTest extends \PHPUnit_Framework_TestCase
19+
abstract class AbstractDiscoveryTest extends TestCase
2020
{
2121
protected function getInstallationManagerMock(string $installPath = null) : InstallationManager
2222
{
2323
$installationManager = $this->createMock(InstallationManager::class);
2424

2525
// Configure the stub.
2626
$installationManager->method('getInstallPath')
27-
->willReturn($installPath ?? 'tests/fixtures/package_a');
27+
->willReturn(realpath($installPath ?? 'tests/fixtures/package_a'));
2828

2929
return $installationManager;
3030
}

0 commit comments

Comments
 (0)