Skip to content

Commit

Permalink
Merge pull request #10 from moufmouf/composer2
Browse files Browse the repository at this point in the history
Upgrading plugin to Composer 2
  • Loading branch information
moufmouf committed Oct 27, 2020
2 parents 8bad73d + 50835d5 commit c5d1580
Show file tree
Hide file tree
Showing 24 changed files with 142 additions and 83 deletions.
21 changes: 21 additions & 0 deletions .scrutinizer.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
checks:
php: true

build:
environment:
php: 7.4
nodes:
my-tests:
dependencies:
before:
- cd tests && ./run.sh
analysis:
tests:
override:
- php-scrutinizer-run

filter:
paths:
- "src/*"
- "tests/*"

11 changes: 5 additions & 6 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
language: php
php:
- 7.0
- 7.1
- 7.2
- 7.3
- 7.4
before_script:
- composer self-update
- composer self-update --2
- composer clear-cache
- composer update
env:
Expand All @@ -18,7 +17,7 @@ script:
- cd ..; vendor/bin/phpunit
- "./vendor/bin/phpcs --standard=PSR2 ./src/ ./tests/unitTests --config-set ignore_warnings_on_exit
1"
- "./vendor/bin/humbug"
- "./vendor/bin/infection"
after_script:
- php vendor/bin/coveralls -v
- php vendor/bin/php-coveralls -v
- "./vendor/bin/couscous travis-auto-deploy --php-version=7.1"
24 changes: 15 additions & 9 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,26 +13,32 @@
}
],
"require": {
"php": ">=7.0.0",
"composer-plugin-api": "^1.0"
"php": ">=7.2",
"composer-plugin-api": "^1.0 || ^2.0"
},
"require-dev": {
"composer/composer": "^1.0",
"satooshi/php-coveralls": "^1.0",
"phpunit/phpunit": "~5.0",
"humbug/humbug": "~1.0",
"squizlabs/php_codesniffer": "^2.7.0",
"couscous/couscous": "^1.6"
"composer/composer": "^1 || ^2",
"composer/semver": "^1 || ^2 || ^3",
"php-coveralls/php-coveralls": "^2.4.2",
"phpunit/phpunit": "^8.5.8",
"squizlabs/php_codesniffer": "^2.9.2",
"couscous/couscous": "^1.8",
"infection/infection": "^0.17.7 || ^1.18.2"
},
"autoload": {
"psr-4": {
"TheCodingMachine\\Discovery\\": "src/"
}
},
"autoload-dev": {
"psr-4": {
"TheCodingMachine\\Discovery\\Tests\\": "tests/unitTests"
}
},
"extra": {
"class": "TheCodingMachine\\Discovery\\DiscoveryPlugin",
"branch-alias": {
"dev-master": "1.1.x-dev"
"dev-master": "1.3.x-dev"
}
},
"minimum-stability": "alpha",
Expand Down
16 changes: 16 additions & 0 deletions infection.json.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"source": {
"directories": [
"src"
]
},
"timeout": 15,
"logs": {
"text": "infection-log.txt",
"summary": "summary-log.txt",
"debug": "debug-log.txt"
},
"phpUnit": {
"configDir": "."
}
}
3 changes: 1 addition & 2 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false"
syntaxCheck="false"
bootstrap="vendor/autoload.php"
>
<testsuites>
Expand All @@ -26,7 +25,7 @@
</whitelist>
</filter>
<logging>
<log type="coverage-html" target="build/coverage" charset="UTF-8" yui="true" highlight="true"/>
<log type="coverage-html" target="build/coverage"/>
<log type="coverage-clover" target="build/logs/clover.xml"/>
</logging>
</phpunit>
2 changes: 1 addition & 1 deletion src/AssetsBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ private function getDiscoveryJson(PackageInterface $package) : array

$fileSystem = new Filesystem();

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

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

Expand Down
16 changes: 16 additions & 0 deletions src/DiscoveryPlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,4 +94,20 @@ public function getCapabilities()
CommandProvider::class => DiscoveryCommandProvider::class,
];
}

/**
* @inheritDoc
*/
public function deactivate(Composer $composer, IOInterface $io)
{

}

/**
* @inheritDoc
*/
public function uninstall(Composer $composer, IOInterface $io)
{

}
}
2 changes: 1 addition & 1 deletion tests/composer-test.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@
"thecodingmachine/discovery": "*",
"package/b": "*"
}
}
}
2 changes: 1 addition & 1 deletion tests/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ set -e
# Lets copy the code in a subdirectory of the tests, otherwise Composer cannot require the package.
rsync -av .. fixtures/copy/ --exclude tests --exclude vendor

COMPOSER=composer-test.json composer update -v
COMPOSER=composer-test.json composer update -vvv

#rm -rf fixtures/copy
8 changes: 4 additions & 4 deletions tests/unitTests/AbstractDiscoveryTest.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php


namespace TheCodingMachine\Discovery;
namespace TheCodingMachine\Discovery\Tests;


use Composer\Command\BaseCommand;
Expand All @@ -12,19 +12,19 @@
use Composer\Package\RootPackage;
use Composer\Repository\RepositoryInterface;
use Composer\Repository\RepositoryManager;
use PHPUnit\Framework\TestCase;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\BufferedOutput;
use TheCodingMachine\Discovery\Commands\ListAssetTypesCommand;

abstract class AbstractDiscoveryTest extends \PHPUnit_Framework_TestCase
abstract class AbstractDiscoveryTest extends TestCase
{
protected function getInstallationManagerMock(string $installPath = null) : InstallationManager
{
$installationManager = $this->createMock(InstallationManager::class);

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

return $installationManager;
}
Expand Down
8 changes: 6 additions & 2 deletions tests/unitTests/AssetOperationTest.php
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
<?php


namespace TheCodingMachine\Discovery;
namespace TheCodingMachine\Discovery\Tests;

use PHPUnit\Framework\TestCase;
use InvalidArgumentException;
use TheCodingMachine\Discovery\Asset;
use TheCodingMachine\Discovery\AssetOperation;
use TheCodingMachine\Discovery\Utils\JsonException;

class AssetOperationTest extends \PHPUnit_Framework_TestCase
class AssetOperationTest extends TestCase
{
public function testBuildFromString()
{
Expand Down
4 changes: 3 additions & 1 deletion tests/unitTests/AssetTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
namespace TheCodingMachine\Discovery;


class AssetTest extends \PHPUnit_Framework_TestCase
use PHPUnit\Framework\TestCase;

class AssetTest extends TestCase
{
public function testToSimpleArray()
{
Expand Down
4 changes: 3 additions & 1 deletion tests/unitTests/AssetTypeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@

namespace TheCodingMachine\Discovery;

class AssetTypeTest extends \PHPUnit_Framework_TestCase
use PHPUnit\Framework\TestCase;

class AssetTypeTest extends TestCase
{
public function testAssetTypeName()
{
Expand Down
3 changes: 2 additions & 1 deletion tests/unitTests/AssetsBuilderTest.php
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
<?php


namespace TheCodingMachine\Discovery;
namespace TheCodingMachine\Discovery\Tests;

use Composer\Installer\InstallationManager;
use Composer\IO\BufferIO;
use Composer\Package\Package;
use Composer\Repository\RepositoryInterface;
use TheCodingMachine\Discovery\AssetsBuilder;

class AssetsBuilderTest extends AbstractDiscoveryTest
{
Expand Down
12 changes: 4 additions & 8 deletions tests/unitTests/Commands/AddAssetCommandTest.php
Original file line number Diff line number Diff line change
@@ -1,19 +1,15 @@
<?php


namespace TheCodingMachine\Discovery\Commands;
namespace TheCodingMachine\Discovery\Tests\Commands;


use Composer\Console\Application;
use Symfony\Component\Console\Input\ArrayInput;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputDefinition;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Input\StringInput;
use Symfony\Component\Console\Output\BufferedOutput;
use Symfony\Component\Console\Tester\CommandTester;
use TheCodingMachine\Discovery\AbstractDiscoveryTest;
use TheCodingMachine\Discovery\Commands\AddAssetCommand;
use TheCodingMachine\Discovery\Tests\AbstractDiscoveryTest;

class AddAssetCommandTest extends AbstractDiscoveryTest
{
Expand Down Expand Up @@ -59,7 +55,7 @@ public function testCallWithBadPriority()

$result = $this->callCommand(new AddAssetCommand(), $input);

$this->assertContains('The priority must be a numeric value.', $result);
$this->assertStringContainsString('The priority must be a numeric value.', $result);

}

Expand Down
6 changes: 4 additions & 2 deletions tests/unitTests/Commands/CommandProviderTest.php
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
<?php


namespace TheCodingMachine\Discovery\Commands;
namespace TheCodingMachine\Discovery\Tests\Commands;


use PHPUnit\Framework\TestCase;
use Symfony\Component\Console\Command\Command;
use TheCodingMachine\Discovery\Commands\CommandProvider;

class CommandProviderTest extends \PHPUnit_Framework_TestCase
class CommandProviderTest extends TestCase
{
public function testCommandProvider()
{
Expand Down
14 changes: 4 additions & 10 deletions tests/unitTests/Commands/DumpCommandTest.php
Original file line number Diff line number Diff line change
@@ -1,19 +1,13 @@
<?php


namespace TheCodingMachine\Discovery\Commands;
namespace TheCodingMachine\Discovery\Tests\Commands;


use Composer\Console\Application;
use Symfony\Component\Console\Input\ArrayInput;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputDefinition;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Input\StringInput;
use Symfony\Component\Console\Output\BufferedOutput;
use Symfony\Component\Console\Tester\CommandTester;
use TheCodingMachine\Discovery\AbstractDiscoveryTest;
use TheCodingMachine\Discovery\Commands\DumpCommand;
use TheCodingMachine\Discovery\Tests\AbstractDiscoveryTest;

class DumpCommandTest extends AbstractDiscoveryTest
{
Expand All @@ -24,7 +18,7 @@ public function testCall()

$result = $this->callCommand(new DumpCommand(), $input);

$this->assertContains('Discovery files successfully dumped in the .discovery directory.', $result);
$this->assertStringContainsString('Discovery files successfully dumped in the .discovery directory.', $result);
}

}
24 changes: 10 additions & 14 deletions tests/unitTests/Commands/ListAssetTypesCommandTest.php
Original file line number Diff line number Diff line change
@@ -1,19 +1,15 @@
<?php


namespace TheCodingMachine\Discovery\Commands;
namespace TheCodingMachine\Discovery\Tests\Commands;


use Composer\Console\Application;
use Symfony\Component\Console\Input\ArrayInput;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputDefinition;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Input\StringInput;
use Symfony\Component\Console\Output\BufferedOutput;
use Symfony\Component\Console\Tester\CommandTester;
use TheCodingMachine\Discovery\AbstractDiscoveryTest;
use TheCodingMachine\Discovery\Commands\ListAssetTypesCommand;
use TheCodingMachine\Discovery\Tests\AbstractDiscoveryTest;

class ListAssetTypesCommandTest extends AbstractDiscoveryTest
{
Expand All @@ -31,9 +27,9 @@ public function testEmptyCall()

$result = $this->callCommand(new ListAssetTypesCommand(), $input);

$this->assertContains('test-asset:', $result);
$this->assertContains('a1', $result);
$this->assertContains('a2', $result);
$this->assertStringContainsString('test-asset:', $result);
$this->assertStringContainsString('a1', $result);
$this->assertStringContainsString('a2', $result);
}

public function testWithAssetType()
Expand All @@ -42,9 +38,9 @@ public function testWithAssetType()

$result = $this->callCommand(new ListAssetTypesCommand(), $input);

$this->assertContains('test-asset:', $result);
$this->assertContains('a1', $result);
$this->assertContains('a2', $result);
$this->assertStringContainsString('test-asset:', $result);
$this->assertStringContainsString('a1', $result);
$this->assertStringContainsString('a2', $result);
}

public function testJson()
Expand All @@ -63,6 +59,6 @@ public function testNoAssetType()

$result = $this->callCommand(new ListAssetTypesCommand(), $input);

$this->assertContains('Could not find the "toto" asset type.', $result);
$this->assertStringContainsString('Could not find the "toto" asset type.', $result);
}
}
Loading

0 comments on commit c5d1580

Please sign in to comment.