Skip to content
Extraits de code Groupes Projets

Comparer les révisions

Les modifications sont affichées comme si la révision source était fusionnée avec la révision cible. En savoir plus sur la comparaison des révisions.

Source

Sélectionner le projet cible
No results found

Cible

Sélectionner le projet cible
  • spip-league/composer-installer
1 résultat
Afficher les modifications
Affichage de
avec 93 ajouts et 72 suppressions
......@@ -44,19 +44,20 @@ class PreferredInstallTest extends TestCase
],
'preferred' => ['spip/*' => 'source'],
'requires' => [
'mandatory' => new Link('mandatory', 'spip/mandatory', new Constraint('=', '*')),
'template' => new Link('template', 'spip/default-template', new Constraint('=', '*')),
'package' => new Link('package', 'spip/package', new Constraint('=', '*')),
'other-package' => new Link('other-package', 'other/package', new Constraint('=', '*')),
'private-template' => new Link('private-template', 'spip/private-template', new Constraint('=', '*')),
'back-office' => new Link('back-office', 'spip/back-office', new Constraint('=', '*')),
'mandatory' => new Link('mandatory', 'spip/mandatory', new Constraint('=', '*')),
'template' => new Link('template', 'spip/default-template', new Constraint('=', '*')),
'package' => new Link('package', 'spip/package', new Constraint('=', '*')),
'other-package' => new Link('other-package', 'other/package', new Constraint('=', '*')),
'private-template' => new Link('private-template', 'spip/private-template', new Constraint(
'=',
'*',
)),
'back-office' => new Link('back-office', 'spip/back-office', new Constraint('=', '*')),
],
'extra' => [
'spip' => [
'template' => 'spip/default-template',
'extensions' => [
'spip/mandatory',
],
'extensions' => ['spip/mandatory'],
'private_template' => 'spip/private-template',
'back_office' => 'spip/back-office',
],
......@@ -75,16 +76,14 @@ class PreferredInstallTest extends TestCase
],
'preferred' => ['one/*' => 'source', 'two/*' => 'source'],
'requires' => [
'mandatory1' => new Link('mandatory', 'one/mandatory1', new Constraint('=', '*')),
'template2' => new Link('template', 'two/template2', new Constraint('=', '*')),
'other-package' => new Link('other-package', 'other/package', new Constraint('=', '*')),
'mandatory1' => new Link('mandatory', 'one/mandatory1', new Constraint('=', '*')),
'template2' => new Link('template', 'two/template2', new Constraint('=', '*')),
'other-package' => new Link('other-package', 'other/package', new Constraint('=', '*')),
],
'extra' => [
'spip' => [
'template' => 'two/template2',
'extensions' => [
'one/mandatory1',
],
'extensions' => ['one/mandatory1'],
],
],
],
......
......@@ -19,7 +19,9 @@ use SpipLeague\Test\Composer\Fixtures\SpecificationStub;
class CollectionTest extends TestCase
{
private SpecificationStub $validStub;
private Collection $testCollection;
private RemoteUrls $changer;
protected function setUp(): void
......@@ -42,7 +44,6 @@ class CollectionTest extends TestCase
// An exception is thrown
}
public function testInvalidSpecificationByArrayAccess()
{
// Given
......@@ -140,7 +141,10 @@ class CollectionTest extends TestCase
$actual = \json_encode($this->testCollection);
// Then
$this->assertSame('{"valid":{"path":"path","source":"source"},"test":{"path":"path","source":"source"}}', $actual);
$this->assertSame(
'{"valid":{"path":"path","source":"source"},"test":{"path":"path","source":"source"}}',
$actual,
);
}
public static function dataFromJsonFile()
......@@ -186,7 +190,7 @@ class CollectionTest extends TestCase
$this->expectExceptionMessageMatches(',Fixtures/malformed.json" malformed,');
// When
Collection::fromJsonFile($this->changer, __DIR__ . '/../Fixtures/malformed.json');
Collection::fromJsonFile($this->changer, __DIR__ . '/../Fixtures/malformed.json');
// Then
// An exception is thrown
......
......@@ -3,12 +3,9 @@
namespace SpipLeague\Test\Composer\Extensions;
use Composer\Composer;
use Composer\Config;
use Composer\Factory as ComposerFactory;
use Composer\IO\NullIO;
use Composer\Package\Link;
use Composer\Package\RootPackage;
use Composer\Semver\Constraint\Constraint;
use Composer\Util\Platform;
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\DataProvider;
......@@ -16,7 +13,6 @@ use PHPUnit\Framework\TestCase;
use SpipLeague\Composer\Extensions\InvalidSpecificationException;
use SpipLeague\Composer\Extensions\Specification;
use SpipLeague\Composer\SpipPaths;
use SpipLeague\Test\Composer\Fixtures\DummyConfigSource;
use SpipLeague\Test\Composer\Fixtures\RemoteUrlsStub;
#[CoversClass(Specification::class)]
......@@ -95,7 +91,7 @@ class SpecificationTest extends TestCase
if ($changer) {
$specification->setChanger(new RemoteUrlsStub(
'git@github.com:vendor/prefix.git',
'https://github.com/vendor/prefix.git'
'https://github.com/vendor/prefix.git',
));
}
......@@ -202,7 +198,7 @@ class SpecificationTest extends TestCase
{
// Given
Platform::putEnv('COMPOSER', 'tests/Fixtures/create-from-composer/composer.json');
$composer = ComposerFactory::create(new NullIO);
$composer = ComposerFactory::create(new NullIO());
// When
$actual = Specification::createFromComposer($composer, 'test/prefix');
......
......@@ -10,10 +10,14 @@ class CollectionMock implements CollectionInterface
{
protected int $position = 0;
/** @var string[] */
/**
* @var string[]
*/
protected array $keys = [];
/** @var array<string,SpecificationInterface> */
/**
* @var array<string,SpecificationInterface>
*/
protected array $collection = [];
private string $file;
......@@ -70,7 +74,7 @@ class CollectionMock implements CollectionInterface
public function offsetGet(mixed $offset): mixed
{
return isset($this->collection[$offset]) ? $this->collection[$offset] : null;
return $this->collection[$offset] ?? null;
}
public function offsetSet(mixed $offset, mixed $value): void
......@@ -79,7 +83,7 @@ class CollectionMock implements CollectionInterface
throw new InvalidSpecificationException('A collection must only contain valid specifications.', 3);
}
if (is_null($offset) || !\is_string($offset)) {
if ($offset === null || !\is_string($offset)) {
$offset = $value->getPrefix();
}
......
......@@ -8,10 +8,14 @@ use SpipLeague\Composer\Git\RemoteUrlsInterface;
class RemoteUrlsStub implements RemoteUrlsInterface
{
/** @var string[] */
/**
* @var string[]
*/
private array $ssh = [];
/** @var string[] */
/**
* @var string[]
*/
private array $https = [];
public function __construct(string ...$urls)
......
......@@ -22,7 +22,7 @@ class SpecificationMock implements SpecificationInterface
string $prefix = 'prefix',
string $vendorName = 'vendor/prefix',
string $constraint = '1.0',
string $path = 'path'
string $path = 'path',
) {
$this->prefix = $prefix;
$this->vendorName = $vendorName;
......
......@@ -18,7 +18,7 @@ class SpecificationStub implements SpecificationInterface
string $prefix = '',
string $vendorName = '',
string $constraint = '',
string $path = 'path'
string $path = 'path',
) {
$this->prefix = $prefix;
$this->vendorName = $vendorName;
......
......@@ -25,9 +25,7 @@ class SpipInstallerTest extends TestCase
$package->setExtra([
'spip' => [
'template' => 'spip/default-template',
'extensions' => [
'spip/mandatory',
],
'extensions' => ['spip/mandatory'],
],
]);
$composer->setPackage($package);
......
......@@ -43,11 +43,12 @@ class AnalyzerTest extends TestCase
$this->composer = new Composer();
$this->composer->setPackage($rootPackage);
$this->composer->setConfig(new Config());
$this->composer->getConfig()->setConfigSource(
new JsonConfigSource(new JsonFile($this->tmpDir . '/AnalyzerTest.json'))
);
$this->composer->getConfig()->getConfigSource()->addConfigSetting('test', 'test');
$this->composer->setLoop(new Loop(new HttpDownloader(new NullIO, $this->composer->getConfig())));
$this->composer->getConfig()
->setConfigSource(new JsonConfigSource(new JsonFile($this->tmpDir . '/AnalyzerTest.json')));
$this->composer->getConfig()
->getConfigSource()
->addConfigSetting('test', 'test');
$this->composer->setLoop(new Loop(new HttpDownloader(new NullIO(), $this->composer->getConfig())));
}
protected function tearDown(): void
......
......@@ -32,7 +32,10 @@ class AddSpecificationTest extends TestCase
$this->filesystem->emptyDirectory($this->tmpDir);
$this->collection = new CollectionMock($this->tmpDir . '/AddSpecificationTest.json');
$this->collection[] = new SpecificationMock('exist');
\file_put_contents($this->tmpDir . '/AddSpecificationTest.json', '{"exist":{"path":"path","source":"https://git-server/vendor/exist.git","branch":"1.0","tag":"v1.0.0"}}');
\file_put_contents(
$this->tmpDir . '/AddSpecificationTest.json',
'{"exist":{"path":"path","source":"https://git-server/vendor/exist.git","branch":"1.0","tag":"v1.0.0"}}',
);
}
protected function tearDown(): void
......@@ -52,7 +55,6 @@ class AddSpecificationTest extends TestCase
'expected' => \null,
'prefix' => 'exist',
],
];
}
......@@ -66,7 +68,7 @@ class AddSpecificationTest extends TestCase
$actual = $operation->mark($this->collection, $this->composer);
// Then
if (\is_null($expected)) {
if ($expected === null) {
$this->assertNull($actual);
} else {
$this->assertInstanceOf($expected, $actual);
......
......@@ -32,15 +32,18 @@ class AddToRequireTest extends TestCase
$this->filesystem->emptyDirectory($this->tmpDir);
$rootPackage = new RootPackage('test/test', '1', '1');
$rootPackage->setRequires(['vendor/exist' => new Link('test/test', 'vendor/exist', new Constraint('>=', '1.0'))]);
$rootPackage->setRequires(
['vendor/exist' => new Link('test/test', 'vendor/exist', new Constraint('>=', '1.0'))],
);
$this->composer = new Composer();
$this->composer->setConfig(new Config());
$this->composer->getConfig()->setConfigSource(
new JsonConfigSource(new JsonFile($this->tmpDir . '/AddToRequireTest.json'))
);
$this->composer->getConfig()
->setConfigSource(new JsonConfigSource(new JsonFile($this->tmpDir . '/AddToRequireTest.json')));
$this->composer->setPackage($rootPackage);
$this->composer->getConfig()->getConfigSource()->addLink('require', 'vendor/exist', '^1.0');
$this->composer->getConfig()
->getConfigSource()
->addLink('require', 'vendor/exist', '^1.0');
}
protected function tearDown(): void
......
......@@ -32,14 +32,16 @@ class AddToSpipExtraExtensionsTest extends TestCase
$this->composer = new Composer();
$this->composer->setConfig(new Config());
$this->composer->getConfig()->setConfigSource(
new JsonConfigSource(new JsonFile($this->tmpDir . '/AddToSpipExtraExtensionsTest.json'))
);
$this->composer->getConfig()
->setConfigSource(new JsonConfigSource(new JsonFile($this->tmpDir . '/AddToSpipExtraExtensionsTest.json')));
$rootPackage = new RootPackage('test/test', '1', '1');
$this->composer->setPackage($rootPackage);
$this->composer->getConfig()->getConfigSource()->addProperty('extra.spip.extensions', ['vendor/exist']);
$this->composer->getPackage()->setExtra(['spip' => ['extensions' => ['vendor/exist']]]);
$this->composer->getConfig()
->getConfigSource()
->addProperty('extra.spip.extensions', ['vendor/exist']);
$this->composer->getPackage()
->setExtra(['spip' => ['extensions' => ['vendor/exist']]]);
}
protected function tearDown(): void
......@@ -72,7 +74,7 @@ class AddToSpipExtraExtensionsTest extends TestCase
$actual = $operation->mark(new CollectionDummy(), $this->composer);
// Then
if (\is_null($expected)) {
if ($expected === null) {
$this->assertNull($actual);
} else {
$this->assertInstanceOf($expected, $actual);
......
......@@ -50,7 +50,6 @@ class RemoveDirectoryTest extends TestCase
'expected' => OperationInterface::class,
'directory' => 'empty',
],
];
}
......@@ -64,7 +63,7 @@ class RemoveDirectoryTest extends TestCase
$actual = $operation->mark(new CollectionDummy(), new Composer());
// Then
if (\is_null($expected)) {
if ($expected === null) {
$this->assertNull($actual);
} else {
$this->assertInstanceOf($expected, $actual);
......
......@@ -33,15 +33,18 @@ class RemoveFromRequireTest extends TestCase
$this->filesystem->emptyDirectory($this->tmpDir);
$rootPackage = new RootPackage('test/test', '1', '1');
$rootPackage->setRequires(['vendor/exist' => new Link('test/test', 'vendor/exist', new Constraint('>=', '1.0'))]);
$rootPackage->setRequires(
['vendor/exist' => new Link('test/test', 'vendor/exist', new Constraint('>=', '1.0'))],
);
$this->composer = new Composer();
$this->composer->setConfig(new Config());
$this->composer->getConfig()->setConfigSource(
new JsonConfigSource(new JsonFile($this->tmpDir . '/RemoveFromRequireTest.json'))
);
$this->composer->getConfig()
->setConfigSource(new JsonConfigSource(new JsonFile($this->tmpDir . '/RemoveFromRequireTest.json')));
$this->composer->setPackage($rootPackage);
$this->composer->getConfig()->getConfigSource()->addLink('require', 'vendor/exist', '^1.0');
$this->composer->getConfig()
->getConfigSource()
->addLink('require', 'vendor/exist', '^1.0');
}
protected function tearDown(): void
......@@ -75,7 +78,7 @@ class RemoveFromRequireTest extends TestCase
$actual = $operation->mark(new CollectionDummy(), $this->composer);
// Then
if (\is_null($expected)) {
if ($expected === null) {
$this->assertNull($actual);
} else {
$this->assertInstanceOf($expected, $actual);
......
......@@ -32,14 +32,18 @@ class RemoveFromSpipExtraExtensionsTest extends TestCase
$this->composer = new Composer();
$this->composer->setConfig(new Config());
$this->composer->getConfig()->setConfigSource(
new JsonConfigSource(new JsonFile($this->tmpDir . '/RemoveFromSpipExtraExtensionsTest.json'))
);
$this->composer->getConfig()
->setConfigSource(
new JsonConfigSource(new JsonFile($this->tmpDir . '/RemoveFromSpipExtraExtensionsTest.json')),
);
$rootPackage = new RootPackage('test/test', '1', '1');
$this->composer->setPackage($rootPackage);
$this->composer->getConfig()->getConfigSource()->addProperty('extra.spip.extensions', ['vendor/exist']);
$this->composer->getPackage()->setExtra(['spip' => ['extensions' => ['vendor/exist']]]);
$this->composer->getConfig()
->getConfigSource()
->addProperty('extra.spip.extensions', ['vendor/exist']);
$this->composer->getPackage()
->setExtra(['spip' => ['extensions' => ['vendor/exist']]]);
}
protected function tearDown(): void
......@@ -72,7 +76,7 @@ class RemoveFromSpipExtraExtensionsTest extends TestCase
$actual = $operation->mark(new CollectionDummy(), $this->composer);
// Then
if (\is_null($expected)) {
if ($expected === null) {
$this->assertNull($actual);
} else {
$this->assertInstanceOf($expected, $actual);
......
......@@ -31,7 +31,10 @@ class RemoveSpecificationTest extends TestCase
$this->filesystem->emptyDirectory($this->tmpDir);
$this->collection = new CollectionMock($this->tmpDir . '/RemoveSpecificationTest.json');
$this->collection[] = new SpecificationMock('exist');
\file_put_contents($this->tmpDir . '/RemoveSpecificationTest.json', '{"exist":{"path":"path","source":"source","branch":"1.0"}}');
\file_put_contents(
$this->tmpDir . '/RemoveSpecificationTest.json',
'{"exist":{"path":"path","source":"source","branch":"1.0"}}',
);
}
protected function tearDown(): void
......@@ -51,7 +54,6 @@ class RemoveSpecificationTest extends TestCase
'expected' => OperationInterface::class,
'prefix' => 'exist',
],
];
}
......@@ -65,7 +67,7 @@ class RemoveSpecificationTest extends TestCase
$actual = $operation->mark($this->collection, $this->composer);
// Then
if (\is_null($expected)) {
if ($expected === null) {
$this->assertNull($actual);
} else {
$this->assertInstanceOf($expected, $actual);
......
......@@ -64,7 +64,7 @@ class SwitcherTest extends TestCase
// When
$switcher->to($operation);
foreach($switcher->flush(fn() => $this->composer) as $message) {
foreach ($switcher->flush(fn() => $this->composer) as $message) {
$actual[] = $message;
}
......