Compare commits
1 Commits
292ad4c08f
...
chore/impl
| Author | SHA1 | Date | |
|---|---|---|---|
| 1d9def792a |
24
.gitea/workflows/php-tests.yml
Normal file
24
.gitea/workflows/php-tests.yml
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
name: PHP Tests
|
||||||
|
|
||||||
|
on:
|
||||||
|
pull_request:
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
test:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v6.0.2
|
||||||
|
|
||||||
|
- name: Set up PHP
|
||||||
|
uses: shivammathur/setup-php@v2
|
||||||
|
with:
|
||||||
|
php-version: '8.5'
|
||||||
|
tools: composer:v2
|
||||||
|
extensions: ctype, iconv, mongodb
|
||||||
|
|
||||||
|
- name: Install dependencies
|
||||||
|
run: composer install --prefer-dist --no-progress
|
||||||
|
|
||||||
|
- name: Run tests
|
||||||
|
run: composer test
|
||||||
1
.gitignore
vendored
1
.gitignore
vendored
@@ -16,6 +16,7 @@ node_modules/
|
|||||||
/vendor/
|
/vendor/
|
||||||
coverage/
|
coverage/
|
||||||
phpunit.xml.cache
|
phpunit.xml.cache
|
||||||
|
.phpunit.cache
|
||||||
.phpunit.result.cache
|
.phpunit.result.cache
|
||||||
.php-cs-fixer.cache
|
.php-cs-fixer.cache
|
||||||
.phpstan.cache
|
.phpstan.cache
|
||||||
|
|||||||
2759
package-lock.json
generated
2759
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
52
package.json
52
package.json
@@ -17,40 +17,40 @@
|
|||||||
"dev:all": "npm run dev && npm run dev:modules"
|
"dev:all": "npm run dev && npm run dev:modules"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@fontsource/inter": "5.2.8",
|
"@fontsource/inter": "5.1.0",
|
||||||
"@fontsource/poppins": "5.2.7",
|
"@fontsource/poppins": "5.1.0",
|
||||||
"@fontsource/public-sans": "5.2.7",
|
"@fontsource/public-sans": "5.1.1",
|
||||||
"@fontsource/roboto": "5.2.9",
|
"@fontsource/roboto": "5.1.0",
|
||||||
"@mdi/font": "7.4.47",
|
"@mdi/font": "7.4.47",
|
||||||
"@tsconfig/node24": "24.0.4",
|
"@tsconfig/node24": "24.0.0",
|
||||||
"@typescript-eslint/parser": "^8.55.0",
|
"@typescript-eslint/parser": "^8.18.2",
|
||||||
"@vue/compiler-sfc": "^3.5.28",
|
"@vue/compiler-sfc": "^3.5.16",
|
||||||
"dompurify": "^3.3.1",
|
"dompurify": "^3.3.1",
|
||||||
"pinia": "3.0.4",
|
"pinia": "3.0.4",
|
||||||
"vee-validate": "^4.15.1",
|
"vee-validate": "^4.15.1",
|
||||||
"vite-plugin-vuetify": "2.1.3",
|
"vite-plugin-vuetify": "2.0.4",
|
||||||
"vue": "3.5.28",
|
"vue": "3.5.13",
|
||||||
"vue-router": "5.0.2",
|
"vue-router": "4.5.0",
|
||||||
"vue3-perfect-scrollbar": "2.0.0",
|
"vue3-perfect-scrollbar": "2.0.0",
|
||||||
"vuetify": "3.11.8"
|
"vuetify": "3.7.6"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@eslint/js": "^9.18.0",
|
"@eslint/js": "^9.17.0",
|
||||||
"@types/dompurify": "^3.2.0",
|
"@types/dompurify": "^3.0.5",
|
||||||
"@types/node": "25.2.3",
|
"@types/node": "24.10.13",
|
||||||
"@vitejs/plugin-vue": "6.0.4",
|
"@vitejs/plugin-vue": "5.2.1",
|
||||||
"@vue/eslint-config-prettier": "10.2.0",
|
"@vue/eslint-config-prettier": "10.1.0",
|
||||||
"@vue/tsconfig": "0.8.1",
|
"@vue/tsconfig": "0.7.0",
|
||||||
"eslint": "^9.18.0",
|
"eslint": "9.17.0",
|
||||||
"eslint-plugin-vue": "10.7.0",
|
"eslint-plugin-vue": "9.32.0",
|
||||||
"prettier": "3.8.1",
|
"prettier": "3.4.2",
|
||||||
"sass": "1.97.3",
|
"sass": "1.77.1",
|
||||||
"sass-loader": "16.0.7",
|
"sass-loader": "16.0.4",
|
||||||
"typescript": "5.9.3",
|
"typescript": "5.9.3",
|
||||||
"typescript-eslint": "^8.55.0",
|
"typescript-eslint": "^8.18.2",
|
||||||
"vite": "7.3.1",
|
"vite": "6.0.6",
|
||||||
"vite-plugin-static-copy": "^3.2.0",
|
"vite-plugin-static-copy": "^3.1.2",
|
||||||
"vue-cli-plugin-vuetify": "2.5.8",
|
"vue-cli-plugin-vuetify": "2.5.8",
|
||||||
"vue-tsc": "^3.2.4"
|
"vue-tsc": "^2.2.10"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
29
tests/php/BaseTest.php
Normal file
29
tests/php/BaseTest.php
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace KTXT;
|
||||||
|
|
||||||
|
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));
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,64 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
declare(strict_types=1);
|
|
||||||
|
|
||||||
namespace KTXF\Json;
|
|
||||||
|
|
||||||
use PHPUnit\Framework\TestCase;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Test for JsonSerializableObject base functionality
|
|
||||||
*/
|
|
||||||
class JsonSerializableObjectTest extends TestCase
|
|
||||||
{
|
|
||||||
public function testJsonSerializeReturnsObjectVars(): void
|
|
||||||
{
|
|
||||||
$testObject = new class extends JsonSerializableObject {
|
|
||||||
public string $publicProperty = 'test';
|
|
||||||
private string $privateProperty = 'private';
|
|
||||||
protected string $protectedProperty = 'protected';
|
|
||||||
};
|
|
||||||
|
|
||||||
$serialized = $testObject->jsonSerialize();
|
|
||||||
|
|
||||||
$this->assertIsArray($serialized);
|
|
||||||
$this->assertArrayHasKey('publicProperty', $serialized);
|
|
||||||
$this->assertEquals('test', $serialized['publicProperty']);
|
|
||||||
$this->assertArrayHasKey('protectedProperty', $serialized); // get_object_vars includes protected
|
|
||||||
$this->assertEquals('protected', $serialized['protectedProperty']);
|
|
||||||
$this->assertArrayNotHasKey('privateProperty', $serialized); // but not private
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testJsonDeserializeSetsProperties(): void
|
|
||||||
{
|
|
||||||
$testObject = new class extends JsonSerializableObject {
|
|
||||||
public string $name = '';
|
|
||||||
public int $age = 0;
|
|
||||||
};
|
|
||||||
|
|
||||||
$data = [
|
|
||||||
'name' => 'John Doe',
|
|
||||||
'age' => 30,
|
|
||||||
'nonexistent' => 'ignored'
|
|
||||||
];
|
|
||||||
|
|
||||||
$result = $testObject->jsonDeserialize($data);
|
|
||||||
|
|
||||||
$this->assertSame($testObject, $result);
|
|
||||||
$this->assertEquals('John Doe', $testObject->name);
|
|
||||||
$this->assertEquals(30, $testObject->age);
|
|
||||||
$this->assertObjectNotHasProperty('nonexistent', $testObject);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testJsonDeserializeHandlesJsonString(): void
|
|
||||||
{
|
|
||||||
$testObject = new class extends JsonSerializableObject {
|
|
||||||
public string $message = '';
|
|
||||||
};
|
|
||||||
|
|
||||||
$jsonString = '{"message": "Hello World"}';
|
|
||||||
$testObject->jsonDeserialize($jsonString);
|
|
||||||
|
|
||||||
$this->assertEquals('Hello World', $testObject->message);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,109 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
declare(strict_types=1);
|
|
||||||
|
|
||||||
namespace KTXF\People\Entity\Individual;
|
|
||||||
|
|
||||||
use PHPUnit\Framework\TestCase;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Test for IndividualObject JsonSerializable functionality
|
|
||||||
*/
|
|
||||||
class IndividualObjectTest extends TestCase
|
|
||||||
{
|
|
||||||
public function testJsonSerialization(): void
|
|
||||||
{
|
|
||||||
// Create an IndividualObject instance
|
|
||||||
$individual = new IndividualObject();
|
|
||||||
|
|
||||||
// Set some basic properties
|
|
||||||
$individual->urid = 'test-urid-123';
|
|
||||||
$individual->label = 'Test Individual';
|
|
||||||
$individual->language = 'en';
|
|
||||||
|
|
||||||
// Set name
|
|
||||||
$individual->names->First = 'John';
|
|
||||||
$individual->names->Last = 'Doe';
|
|
||||||
$individual->names->Prefix = 'Mr.';
|
|
||||||
|
|
||||||
// Add an alias
|
|
||||||
$alias = new IndividualAliasObject();
|
|
||||||
$alias->label = 'Johnny';
|
|
||||||
$individual->names->Aliases[] = $alias;
|
|
||||||
|
|
||||||
// Serialize to JSON
|
|
||||||
$json = json_encode($individual);
|
|
||||||
|
|
||||||
// Verify JSON structure
|
|
||||||
$this->assertJson($json);
|
|
||||||
|
|
||||||
$data = json_decode($json, true);
|
|
||||||
$this->assertEquals('individual', $data['type']);
|
|
||||||
$this->assertEquals(1, $data['version']);
|
|
||||||
$this->assertEquals('test-urid-123', $data['urid']);
|
|
||||||
$this->assertEquals('Test Individual', $data['label']);
|
|
||||||
$this->assertEquals('en', $data['language']);
|
|
||||||
$this->assertEquals('John', $data['names']['First']);
|
|
||||||
$this->assertEquals('Doe', $data['names']['Last']);
|
|
||||||
$this->assertEquals('Mr.', $data['names']['Prefix']);
|
|
||||||
$this->assertCount(1, $data['names']['Aliases']);
|
|
||||||
$this->assertEquals('Johnny', $data['names']['Aliases'][0]['label']);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testJsonDeserialization(): void
|
|
||||||
{
|
|
||||||
$jsonData = [
|
|
||||||
'type' => 'individual',
|
|
||||||
'version' => 1,
|
|
||||||
'urid' => 'test-urid-456',
|
|
||||||
'label' => 'Deserialized Individual',
|
|
||||||
'language' => 'fr',
|
|
||||||
'names' => [
|
|
||||||
'First' => 'Jane',
|
|
||||||
'Last' => 'Smith',
|
|
||||||
'Prefix' => 'Ms.',
|
|
||||||
'Aliases' => [
|
|
||||||
['label' => 'Janie']
|
|
||||||
]
|
|
||||||
]
|
|
||||||
];
|
|
||||||
|
|
||||||
$individual = new IndividualObject();
|
|
||||||
$individual->jsonDeserialize($jsonData);
|
|
||||||
|
|
||||||
$this->assertEquals('test-urid-456', $individual->urid);
|
|
||||||
$this->assertEquals('Deserialized Individual', $individual->label);
|
|
||||||
$this->assertEquals('fr', $individual->language);
|
|
||||||
$this->assertEquals('Jane', $individual->names->First);
|
|
||||||
$this->assertEquals('Smith', $individual->names->Last);
|
|
||||||
$this->assertEquals('Ms.', $individual->names->Prefix);
|
|
||||||
$this->assertCount(1, $individual->names->Aliases);
|
|
||||||
$this->assertEquals('Janie', $individual->names->Aliases[0]->label);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testJsonRoundTrip(): void
|
|
||||||
{
|
|
||||||
// Create original object
|
|
||||||
$original = new IndividualObject();
|
|
||||||
$original->urid = 'round-trip-urid';
|
|
||||||
$original->label = 'Round Trip Test';
|
|
||||||
$original->names->First = 'Alice';
|
|
||||||
$original->names->Last = 'Wonderland';
|
|
||||||
|
|
||||||
// Serialize and deserialize
|
|
||||||
$json = json_encode($original);
|
|
||||||
$deserialized = new IndividualObject();
|
|
||||||
$deserialized->jsonDeserialize($json);
|
|
||||||
|
|
||||||
// Verify round-trip integrity
|
|
||||||
$this->assertEquals($original->urid, $deserialized->urid);
|
|
||||||
$this->assertEquals($original->label, $deserialized->label);
|
|
||||||
$this->assertEquals($original->names->First, $deserialized->names->First);
|
|
||||||
$this->assertEquals($original->names->Last, $deserialized->names->Last);
|
|
||||||
|
|
||||||
// Verify JSON representations are identical
|
|
||||||
$originalJson = json_encode($original);
|
|
||||||
$deserializedJson = json_encode($deserialized);
|
|
||||||
$this->assertJsonStringEqualsJsonString($originalJson, $deserializedJson);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user