Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added Steam Deck support to app details parser and accompanying test.
- Loading branch information
Showing
4 changed files
with
127 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<?php | ||
declare(strict_types=1); | ||
|
||
namespace ScriptFUSION\Porter\Provider\Steam\Scrape; | ||
|
||
use Eloquent\Enumeration\AbstractEnumeration; | ||
|
||
/** | ||
* @method static self UNSUPPORTED | ||
* @method static self VERIFIED | ||
* @method static self PLAYABLE | ||
*/ | ||
final class SteamDeckCompatibility extends AbstractEnumeration | ||
{ | ||
public const UNSUPPORTED = 'UNSUPPORTED'; | ||
public const VERIFIED = 'VERIFIED'; | ||
public const PLAYABLE = 'PLAYABLE'; | ||
|
||
private const ID_MAP = [ | ||
1 => self::UNSUPPORTED, | ||
2 => self::PLAYABLE, | ||
3 => self::VERIFIED, | ||
]; | ||
|
||
public static function fromId(int $id): self | ||
{ | ||
return self::memberByKey(self::ID_MAP[$id]); | ||
} | ||
|
||
public function toId(): int | ||
{ | ||
return array_search($this->key(), self::ID_MAP, true); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<?php | ||
declare(strict_types=1); | ||
|
||
namespace ScriptFUSIONTest\Porter\Provider\Steam\Unit; | ||
|
||
use ScriptFUSION\Porter\Provider\Steam\Scrape\SteamDeckCompatibility; | ||
use PHPUnit\Framework\TestCase; | ||
|
||
/** | ||
* @see SteamDeckCompatibility | ||
*/ | ||
final class SteamDeckCompatibilityTest extends TestCase | ||
{ | ||
/** | ||
* @dataProvider provideIds | ||
*/ | ||
public function testIdRoundTrip(int $id): void | ||
{ | ||
self::assertInstanceOf(SteamDeckCompatibility::class, $compat = SteamDeckCompatibility::fromId($id)); | ||
self::assertSame($id, $compat->toId()); | ||
} | ||
|
||
public function provideIds(): iterable | ||
{ | ||
yield from \iter\chunk(range(1, 3), 1); | ||
} | ||
} |