mirror of
https://codeberg.org/vlw/php-xenum.git
synced 2025-09-13 20:23:41 +02:00
feat: add CI
This commit is contained in:
parent
243abfc531
commit
3a9e7eff73
4 changed files with 1742 additions and 1 deletions
21
.github/workflows/ci.yml
vendored
Normal file
21
.github/workflows/ci.yml
vendored
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
name: PHP xEnum CI
|
||||||
|
run-name: PHP xEnum CI
|
||||||
|
on: [push, pull_request]
|
||||||
|
jobs:
|
||||||
|
build-test:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
php-versions: ["8.2"]
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Setup PHP
|
||||||
|
uses: shivammathur/setup-php@v2
|
||||||
|
with:
|
||||||
|
php-version: ${{ matrix.php-versions }}
|
||||||
|
|
||||||
|
- name: Run PHPUnit tests
|
||||||
|
uses: php-actions/phpunit@v3
|
|
@ -15,5 +15,8 @@
|
||||||
"victorwesterlund\\": "src/"
|
"victorwesterlund\\": "src/"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"require": {}
|
"require": {},
|
||||||
|
"require-dev": {
|
||||||
|
"phpunit/phpunit": "^10"
|
||||||
|
}
|
||||||
}
|
}
|
1672
composer.lock
generated
Normal file
1672
composer.lock
generated
Normal file
File diff suppressed because it is too large
Load diff
45
tests/xEnumTest.php
Normal file
45
tests/xEnumTest.php
Normal file
|
@ -0,0 +1,45 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use \PHPUnit\Framework\TestCase;
|
||||||
|
|
||||||
|
use \victorwesterlund\xEnum;
|
||||||
|
|
||||||
|
require_once dirname(__DIR__) . "/src/xEnum.php";
|
||||||
|
|
||||||
|
enum Test: string {
|
||||||
|
use xEnum;
|
||||||
|
|
||||||
|
case TEST1 = "test1";
|
||||||
|
case TEST2 = "test2";
|
||||||
|
case TEST3 = "test3";
|
||||||
|
}
|
||||||
|
|
||||||
|
final class xEnumTest extends TestCase {
|
||||||
|
const VALUES = [
|
||||||
|
"TEST1" => "test1",
|
||||||
|
"TEST2" => "test2",
|
||||||
|
"TEST3" => "test3"
|
||||||
|
];
|
||||||
|
|
||||||
|
public function testFromName(): void {
|
||||||
|
$test = Test::TEST1;
|
||||||
|
$this->assertSame($test, Test::fromName($test->name));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testTryFromName(): void {
|
||||||
|
$test = Test::TEST1;
|
||||||
|
$this->assertSame($test, Test::tryFromName($test->name));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testTryFromNameInvalid(): void {
|
||||||
|
$this->assertSame(null, Test::tryFromName("INVALID"));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testNames(): void {
|
||||||
|
$this->assertSame(array_keys(self::VALUES), Test::names());
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testValues(): void {
|
||||||
|
$this->assertSame(array_values(self::VALUES), Test::values());
|
||||||
|
}
|
||||||
|
}
|
Loading…
Add table
Reference in a new issue