Add Gitea Actions CI and JSON regression tests
Laravel Modules CI / PHP 8.5 / Laravel 13 (push) Successful in 1m27s
Laravel Modules CI / PHP 8.5 / Laravel 13 (push) Successful in 1m27s
This commit is contained in:
@@ -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
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user