Skip to content

Commit

Permalink
Cleanup tests from annotations (#86)
Browse files Browse the repository at this point in the history
  • Loading branch information
mondrake authored Oct 28, 2024
1 parent c8c686c commit 3840fd5
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 39 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/code-quality.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@ jobs:

- name: "Require tools"
continue-on-error: true
run: composer require --ansi --dev "vimeo/psalm:^5.15" "phpstan/phpstan:>=1.10" "squizlabs/php_codesniffer:>=3.7" "phpunit/phpunit:>=10"
run: |
composer config --no-plugins allow-plugins.phpstan/extension-installer true
composer require --ansi --dev "vimeo/psalm:^5.15" "phpstan/phpstan:>=1.10" "phpstan/extension-installer:>=1.4" "phpstan/phpstan-phpunit:>=1.4" "squizlabs/php_codesniffer:>=3.7" "phpunit/phpunit:>=10"
- name: "Run static analysis with phpstan/phpstan"
run: "vendor/bin/phpstan"
Expand Down
11 changes: 1 addition & 10 deletions tests/src/MapHandlerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,10 @@
use PHPUnit\Framework\Attributes\BackupStaticProperties;
use PHPUnit\Framework\Attributes\DataProvider;

/**
* @backupStaticAttributes enabled
*/
#[BackupStaticProperties(true)]
class MapHandlerTest extends MimeMapTestBase
{
/**
* @var MimeMapInterface
*/
protected $map;
protected readonly MimeMapInterface $map;

public function setUp(): void
{
Expand Down Expand Up @@ -364,9 +358,6 @@ public static function malformedTypeProvider(): array
];
}

/**
* @dataProvider malformedTypeProvider
*/
#[DataProvider('malformedTypeProvider')]
public function testAddMalformedTypeExtensionMapping(string $type): void
{
Expand Down
18 changes: 4 additions & 14 deletions tests/src/MapUpdaterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,23 +10,13 @@
use PHPUnit\Framework\Attributes\BackupStaticProperties;
use PHPUnit\Framework\Attributes\CoversClass;

/**
* @coversDefaultClass \FileEye\MimeMap\MapUpdater
* @backupStaticAttributes enabled
*/
#[CoversClass(MapUpdater::class)]
#[BackupStaticProperties(true)]
class MapUpdaterTest extends MimeMapTestBase
{

/** @var MimeMapInterface */
protected $newMap;

/** @var MapUpdater */
protected $updater;

/** @var Filesystem */
protected $fileSystem;
protected readonly MimeMapInterface $newMap;
protected readonly MapUpdater $updater;
protected readonly Filesystem $fileSystem;

public function setUp(): void
{
Expand Down Expand Up @@ -152,7 +142,7 @@ public function testLoadMapFromFreedesktopInvalidFile(): void
public function testEmptyMapNotWriteable(): void
{
$this->expectException('LogicException');
$this->assertNull($this->newMap->getFileName());
$this->assertSame('', $this->newMap->getFileName());
}

public function testWriteMapToPhpClassFile(): void
Expand Down
17 changes: 3 additions & 14 deletions tests/src/TypeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -424,8 +424,6 @@ public static function parseProvider(): array
}

/**
* @dataProvider parseProvider
*
* @param string $type
* @param string[] $expectedToString
* @param string[] $expectedMedia
Expand Down Expand Up @@ -489,9 +487,6 @@ public static function parseMalformedProvider(): array
];
}

/**
* @dataProvider parseMalformedProvider
*/
#[DataProvider('parseMalformedProvider')]
public function testParseMalformed(string $type): void
{
Expand All @@ -502,10 +497,10 @@ public function testParseMalformed(string $type): void
public function testParseAgain(): void
{
$mt = new Type('application/ogg;description=Hello there!;asd=fgh');
$this->assertSame(2, count($mt->getParameters()));
$this->assertCount(2, $mt->getParameters());

$mt = new Type('text/plain;hello=there!');
$this->assertSame(1, count($mt->getParameters()));
$this->assertCount(1, $mt->getParameters());
}

public function testGetDescription(): void
Expand Down Expand Up @@ -536,9 +531,6 @@ public static function missingDescriptionProvider(): array
];
}

/**
* @dataProvider missingDescriptionProvider
*/
#[DataProvider('missingDescriptionProvider')]
public function testMissingDescription(string $type): void
{
Expand Down Expand Up @@ -730,13 +722,10 @@ public static function getDefaultExtensionFailProvider()
];
}

/**
* @dataProvider getDefaultExtensionFailProvider
*/
#[DataProvider('getDefaultExtensionFailProvider')]
public function testGetDefaultExtensionFail(string $type): void
{
$this->expectException(MappingException::class);
$this->assertNull((new Type($type))->getDefaultExtension());
$this->assertSame('', (new Type($type))->getDefaultExtension());
}
}

0 comments on commit 3840fd5

Please sign in to comment.