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 167 ajouts et 59 suppressions
{
"name": "spip-league/create-from-composer",
"description": "Test Specification::createFromComposer",
"require": {
"test/prefix": "^1.0.x-dev"
}
}
{
"packages": [
{
"name": "test/prefix",
"version": "1.0.x-dev",
"source": {
"type": "git",
"url": "https://github.com/test/prefix.git",
"reference": "xxx"
},
"type": "library",
"description": "test prefix"
}
]
}
{
"one": {
"path": "path/to/one",
"source": "https://url/to/one.git"
"source": "https://url/to/one.git",
"branch": "main"
},
"two": {
"path": "path/to/two",
"source": "git@url:to/two.git"
"source": "git@url:to/two.git",
"branch": "main"
}
}
......@@ -19,7 +19,10 @@ class RemoteUrlsTest extends TestCase
$this->changer = new RemoteUrls(new ProcessExecutor(new NullIO()));
}
public static function dataHttpsToSsh()
/**
* @return array<string,mixed>
*/
public static function dataHttpsToSsh(): array
{
return [
'empty-url' => [
......@@ -38,12 +41,15 @@ class RemoteUrlsTest extends TestCase
}
#[DataProvider('dataHttpsToSsh')]
public function testToSsh($expected, $url)
public function testToSsh(string $expected, string $url): void
{
$this->assertSame($expected, $this->changer->toSsh($url));
}
public static function dataSshToHttps()
/**
* @return array<string,mixed>
*/
public static function dataSshToHttps(): array
{
return [
'empty-url' => [
......@@ -62,22 +68,22 @@ class RemoteUrlsTest extends TestCase
}
#[DataProvider('dataSshToHttps')]
public function testToHttps($expected, $url)
public function testToHttps(string $expected, string $url): void
{
$this->assertSame($expected, $this->changer->toHttps($url));
}
public function testGetRemote()
public function testGetRemote(): void
{
$this->assertSame('git -C test remote get-url origin', $this->changer->getRemote('test'));
}
public function testSetRemote()
public function testSetRemote(): void
{
$this->assertSame('git -C test remote set-url origin test-url', $this->changer->setRemote('test', 'test-url'));
}
public function testGetProcessor()
public function testGetProcessor(): void
{
$this->assertInstanceOf(ProcessExecutor::class, $this->changer->getProcessor());
}
......
......@@ -33,17 +33,16 @@ class SpipInstallerTest extends TestCase
$this->installer = new SpipInstaller($io, $composer);
}
public static function dataPluginTypes()
/**
* @return array<string,mixed>
*/
public static function dataPluginTypes(): array
{
return [
'library' => [
'expected' => false,
'type' => 'library',
],
'classic' => [
'expected' => true,
'type' => 'spip-classic',
],
'ecrire' => [
'expected' => true,
'type' => 'spip-ecrire',
......@@ -60,7 +59,7 @@ class SpipInstallerTest extends TestCase
}
#[DataProvider('dataPluginTypes')]
public function testSupports($expected, $type)
public function testSupports(bool $expected, string $type): void
{
$package = new Package('spip/test', '1.0.0', '1.0.0.0');
$package->setType($type);
......@@ -68,7 +67,10 @@ class SpipInstallerTest extends TestCase
$this->assertEquals($expected, $this->installer->supports($package->getType()));
}
public static function dataPluginPaths()
/**
* @return array<string,mixed>
*/
public static function dataPluginPaths(): array
{
return [
'library' => [
......@@ -77,11 +79,6 @@ class SpipInstallerTest extends TestCase
'type' => 'library',
],
'classic' => [
'expected' => './tmp/__spip_classic__',
'name' => 'spip/test',
'type' => 'spip-classic',
],
'ecrire' => [
'expected' => './' . SpipPaths::BACK_OFFICE,
'name' => 'spip/test',
......@@ -111,7 +108,7 @@ class SpipInstallerTest extends TestCase
}
#[DataProvider('dataPluginPaths')]
public function testGetInstallPath($expected, $name, $type)
public function testGetInstallPath(string $expected, string $name, string $type): void
{
$package = new Package($name, '1.0.0', '1.0.0.0');
$package->setType($type);
......@@ -119,7 +116,7 @@ class SpipInstallerTest extends TestCase
$this->assertSame($expected, $this->installer->getInstallPath($package));
}
public function testUnsupportedType()
public function testUnsupportedType(): void
{
$this->expectException(InvalidArgumentException::class);
$package = new Package('spip/test', '1.0.0', '1.0.0.0');
......
......@@ -20,6 +20,7 @@ use SpipLeague\Composer\Switch\Operation\AddToSpipExtraExtensions;
use SpipLeague\Composer\Switch\Operation\RemoveSpecification;
use SpipLeague\Test\Composer\Fixtures\CollectionMock;
use SpipLeague\Test\Composer\Fixtures\SpecificationMock;
use SpipLeague\Test\Composer\Fixtures\RemoteUrlsStub;
#[CoversClass(Analyzer::class)]
#[CoversClass(AddToRequire::class)]
......@@ -60,7 +61,10 @@ class AnalyzerTest extends TestCase
$this->filesystem->rmdir($this->tmpDir);
}
public static function dataForward()
/**
* @return array<string,mixed>
*/
public static function dataForward(): array
{
return [
'switch vendor/prefix' => [
......@@ -73,13 +77,16 @@ class AnalyzerTest extends TestCase
];
}
/**
* @param array<mixed> $expected
*/
#[DataProvider('dataForward')]
public function testForward($expected)
public function testForward(array $expected): void
{
// Given
$collection = new CollectionMock('');
$collection[] = new SpecificationMock();
$analyzer = new Analyzer($collection, $this->composer);
$analyzer = new Analyzer($collection, $this->composer, new RemoteUrlsStub());
$actual = [];
// When
......@@ -91,7 +98,10 @@ class AnalyzerTest extends TestCase
$this->assertEquals($expected, $actual);
}
public static function dataBaack()
/**
* @return array<string,mixed>
*/
public static function dataBack(): array
{
return [
'nothing' => [
......@@ -100,12 +110,15 @@ class AnalyzerTest extends TestCase
];
}
#[DataProvider('dataBaack')]
public function testBack($expected)
/**
* @param array<mixed> $expected
*/
#[DataProvider('dataBack')]
public function testBack(array $expected): void
{
// Given
$collection = new CollectionMock('');
$analyzer = new Analyzer($collection, $this->composer);
$analyzer = new Analyzer($collection, $this->composer, new RemoteUrlsStub());
$actual = [];
// When
......
......@@ -44,7 +44,10 @@ class AddSpecificationTest extends TestCase
$this->filesystem->rmdir($this->tmpDir);
}
public static function dataMark()
/**
* @return array<string,mixed>
*/
public static function dataMark(): array
{
return [
'not-exist' => [
......@@ -58,8 +61,11 @@ class AddSpecificationTest extends TestCase
];
}
/**
* @param ?class-string<object> $expected
*/
#[DataProvider('dataMark')]
public function testMark($expected, $prefix)
public function testMark(?string $expected, string $prefix): void
{
// Given
$operation = new AddSpecification(new SpecificationStub($prefix));
......@@ -75,7 +81,10 @@ class AddSpecificationTest extends TestCase
}
}
public static function dataDo()
/**
* @return array<string,mixed>
*/
public static function dataDo(): array
{
return [
'exist' => [
......@@ -89,8 +98,11 @@ class AddSpecificationTest extends TestCase
];
}
/**
* @param non-empty-string $expected
*/
#[DataProvider('dataDo')]
public function testDo($expected, $prefix)
public function testDo(string $expected, string $prefix): void
{
// Given
$operation = new AddSpecification(new SpecificationStub($prefix));
......
......@@ -52,7 +52,10 @@ class AddToRequireTest extends TestCase
$this->filesystem->rmdir($this->tmpDir);
}
public static function dataDo()
/**
* @return array<string,mixed>
*/
public static function dataDo(): array
{
return [
'exist' => [
......@@ -69,14 +72,15 @@ class AddToRequireTest extends TestCase
}
#[DataProvider('dataDo')]
public function testDo($expected, $vendorName, $constraint)
public function testDo(string $expected, string $vendorName, string $constraint): void
{
// Given
$operation = new AddToRequire($vendorName, $constraint);
// When
$actual = $operation->do(new CollectionDummy(), $this->composer);
$actualContent = \json_decode(\file_get_contents($this->tmpDir . '/AddToRequireTest.json'), \true);
/** @var array{require:array<string,string>} $actualContent */
$actualContent = \json_decode(\file_get_contents($this->tmpDir . '/AddToRequireTest.json') ?: '', \true);
$actualContent = $actualContent['require'][$vendorName] ?? \null;
// Then
......
......@@ -50,7 +50,10 @@ class AddToSpipExtraExtensionsTest extends TestCase
$this->filesystem->rmdir($this->tmpDir);
}
public static function dataMark()
/**
* @return array<string,mixed>
*/
public static function dataMark(): array
{
return [
'exist' => [
......@@ -64,8 +67,11 @@ class AddToSpipExtraExtensionsTest extends TestCase
];
}
/**
* @param ?class-string<object> $expected
*/
#[DataProvider('dataMark')]
public function testMark($expected, $vendorName)
public function testMark(?string $expected, string $vendorName): void
{
// Given
$operation = new AddToSpipExtraExtensions($vendorName);
......@@ -81,7 +87,10 @@ class AddToSpipExtraExtensionsTest extends TestCase
}
}
public static function dataDo()
/**
* @return array<string,mixed>
*/
public static function dataDo(): array
{
return [
'added' => [
......@@ -96,7 +105,7 @@ class AddToSpipExtraExtensionsTest extends TestCase
}
#[DataProvider('dataDo')]
public function testDo($expected, $vendorName)
public function testDo(string $expected, string $vendorName): void
{
// Given
$operation = new AddToSpipExtraExtensions($vendorName);
......
......@@ -39,7 +39,10 @@ class RemoveDirectoryTest extends TestCase
$this->filesystem->rmdir($this->tmpDir);
}
public static function dataMark()
/**
* @return array<string,mixed>
*/
public static function dataMark(): array
{
return [
'not-exist' => [
......@@ -53,8 +56,11 @@ class RemoveDirectoryTest extends TestCase
];
}
/**
* @param ?class-string<object> $expected
*/
#[DataProvider('dataMark')]
public function testMark($expected, $directory)
public function testMark(?string $expected, string $directory): void
{
// Given
$operation = new RemoveDirectory($this->filesystem, $this->tmpDir . '/' . $directory);
......@@ -70,7 +76,10 @@ class RemoveDirectoryTest extends TestCase
}
}
public static function dataDo()
/**
* @return array<string,mixed>
*/
public static function dataDo(): array
{
return [
'not-exists' => [
......@@ -92,7 +101,7 @@ class RemoveDirectoryTest extends TestCase
}
#[DataProvider('dataDo')]
public function testDo($expected, $directory, $ifEmpty)
public function testDo(string $expected, string $directory, bool $ifEmpty): void
{
// Given
$operation = new RemoveDirectory($this->filesystem, $this->tmpDir . '/' . $directory, $ifEmpty);
......
......@@ -53,7 +53,10 @@ class RemoveFromRequireTest extends TestCase
$this->filesystem->rmdir($this->tmpDir);
}
public static function dataMark()
/**
* @return array<string,mixed>
*/
public static function dataMark(): array
{
return [
'not-exist' => [
......@@ -68,8 +71,11 @@ class RemoveFromRequireTest extends TestCase
];
}
/**
* @param ?class-string<object> $expected
*/
#[DataProvider('dataMark')]
public function testMark($expected, $vendorName)
public function testMark(?string $expected, string $vendorName): void
{
// Given
$operation = new RemoveFromRequire($vendorName);
......@@ -85,7 +91,10 @@ class RemoveFromRequireTest extends TestCase
}
}
public static function dataDo()
/**
* @return array<string,mixed>
*/
public static function dataDo(): array
{
return [
'exist' => [
......@@ -96,7 +105,7 @@ class RemoveFromRequireTest extends TestCase
}
#[DataProvider('dataDo')]
public function testDo($expected, $vendorName)
public function testDo(string $expected, string $vendorName): void
{
// Given
$operation = new RemoveFromRequire($vendorName);
......
......@@ -52,7 +52,10 @@ class RemoveFromSpipExtraExtensionsTest extends TestCase
$this->filesystem->rmdir($this->tmpDir);
}
public static function dataMark()
/**
* @return array<string,mixed>
*/
public static function dataMark(): array
{
return [
'exist' => [
......@@ -66,8 +69,11 @@ class RemoveFromSpipExtraExtensionsTest extends TestCase
];
}
/**
* @param ?class-string<object> $expected
*/
#[DataProvider('dataMark')]
public function testMark($expected, $vendorName)
public function testMark(?string $expected, string $vendorName): void
{
// Given
$operation = new RemoveFromSpipExtraExtensions($vendorName);
......@@ -83,7 +89,10 @@ class RemoveFromSpipExtraExtensionsTest extends TestCase
}
}
public static function dataDo()
/**
* @return array<string,mixed>
*/
public static function dataDo(): array
{
return [
'removed' => [
......@@ -98,7 +107,7 @@ class RemoveFromSpipExtraExtensionsTest extends TestCase
}
#[DataProvider('dataDo')]
public function testDo($expected, $vendorName)
public function testDo(string $expected, string $vendorName): void
{
// Given
$operation = new RemoveFromSpipExtraExtensions($vendorName);
......
......@@ -43,7 +43,10 @@ class RemoveSpecificationTest extends TestCase
$this->filesystem->rmdir($this->tmpDir);
}
public static function dataMark()
/**
* @return array<string,mixed>
*/
public static function dataMark(): array
{
return [
'not-exist' => [
......@@ -57,8 +60,11 @@ class RemoveSpecificationTest extends TestCase
];
}
/**
* @param ?class-string<object> $expected
*/
#[DataProvider('dataMark')]
public function testMark($expected, $prefix)
public function testMark(?string $expected, string $prefix): void
{
// Given
$operation = new RemoveSpecification($prefix);
......@@ -74,7 +80,10 @@ class RemoveSpecificationTest extends TestCase
}
}
public static function dataDo()
/**
* @return array<string,mixed>
*/
public static function dataDo(): array
{
return [
'exist' => [
......@@ -89,7 +98,7 @@ class RemoveSpecificationTest extends TestCase
}
#[DataProvider('dataDo')]
public function testDo($expected, $prefix)
public function testDo(string $expected, string $prefix): void
{
// Given
$operation = new RemoveSpecification($prefix);
......
......@@ -7,6 +7,7 @@ use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\TestCase;
use SpipLeague\Composer\Extensions\CollectionInterface;
use SpipLeague\Composer\Switch\Operation\OperationInterface;
use SpipLeague\Composer\Switch\Switcher;
use SpipLeague\Test\Composer\Fixtures\CollectionDummy;
use SpipLeague\Test\Composer\Fixtures\OperationMock;
......@@ -30,7 +31,10 @@ class SwitcherTest extends TestCase
unset($this->collection);
}
public static function dataToAndSwitch()
/**
* @return array<string,mixed>
*/
public static function dataToAndSwitch(): array
{
return [
'nothing' => [
......@@ -55,8 +59,11 @@ class SwitcherTest extends TestCase
];
}
/**
* @param array<string> $expected
*/
#[DataProvider('dataToAndSwitch')]
public function testToAndFlush($expected, $operation)
public function testToAndFlush(array $expected, OperationInterface $operation): void
{
// Given
$switcher = new Switcher($this->collection, $this->composer);
......