test: split unit and integration suites and add coverage config
Tests / PHP 8.3 (push) Failing after 3m42s
Tests / PHP 8.4 (push) Failing after 2m31s

- Create tests/Integration/ConnectionTest.php, skipped unless CAMELIA_TEST_HOST,
  CAMELIA_TEST_DATABASE and CAMELIA_TEST_USER are set, so composer test:integration
  no longer fails on a missing directory.
- Move coverage reports to phpunit.coverage.xml.dist: a coverage driver is optional and
  failOnWarning would turn its absence into a failed gate.
- Add a composer coverage script and document the requirement.
- Exclude development-only files from the distribution archive via export-ignore.
- Add a Gitea Actions workflow running composer check on PHP 8.3 and 8.4.
- Align the README title with the package name and add Packagist and CI badges.
This commit is contained in:
dgarcia committed 2026-11-15 10:21:11 -03:00
1 parent 725bcfdaf4
commit f9010e2c63
7 files changed
+144 -3

No files matched your search

+52
View File
@@ -0,0 +1,52 @@
<?php
declare(strict_types=1);
namespace Camelia\Orm\Tests\Integration;
use Camelia\Orm\Orm;
use PHPUnit\Framework\Attributes\Test;
use PHPUnit\Framework\TestCase;
/**
* Integration tests require a live MariaDB/MySQL server. The suite is skipped unless
* CAMELIA_TEST_HOST, CAMELIA_TEST_DATABASE and CAMELIA_TEST_USER are set, so
* `composer test` stays hermetic and needs no database.
*/
final class ConnectionTest extends TestCase
{
/**
* @return array{host: string, user: string, database: string, password: string, port: int}
*/
private function optionsOrSkip(): array
{
$host = getenv('CAMELIA_TEST_HOST');
$database = getenv('CAMELIA_TEST_DATABASE');
$user = getenv('CAMELIA_TEST_USER');
if ($host === false || $database === false || $user === false) {
self::markTestSkipped(
'CAMELIA_TEST_HOST, CAMELIA_TEST_DATABASE and CAMELIA_TEST_USER are required.',
);
}
$port = getenv('CAMELIA_TEST_PORT');
$password = getenv('CAMELIA_TEST_PASSWORD');
return [
'host' => $host,
'user' => $user,
'database' => $database,
'password' => $password === false ? '' : $password,
'port' => $port === false ? 3306 : (int) $port,
];
}
#[Test]
public function it_connects_to_the_configured_database(): void
{
$orm = Orm::fromArray($this->optionsOrSkip());
self::assertSame(1, (int) $orm->connection()->scalar('SELECT 1'));
}
}