Add Gitea Actions CI and JSON regression tests
Laravel Modules CI / PHP 8.5 / Laravel 13 (push) Successful in 1m27s

This commit is contained in:
Mark Gregory
2026-11-20 12:48:12 +00:00
parent 9c5533ef40
commit 390649afc6
2 changed files with 102 additions and 0 deletions
+44
View File
@@ -0,0 +1,44 @@
name: Laravel Modules CI
on:
push:
branches:
- main
tags:
- 'v*'
pull_request:
branches:
- main
workflow_dispatch:
jobs:
test:
name: PHP 8.5 / Laravel 13
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.5'
extensions: mbstring, dom, xml, sqlite3, pdo_sqlite
coverage: none
tools: composer:v2
- name: Install dependencies
run: composer install --prefer-dist --no-interaction --no-progress
- name: Validate Composer
run: composer validate --strict
- name: Check PHP requirements
run: composer check-platform-reqs
- name: Security audit
run: composer audit
- name: Run PHPUnit
run: composer test
+58
View File
@@ -0,0 +1,58 @@
<?php
namespace absdev\Modules\Tests;
use absdev\Modules\Exceptions\InvalidJsonException;
use absdev\Modules\Json;
use Orchestra\Testbench\TestCase;
class JsonTest extends TestCase
{
private string $filename;
protected function setUp(): void
{
parent::setUp();
$this->app['config']->set('modules.cache.enabled', false);
$filename = tempnam(sys_get_temp_dir(), 'absdev-');
if ($filename === false) {
throw new \RuntimeException('Unable to create test file');
}
$this->filename = $filename;
}
protected function tearDown(): void
{
if (isset($this->filename) && is_file($this->filename)) {
unlink($this->filename);
}
parent::tearDown();
}
public function test_reads_module_json(): void
{
file_put_contents(
$this->filename,
'{"name":"Example","enabled":true}'
);
$json = new Json($this->filename);
$this->assertSame('Example', $json->get('name'));
$this->assertTrue($json->get('enabled'));
}
public function test_rejects_invalid_json(): void
{
file_put_contents($this->filename, '{invalid');
$this->expectException(InvalidJsonException::class);
new Json($this->filename);
}
}