Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cleanup tests from annotations #86

Merged
merged 5 commits into from
Oct 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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());
}
}
Loading