chore: implement php test suites
PHP Integration Tests / Integration Tests (pull_request) Failing after 1m5s
PHP Unit Tests / test (pull_request) Successful in 2m10s

Signed-off-by: Sebastian Krupinski <krupinski01@gmail.com>
This commit is contained in:
2026-07-23 22:20:36 -04:00
parent a3e06a2da9
commit 18e18be2b2
9 changed files with 1778 additions and 17 deletions
@@ -1,4 +1,4 @@
name: Integration Tests
name: PHP Integration Tests
on:
pull_request:
+42
View File
@@ -0,0 +1,42 @@
name: PHP Unit Tests
on:
pull_request:
jobs:
test:
runs-on: ubuntu-latest
steps:
- name: Retrieve Server Install Action
uses: actions/checkout@v6.0.2
with:
repository: Nodarx/action-server-install
ref: main
path: action-server-install
github-server-url: https://git.ktrix.dev
- name: Install Server
uses: ./action-server-install
with:
install-php: 'true'
install-node: 'false'
php-version: '8.5'
node-version: '24'
server-path: './server'
- name: Checkout Pull Request
uses: actions/checkout@v6.0.2
with:
repository: ${{ github.repository }}
ref: ${{ github.event.pull_request.head.sha }}
path: server/modules/authentication_provider_password
github-server-url: https://git.ktrix.dev
- name: Install dependencies
run: composer install --prefer-dist --no-progress
working-directory: server/modules/authentication_provider_password
- name: Run tests
run: composer test:unit
working-directory: server/modules/authentication_provider_password
+1 -5
View File
@@ -15,11 +15,7 @@ node_modules/
/vendor/
/lib/vendor/
coverage/
phpunit.xml.cache
.phpunit.cache/
.phpunit.result.cache
.php-cs-fixer.cache
.phpstan.cache
*.cache
.phpactor/
# Editors
+11 -2
View File
@@ -8,9 +8,18 @@
}
},
"require": {
"php": ">=8.2"
"php": ">=8.3"
},
"require-dev": {
"phpunit/phpunit": "^12.0"
},
"autoload-dev": {
"psr-4": {
"KTXT\\AuthenticationProviderPassword\\Tests\\": "tests/php/"
}
},
"scripts": {
"test:integration": "../../vendor/bin/phpunit --configuration tests/php/phpunit.integration.xml --colors=always --testdox"
"test:unit": "phpunit --configuration tests/php/phpunit.xml --testsuite \"Unit Tests\" --colors=always --testdox",
"test:integration": "phpunit --configuration tests/php/phpunit.xml --testsuite \"Integration Tests\" --colors=always --testdox"
}
}
Generated
+1685 -3
View File
File diff suppressed because it is too large Load Diff
@@ -60,7 +60,7 @@ abstract class IntegrationTestCase extends TestCase
protected static function buildServer(): Server
{
return new Server(KTRIX_SERVER_ROOT);
return new Server(SERVER_ROOT);
}
// =========================================================================
@@ -127,7 +127,7 @@ abstract class IntegrationTestCase extends TestCase
*/
protected static function runConsole(array $args): string
{
$command = escapeshellcmd(PHP_BINARY) . ' ' . escapeshellarg(KTRIX_SERVER_ROOT . '/bin/console');
$command = escapeshellcmd(PHP_BINARY) . ' ' . escapeshellarg(SERVER_ROOT . '/bin/console');
foreach ($args as $arg) {
$command .= ' ' . escapeshellarg((string) $arg);
}
+29
View File
@@ -0,0 +1,29 @@
<?php
namespace KTXT\AuthenticationProviderPassword\Tests\Unit;
use PHPUnit\Framework\TestCase;
class BaseTest extends TestCase
{
public function testBasicAssertion(): void
{
$this->assertTrue(true);
}
public function testArrayOperations(): void
{
$array = ['foo' => 'bar'];
$this->assertArrayHasKey('foo', $array);
$this->assertEquals('bar', $array['foo']);
}
public function testStringOperations(): void
{
$string = 'Hello, World!';
$this->assertStringContainsString('World', $string);
$this->assertEquals(13, strlen($string));
}
}
+2 -2
View File
@@ -6,9 +6,9 @@ declare(strict_types=1);
// server's own vendor/autoload.php (core + shared + framework deps) is a
// fixed number of levels above this file. Every other test file resolves
// the server root through this constant rather than repeating the math.
define('KTRIX_SERVER_ROOT', dirname(__DIR__, 4));
define('SERVER_ROOT', dirname(__DIR__, 4));
require KTRIX_SERVER_ROOT . '/vendor/autoload.php';
require SERVER_ROOT . '/vendor/autoload.php';
require __DIR__ . '/Integration/IntegrationTestCase.php';
if (isset($_SERVER['APP_DEBUG']) && $_SERVER['APP_DEBUG']) {
@@ -2,7 +2,7 @@
<!-- https://phpunit.readthedocs.io/en/latest/configuration.html -->
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="../../../../vendor/phpunit/phpunit/phpunit.xsd"
xsi:noNamespaceSchemaLocation="../../vendor/phpunit/phpunit/phpunit.xsd"
colors="true"
failOnDeprecation="true"
failOnNotice="true"
@@ -17,8 +17,11 @@
</php>
<testsuites>
<testsuite name="Unit Tests">
<directory>Unit</directory>
</testsuite>
<testsuite name="Integration Tests">
<directory suffix="Test.php">Integration</directory>
<directory>Integration</directory>
</testsuite>
</testsuites>