Skip to content
Extraits de code Groupes Projets
Valider 5445b1cb rédigé par JamesRezo's avatar JamesRezo :tada:
Parcourir les fichiers

test: passe phpstan

parent d035ec42
Aucune branche associée trouvée
Aucune étiquette associée trouvée
1 requête de fusion!13Add CI
Ce commit fait partie de la requête de fusion !13. Les commentaires créés ici seront créés dans le contexte de cette requête de fusion.
......@@ -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);
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter