diff --git a/.gitea/workflows/ci.yml b/.gitea/workflows/ci.yml new file mode 100644 index 0000000..3ba167b --- /dev/null +++ b/.gitea/workflows/ci.yml @@ -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 diff --git a/tests/JsonTest.php b/tests/JsonTest.php new file mode 100644 index 0000000..0de853c --- /dev/null +++ b/tests/JsonTest.php @@ -0,0 +1,58 @@ +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); + } +}