From 0d9b989a59a05b0e96cc345a2758b9f4d49de62d Mon Sep 17 00:00:00 2001 From: Riddick Date: Tue, 23 Jun 2026 15:23:19 +0200 Subject: [PATCH 1/5] Update README with PHPUnit integration details Revised the `README.md` to reflect the introduction of PHPUnit testing infrastructure into the `feature/phpunit-integration-and-initial-tests` branch. Changes include updated badge links, branch-specific information, and details on core testing objectives, architectural goals, and initial test coverage. Establishes a clear purpose and documentation for the new testing layer within the FireHub ecosystem. --- README.md | 99 +++++++++++++++++++++++++++++++++++++------------------ 1 file changed, 67 insertions(+), 32 deletions(-) diff --git a/README.md b/README.md index 6a6e86b..7ebe6dd 100644 --- a/README.md +++ b/README.md @@ -23,19 +23,19 @@

- + GitHub last commit (branch) - + GitHub activity (branch) - + GitHub commit difference between two branches

@@ -45,47 +45,82 @@ Standard provides the base classes, kernel, domain layer, and minimal runtime ut --- -## FireHub Icon Development Branch +## FireHub Icon PHPUnit testing infrastructure – Development Branch -⚠️ **This is the `develop` branch** +⚠️ **This is the `development` branch** - Unstable - APIs may change without notice - Not intended for production use +### Related + +- Milestone: **Development v1** +- Target Release: **v0.0.0** +- Repository: FireHub Core Standard + +### Pull request + +

+ + GitHub pull request title + + GitHub pull request author + + GitHub pull request created + + GitHub pull request comments +

+ +### Milestone + +

+ + GitHub milestone details +

+ ## FireHub Icon Branch Purpose -The `develop` branch is the **primary integration branch** for all ongoing development. +This branch introduces the PHPUnit testing infrastructure and initial Core test coverage for the FireHub ecosystem. + +It establishes the foundational testing layer required to validate Core behavior across: -It serves as the staging area where: -- Feature branches are merged -- Bug fixes are integrated -- Experimental work is stabilized -- Code is prepared for upcoming releases +- Core Standard +- Core Professional +- Core Enterprise +- Runtime Foundation (consumers only) -All **release branches** are created **from `develop`**. +This includes PHPUnit configuration, bootstrap alignment, and first executable test cases for Core contracts. -## Stability Guarantee +## FireHub Icon Architectural Goal -❌ No backward compatibility guarantee -❌ APIs may change without notice -❌ Behavior may be incomplete or inconsistent -❌ Breaking changes are expected +Introduce a standardized testing layer for Core validation that: -This branch is intended **only for contributors and advanced testers**. +- Ensures Core contracts behave deterministically +- Provides automated verification of architectural rules +- Enables CI-level validation of Core stability +- Establishes testing as a first-class governance layer in FireHub -## FireHub Icon Composer Usage (Not Recommended) +## FireHub Icon Core Concept -For internal testing only: +A FireHub testing layer is: -```json -{ - "require": { - "the-firehub-project/core-standard": "dev-develop" - } -} -``` -⚠️ Never use dev-develop in production. +> A deterministic validation system that ensures Core contracts and architectural rules behave as specified, independent of runtime implementation details. ## FireHub Icon Authors and Contributors @@ -102,4 +137,4 @@ Architecture guidelines, design principles, and ecosystem documentation are avai This software is licensed under the Apache-2.0 License. -For more details, read the full license [here](./LICENSE). +For more details, read the full license [here](./LICENSE). \ No newline at end of file From f2bbd114a0ae3c90fd6fe92990550ffc4978b8ca Mon Sep 17 00:00:00 2001 From: Riddick Date: Wed, 24 Jun 2026 13:21:21 +0200 Subject: [PATCH 2/5] Refactor docblocks in `ValueObject` methods for clarity and consistency Reordered and standardized docblock annotations in the `equals` and `sameAs` methods. Adjusted the position of `@uses` and `@since` annotations to improve readability and align with documentation conventions. No functional changes were introduced. --- .../ValueObject.php} | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) rename src/{type/firehub.ValueObject.php => Type/ValueObject.php} (96%) diff --git a/src/type/firehub.ValueObject.php b/src/Type/ValueObject.php similarity index 96% rename from src/type/firehub.ValueObject.php rename to src/Type/ValueObject.php index 617c680..34f0ba8 100644 --- a/src/type/firehub.ValueObject.php +++ b/src/Type/ValueObject.php @@ -44,16 +44,16 @@ abstract public function value ():mixed; * * Compares this Value Object with another instance of the same type using strict * class comparison and value equality semantics. - * @since 1.0.0 - * - * @uses \FireHub\Core\Type\ValueObject::sameAs() To compare the VO types. - * @uses \FireHub\Core\Type\ValueObject::value() To compare the VO values. - * * @param self $other

* The Value Object to compare against. *

* * @return bool True if the VOs are equal, false otherwise. + *@uses \FireHub\Core\Type\ValueObject::value() To compare the VO values. + * + * @since 1.0.0 + * + * @uses \FireHub\Core\Type\ValueObject::sameAs() To compare the VO types. */ final public function equals (self $other):bool { @@ -66,13 +66,13 @@ final public function equals (self $other):bool { * ### Checks strict identity equality of a Value Object type * * Ensures both objects are of the same concrete class without comparing values. - * @since 1.0.0 - * * @param \FireHub\Core\Type\ValueObject $other

* The Value Object to compare against. *

* * @return bool True if the objects are of the same type, false otherwise. + *@since 1.0.0 + * */ final public function sameAs (self $other):bool { From c1217098fb097805a744f1760be32ab600bd48ca Mon Sep 17 00:00:00 2001 From: Riddick Date: Wed, 24 Jun 2026 13:23:25 +0200 Subject: [PATCH 3/5] Correct casing of path in PHPStan configuration file Updated the include path in `phpstan.neon` to align with correct casing (`Config` instead of `config`). This ensures compatibility with case-sensitive file systems and prevents potential runtime issues during static analysis. --- phpstan.neon | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpstan.neon b/phpstan.neon index 6161413..d0e5c9b 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -1,5 +1,5 @@ includes: - - vendor/the-firehub-project/phpstan-rules/src/config/base.neon + - vendor/the-firehub-project/phpstan-rules/src/Config/base.neon parameters: paths: From 85c86745f7821c03e69547d3d24a7c76cb479067 Mon Sep 17 00:00:00 2001 From: Riddick Date: Wed, 24 Jun 2026 13:25:16 +0200 Subject: [PATCH 4/5] Add PHPUnit configuration and update composer setup Introduced a `phpunit.xml` configuration file to establish a testing framework for the repository. Updated `.gitattributes` to exclude the PHPUnit configuration file from export. Enhanced `composer.json` by adding `the-firehub-project/testing` as a development dependency and configuring `autoload` and `autoload-dev` sections to map source and test namespaces. These changes lay the groundwork for unit testing and streamlined development workflows. --- .gitattributes | 1 + composer.json | 14 +++++++++++++- phpunit.xml | 16 ++++++++++++++++ 3 files changed, 30 insertions(+), 1 deletion(-) create mode 100644 phpunit.xml diff --git a/.gitattributes b/.gitattributes index 27356a7..655489b 100644 --- a/.gitattributes +++ b/.gitattributes @@ -10,6 +10,7 @@ /.gitattributes export-ignore /.gitignore export-ignore /phpstan.neon export-ignore +/phpunit.xml export-ignore # Explicit text file types *.php text diff --git a/composer.json b/composer.json index 64e7613..d8b699e 100644 --- a/composer.json +++ b/composer.json @@ -10,9 +10,21 @@ }, "require-dev": { "phpstan/phpstan": "^2.0", - "the-firehub-project/phpstan-rules": "dev-develop" + "the-firehub-project/phpstan-rules": "dev-develop", + + "the-firehub-project/testing": "dev-develop" }, "minimum-stability": "stable", + "autoload": { + "psr-4": { + "FireHub\\Core\\": "src" + } + }, + "autoload-dev": { + "psr-4": { + "FireHub\\Tests\\Core\\": "tests/" + } + }, "authors": [ { "name": "Danijel Galić", diff --git a/phpunit.xml b/phpunit.xml new file mode 100644 index 0000000..27667c4 --- /dev/null +++ b/phpunit.xml @@ -0,0 +1,16 @@ + + + + + tests/Unit + + + + + src + + + \ No newline at end of file From bdbf8866e2f6a29c0a6c044816243540eed58dc4 Mon Sep 17 00:00:00 2001 From: Riddick Date: Wed, 24 Jun 2026 13:29:17 +0200 Subject: [PATCH 5/5] Add `ValueObject` unit tests, stubs, and PHPUnit workflow Implemented `ValueObjectTest` to verify the behavior of the `ValueObject` base class, covering the `equals` and `sameAs` methods. Introduced `DummyStringVO` and `DummyIntVO` stubs to facilitate testing. Added a reusable PHPUnit GitHub Actions workflow for automated test execution on pull requests. These changes enhance code reliability and ensure foundational test coverage for value objects. --- .github/workflows/PHPUnit.yml | 18 +++++++ tests/Stubs/Type/DummyIntVO.php | 55 +++++++++++++++++++++ tests/Stubs/Type/DummyStringVO.php | 55 +++++++++++++++++++++ tests/Unit/Type/ValueObjectTest.php | 74 +++++++++++++++++++++++++++++ 4 files changed, 202 insertions(+) create mode 100644 .github/workflows/PHPUnit.yml create mode 100644 tests/Stubs/Type/DummyIntVO.php create mode 100644 tests/Stubs/Type/DummyStringVO.php create mode 100644 tests/Unit/Type/ValueObjectTest.php diff --git a/.github/workflows/PHPUnit.yml b/.github/workflows/PHPUnit.yml new file mode 100644 index 0000000..3d8ae28 --- /dev/null +++ b/.github/workflows/PHPUnit.yml @@ -0,0 +1,18 @@ +name: PHPUnit + +on: + pull_request: + +permissions: read-all + +jobs: + build: + uses: The-FireHub-Project/.github/.github/workflows/RunCommandOnMatrix.yml@master + with: + title: "Run PHPUnit" + phpVersions: ${{ vars.PHP_VERSIONS }} + phpExtensions: ${{ vars.PHP_EXTENSIONS }} + tools: "phpunit:13.x" + command: "phpunit" + secrets: + GH_TOKEN: ${{ secrets.GH_TOKEN }} \ No newline at end of file diff --git a/tests/Stubs/Type/DummyIntVO.php b/tests/Stubs/Type/DummyIntVO.php new file mode 100644 index 0000000..28537cb --- /dev/null +++ b/tests/Stubs/Type/DummyIntVO.php @@ -0,0 +1,55 @@ + + * @copyright 2026-present The FireHub Project - All rights reserved + * @license https://opensource.org/license/Apache-2-0 Apache License, Version 2.0 + * + * @php-version >=8.2 + * @package Core\Tests + */ + +namespace FireHub\Tests\Core\Stubs\Type; + +use FireHub\Core\Type\ValueObject; +use InvalidArgumentException; + +/** + * ### Dummy int Value Object + * @since 1.0.0 + */ +readonly class DummyIntVO extends ValueObject { + + /** + * ### Constructor + * @since 1.0.0 + * + * @param int $value + * + * @return void + */ + public function __construct ( + private int $value = 1 + ) { + + $this->guard( + fn() => $this->value > 0, + fn() => new InvalidArgumentException('Value must be positive.') + ); + + } + + /** + * @inheritDoc + * + * @since 1.0.0 + */ + public function value ():int { + + return $this->value; + + } + +} \ No newline at end of file diff --git a/tests/Stubs/Type/DummyStringVO.php b/tests/Stubs/Type/DummyStringVO.php new file mode 100644 index 0000000..a4e9be0 --- /dev/null +++ b/tests/Stubs/Type/DummyStringVO.php @@ -0,0 +1,55 @@ + + * @copyright 2026-present The FireHub Project - All rights reserved + * @license https://opensource.org/license/Apache-2-0 Apache License, Version 2.0 + * + * @php-version >=8.2 + * @package Core\Tests + */ + +namespace FireHub\Tests\Core\Stubs\Type; + +use FireHub\Core\Type\ValueObject; +use InvalidArgumentException; + +/** + * ### Dummy string Value Object + * @since 1.0.0 + */ +readonly class DummyStringVO extends ValueObject { + + /** + * ### Constructor + * @since 1.0.0 + * + * @param string $value + * + * @return void + */ + public function __construct ( + private string $value = 'default' + ) { + + $this->guard( + fn() => $this->value !== '', + fn() => new InvalidArgumentException('Value cannot be empty.') + ); + + } + + /** + * @inheritDoc + * + * @since 1.0.0 + */ + public function value ():string { + + return $this->value; + + } + +} \ No newline at end of file diff --git a/tests/Unit/Type/ValueObjectTest.php b/tests/Unit/Type/ValueObjectTest.php new file mode 100644 index 0000000..a4682a1 --- /dev/null +++ b/tests/Unit/Type/ValueObjectTest.php @@ -0,0 +1,74 @@ + + * @copyright 2026-present The FireHub Project - All rights reserved + * @license https://opensource.org/license/Apache-2-0 Apache License, Version 2.0 + * + * @php-version >=7.0 + * @package Core\Tests + */ + +namespace FireHub\Tests\Core\Unit\Type; + +use FireHub\Testing\FireHubTestCase; +use FireHub\Core\Type\ValueObject; +use FireHub\Tests\Core\Stubs\Type\ { + DummyIntVO, DummyStringVO +}; +use PHPUnit\Framework\Attributes\ { + CoversClass, Group, Small, TestWith +}; + +/** + * ### Test Base Value Object + * @since 1.0.0 + */ +#[Small] +#[Group('type')] +#[CoversClass(ValueObject::class)] +final class ValueObjectTest extends FireHubTestCase { + + /** + * @since 1.0.0 + * + * @param string $a + * @param string $b + * @param bool $expected + * + * @return void + */ + #[TestWith(['x', 'x', true])] + #[TestWith(['x', 'y', false])] + public function testEquals (string $a, string $b, bool $expected):void { + + $a = new DummyStringVO($a); + $b = new DummyStringVO($b); + + $this::assertEquals($expected, $a->equals($b)); + + } + + /** + * @since 1.0.0 + * + * @param string $a + * @param string $b + * @param bool $expected + * + * @return void + */ + #[TestWith([DummyStringVO::class, DummyStringVO::class, true])] + #[TestWith([DummyStringVO::class, DummyIntVO::class, false])] + public function testSameAs (string $a, string $b, bool $expected):void { + + $a = new $a; + $b = new $b; + + $this::assertEquals($expected, $a->sameAs($b)); + + } + +} \ No newline at end of file