chore: implement php test suites
Signed-off-by: Sebastian Krupinski <krupinski01@gmail.com>
This commit is contained in:
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
name: Integration Tests
|
name: PHP Integration Tests
|
||||||
|
|
||||||
on:
|
on:
|
||||||
pull_request:
|
pull_request:
|
||||||
@@ -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
@@ -15,11 +15,7 @@ node_modules/
|
|||||||
/vendor/
|
/vendor/
|
||||||
/lib/vendor/
|
/lib/vendor/
|
||||||
coverage/
|
coverage/
|
||||||
phpunit.xml.cache
|
*.cache
|
||||||
.phpunit.cache/
|
|
||||||
.phpunit.result.cache
|
|
||||||
.php-cs-fixer.cache
|
|
||||||
.phpstan.cache
|
|
||||||
.phpactor/
|
.phpactor/
|
||||||
|
|
||||||
# Editors
|
# Editors
|
||||||
|
|||||||
+11
-2
@@ -8,9 +8,18 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"require": {
|
"require": {
|
||||||
"php": ">=8.2"
|
"php": ">=8.3"
|
||||||
|
},
|
||||||
|
"require-dev": {
|
||||||
|
"phpunit/phpunit": "^12.0"
|
||||||
|
},
|
||||||
|
"autoload-dev": {
|
||||||
|
"psr-4": {
|
||||||
|
"KTXT\\AuthenticationProviderPassword\\Tests\\": "tests/php/"
|
||||||
|
}
|
||||||
},
|
},
|
||||||
"scripts": {
|
"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
File diff suppressed because it is too large
Load Diff
@@ -60,7 +60,7 @@ abstract class IntegrationTestCase extends TestCase
|
|||||||
|
|
||||||
protected static function buildServer(): Server
|
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
|
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) {
|
foreach ($args as $arg) {
|
||||||
$command .= ' ' . escapeshellarg((string) $arg);
|
$command .= ' ' . escapeshellarg((string) $arg);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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));
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -6,9 +6,9 @@ declare(strict_types=1);
|
|||||||
// server's own vendor/autoload.php (core + shared + framework deps) is a
|
// server's own vendor/autoload.php (core + shared + framework deps) is a
|
||||||
// fixed number of levels above this file. Every other test file resolves
|
// fixed number of levels above this file. Every other test file resolves
|
||||||
// the server root through this constant rather than repeating the math.
|
// 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';
|
require __DIR__ . '/Integration/IntegrationTestCase.php';
|
||||||
|
|
||||||
if (isset($_SERVER['APP_DEBUG']) && $_SERVER['APP_DEBUG']) {
|
if (isset($_SERVER['APP_DEBUG']) && $_SERVER['APP_DEBUG']) {
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
<!-- https://phpunit.readthedocs.io/en/latest/configuration.html -->
|
<!-- https://phpunit.readthedocs.io/en/latest/configuration.html -->
|
||||||
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
<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"
|
colors="true"
|
||||||
failOnDeprecation="true"
|
failOnDeprecation="true"
|
||||||
failOnNotice="true"
|
failOnNotice="true"
|
||||||
@@ -17,8 +17,11 @@
|
|||||||
</php>
|
</php>
|
||||||
|
|
||||||
<testsuites>
|
<testsuites>
|
||||||
|
<testsuite name="Unit Tests">
|
||||||
|
<directory>Unit</directory>
|
||||||
|
</testsuite>
|
||||||
<testsuite name="Integration Tests">
|
<testsuite name="Integration Tests">
|
||||||
<directory suffix="Test.php">Integration</directory>
|
<directory>Integration</directory>
|
||||||
</testsuite>
|
</testsuite>
|
||||||
</testsuites>
|
</testsuites>
|
||||||
|
|
||||||
Reference in New Issue
Block a user