diff --git a/README.md b/README.md index 8326abf..8a5e6ac 100644 --- a/README.md +++ b/README.md @@ -22,20 +22,24 @@ /> +[![PHPStan](https://github.com/The-FireHub-Project/Testing/actions/workflows/PHPStan.yml/badge.svg?branch=feature%2Ftesting-infrastructure)](https://github.com/The-FireHub-Project/Testing/actions/workflows/PHPStan.yml) +[![PHPUnit](https://github.com/The-FireHub-Project/Testing/actions/workflows/PHPUnit.yml/badge.svg?branch=feature%2Ftesting-infrastructure)](https://github.com/The-FireHub-Project/Testing/actions/workflows/PHPUnit.yml) +[![Codecov](https://codecov.io/gh/The-FireHub-Project/Testing/branch/feature%2Ftesting-infrastructure/graph/badge.svg?token=XW2YEONF51)](https://app.codecov.io/gh/The-FireHub-Project/Testing/tree/feature%2Ftesting-infrastructure) +

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

@@ -55,47 +59,89 @@ This layer is designed to ensure that FireHub architectural rules are continuous --- -## FireHub Icon Development Branch +## FireHub Icon 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 + +- Target Release: **v0.0.0** +- Repository: FireHub Testing Toolkit + +### Pull request + +

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

+ ## FireHub Icon Branch Purpose -The `develop` branch is the **primary integration branch** for all ongoing development. +Introduce the `the-firehub-project/testing` package as a shared testing infrastructure library for the FireHub ecosystem. + +This branch establishes a centralized location for reusable testing components such as Data Providers, Stubs, Fixtures, and common testing utilities that can be consumed by FireHub Core, Runtime, Adapter, and Capability repositories. + +The goal is to avoid duplicated test infrastructure across repositories and provide a consistent testing foundation across the entire ecosystem. + +## FireHub Icon Architectural Goal + +Create a framework-agnostic testing support layer that sits outside the production runtime while supporting all FireHub packages during development and verification. + +The Testing package should: + +- Provide reusable test building blocks shared across repositories. +- Keep testing concerns separated from Core contracts and Runtime execution logic. +- Support multiple testing frameworks without coupling the package to a specific runner. +- Improve the consistency, maintainability, and scalability of the FireHub test ecosystem. +- Enable isolated testing of contracts, implementations, adapters, and capabilities. + +## FireHub Icon Core Concept + +The Testing package provides reusable verification components instead of application logic. -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 concepts: -All **release branches** are created **from `develop`**. +- **Data Providers** + - Shared datasets for repeatable test scenarios. + - Standardized valid, invalid, boundary, and edge-case inputs. -## Stability Guarantee +- **Stubs** + - Lightweight implementations of contracts used to isolate behavior during testing. + - Used instead of production implementations when testing individual units. -❌ No backward compatibility guarantee -❌ APIs may change without notice -❌ Behavior may be incomplete or inconsistent -❌ Breaking changes are expected +- **Fixtures** + - Reusable object and state creation helpers for complex test scenarios. -This branch is intended **only for contributors and advanced testers**. +- **Testing Utilities** + - Common assertions, helpers, and test support functionality. -## FireHub Icon Composer Usage (Not Recommended) +The package follows the principle: -For internal testing only: +> Production code defines behavior. Testing infrastructure verifies behavior. -```json -{ - "require": { - "the-firehub-project/testing": "dev-develop" - } -} -``` -⚠️ Never use dev-develop in production. +The Testing package must never become a dependency of runtime execution. It exists only as a development and verification dependency. ## FireHub Icon Authors and Contributors @@ -110,6 +156,6 @@ Architecture guidelines, design principles, and ecosystem documentation are avai ## FireHub Icon License -This software is licensed under the MIT License. +This software is licensed under the Apache-2.0 License. For more details, read the full license [here](./LICENSE). \ No newline at end of file diff --git a/src/DataProviders/ArrDataProvider.php b/src/DataProviders/ArrDataProvider.php new file mode 100644 index 0000000..e30fe4f --- /dev/null +++ b/src/DataProviders/ArrDataProvider.php @@ -0,0 +1,67 @@ + + * @copyright 2026-present The FireHub Project - All rights reserved + * @license https://opensource.org/license/MIT MIT License + * + * @php-version >=7.4 + * @package Testing + */ + +namespace FireHub\Testing\DataProviders; + +/** + * ### Array data provider + * @since 1.0.0 + */ +final class ArrDataProvider { + + /** + * @since 1.0.0 + * + * @return array + */ + public static function list ():array { + + return [ + [[1, 2, 3]], + [[10.2, 200, -3]], + [['x', 'y', 'z']], + [[]] + ]; + + } + + /** + * @since 1.0.0 + * + * @return array + */ + public static function associative ():array { + + return [ + [['one' => 1, 'two' => 2, 'three' => 3]], + [['ONE' => 1, 'TWO' => 2, 'THREE' => 3]], + [[2 => '', 'x' => null, 5 => false]] + ]; + + } + + /** + * @since 1.0.0 + * + * @return array + */ + public static function multidimensional ():array { + + return [ + [['one' => [1, 2, 3], 'two' => [4, 5, 6], 'three' => [7, 8, 9]]], + [[1 => [1 => null, 2 => false], 2 => [1 => true, 'x' => false]]] + ]; + + } + +} \ No newline at end of file diff --git a/src/DataProviders/ConstantDataProvider.php b/src/DataProviders/ConstantDataProvider.php new file mode 100644 index 0000000..a5a5faa --- /dev/null +++ b/src/DataProviders/ConstantDataProvider.php @@ -0,0 +1,39 @@ + + * @copyright 2026-present The FireHub Project - All rights reserved + * @license https://opensource.org/license/MIT MIT License + * + * @php-version >=7.4 + * @package Testing + */ + +namespace FireHub\Testing\DataProviders; + +/** + * ### Constant data provider + * @since 1.0.0 + */ +final class ConstantDataProvider { + + /** + * @since 1.0.0 + * + * @return array> + */ + public static function types ():array { + + return [ + ['testString', 'test'], + ['testInt', 10], + ['testBool', false], + ['testNull', null], + ['testArray', ['x']] + ]; + + } + +} \ No newline at end of file diff --git a/src/DataProviders/DataDataProvider.php b/src/DataProviders/DataDataProvider.php new file mode 100644 index 0000000..5eb5a4a --- /dev/null +++ b/src/DataProviders/DataDataProvider.php @@ -0,0 +1,164 @@ + + * @copyright 2026-present The FireHub Project - All rights reserved + * @license https://opensource.org/license/MIT MIT License + * + * @php-version >=7.4 + * @package Testing + */ + +namespace FireHub\Testing\DataProviders; + +use Countable; + +/** + * ### Data data provider + * @since 1.0.0 + */ +final class DataDataProvider { + + /** + * @since 1.0.0 + * + * @return array> + */ + public static function string ():array { + + return [ + ['firehub'], + [''] + ]; + + } + + /** + * @since 1.0.0 + * + * @return array> + */ + public static function int ():array { + + return [ + [10], + [-5], + [0] + ]; + + } + + /** + * @since 1.0.0 + * + * @return array> + */ + public static function float ():array { + + return [ + [10.5], + [-2.3] + ]; + + } + + /** + * @since 1.0.0 + * + * @return array> + */ + public static function array ():array { + + return [ + [[1, 2, 3]], + [[1 => 'one', 2 => 'two', 3 => 'three']] + ]; + + } + + /** + * @since 1.0.0 + * + * @return array> + */ + public static function null ():array { + + return [ + [null] + ]; + + } + + /** + * @since 1.0.0 + * + * @return array> + */ + public static function bool ():array { + + return [ + [true], + [false] + ]; + + } + + /** + * @since 1.0.0 + * + * @return array> + */ + public static function callable ():array { + + return [ + [fn() => true], + [new class {public function __invoke () {}}] + ]; + + } + + /** + * @since 1.0.0 + * + * @return array> + */ + public static function countable ():array { + + return [ + [new class implements Countable {public function count ():int {return 10;}}] + ]; + + } + + /** + * @since 1.0.0 + * + * @return array> + */ + public static function resource ():array { + + return [ + [fopen('php://stdout', 'wb')] + ]; + + } + + /** + * @since 1.0.0 + * + * @return array> + */ + public static function closedResource ():array { + + $resource = fopen('php://stdout', 'wb'); + fclose($resource); + + return [ + [$resource] + ]; + + } + +} \ No newline at end of file diff --git a/src/DataProviders/DateDataProvider.php b/src/DataProviders/DateDataProvider.php new file mode 100644 index 0000000..a1505b8 --- /dev/null +++ b/src/DataProviders/DateDataProvider.php @@ -0,0 +1,71 @@ + + * @copyright 2026-present The FireHub Project - All rights reserved + * @license https://opensource.org/license/MIT MIT License + * + * @php-version >=7.4 + * @package Testing + */ + +namespace FireHub\Testing\DataProviders; + +/** + * ### Date data provider + * @since 1.0.0 + */ +final class DateDataProvider { + + /** + * @since 1.0.0 + * + * @return array + */ + public static function validDates ():array { + + return [ + [1, 1, 1], + [2024, 12, 31], + [1000, 10, 6] + ]; + + } + + /** + * @since 1.0.0 + * + * @return array + */ + public static function invalidDates ():array { + + return [ + [0, -1, -1], + [1, 1, 32], + [1, 13, 12] + ]; + + } + + /** + * @since 1.0.0 + * + * @return array + */ + public static function stringToTime ():array { + + return [ + ['now'], + ['10 September 2000'], + ['+1 day'], + ['+1 week'], + ['+1 week 2 days 4 hours 2 seconds'], + ['next Thursday'], + ['last Monday'] + ]; + + } + +} \ No newline at end of file diff --git a/src/DataProviders/NumDataProvider.php b/src/DataProviders/NumDataProvider.php new file mode 100644 index 0000000..080eedd --- /dev/null +++ b/src/DataProviders/NumDataProvider.php @@ -0,0 +1,88 @@ + + * @copyright 2026-present The FireHub Project - All rights reserved + * @license https://opensource.org/license/MIT MIT License + * + * @php-version >=7.4 + * @package Testing + */ + +namespace FireHub\Testing\DataProviders; + +/** + * ### Numeric data provider + * @since 1.0.0 + */ +final class NumDataProvider { + + /** + * @since 1.0.0 + * + * @return array> + */ + public static function positiveInt ():array { + + return [[10], [45874], [INF]]; + + } + + /** + * @since 1.0.0 + * + * @return array> + */ + public static function negativeInt ():array { + + return [[-1], [-4568], [-INF]]; + + } + + /** + * @since 1.0.0 + * + * @return array> + */ + public static function positiveFloat ():array { + + return [[0.435435], [45.223], [43253.43543]]; + + } + + /** + * @since 1.0.0 + * + * @return array> + */ + public static function negativeFloat ():array { + + return [[-0.3532545], [-1.2], [-10.567]]; + + } + + /** + * @since 1.0.0 + * + * @return array> + */ + public static function null ():array { + + return [[0], [-0], [0.0000], [-0.00]]; + + } + + /** + * @since 1.0.0 + * + * @return array> + */ + public static function nan ():array { + + return [[NAN]]; + + } + +} \ No newline at end of file diff --git a/src/DataProviders/ResourceDataProvider.php b/src/DataProviders/ResourceDataProvider.php new file mode 100644 index 0000000..929de85 --- /dev/null +++ b/src/DataProviders/ResourceDataProvider.php @@ -0,0 +1,35 @@ + + * @copyright 2026-present The FireHub Project - All rights reserved + * @license https://opensource.org/license/MIT MIT License + * + * @php-version >=7.4 + * @package Testing + */ + +namespace FireHub\Testing\DataProviders; + +/** + * ### Resource data provider + * @since 1.0.0 + */ +final class ResourceDataProvider { + + /** + * @since 1.0.0 + * + * @return array> + */ + public static function stream ():array { + + return [ + [fopen('php://stdout', 'wb')] + ]; + + } + +} \ No newline at end of file diff --git a/src/DataProviders/StrDataProvider.php b/src/DataProviders/StrDataProvider.php new file mode 100644 index 0000000..2b3b460 --- /dev/null +++ b/src/DataProviders/StrDataProvider.php @@ -0,0 +1,48 @@ + + * @copyright 2026-present The FireHub Project - All rights reserved + * @license https://opensource.org/license/MIT MIT License + * + * @php-version >=7.4 + * @package Testing + */ + +namespace FireHub\Testing\DataProviders; + +/** + * ### String data provider + * @since 1.0.0 + */ +final class StrDataProvider { + + /** + * @since 1.0.0 + * + * @return array> + */ + public static function stringsSB ():array { + + return [ + ['The lazy fox jumped over the fence.'] + ]; + + } + + /** + * @since 1.0.0 + * + * @return array> + */ + public static function stringsMB ():array { + + return [ + ['đščćž 诶杰艾玛 ЛЙ ÈßÁ カタカナ'] + ]; + + } + +} \ No newline at end of file diff --git a/src/Stubs/CountableClass.php b/src/Stubs/CountableClass.php new file mode 100644 index 0000000..96fd107 --- /dev/null +++ b/src/Stubs/CountableClass.php @@ -0,0 +1,35 @@ + + * @copyright 2026-present The FireHub Project - All rights reserved + * @license https://opensource.org/license/MIT MIT License + * + * @php-version >=7.4 + * @package Testing + */ + +namespace FireHub\Testing\Stubs; + +use Countable; + +/** + * ### Countable class + * @since 1.0.0 + */ +class CountableClass implements Countable { + + /** + * @since 1.0.0 + * + * @return int + */ + public function count ():int { + + return 10; + + } + +} \ No newline at end of file diff --git a/src/Stubs/EmptyClass.php b/src/Stubs/EmptyClass.php new file mode 100644 index 0000000..7a00c4f --- /dev/null +++ b/src/Stubs/EmptyClass.php @@ -0,0 +1,20 @@ + + * @copyright 2026-present The FireHub Project - All rights reserved + * @license https://opensource.org/license/MIT MIT License + * + * @php-version >=7.4 + * @package Testing + */ + +namespace FireHub\Testing\Stubs; + +/** + * ### Normal class + * @since 1.0.0 + */ +class EmptyClass {} \ No newline at end of file diff --git a/src/Stubs/EmptyEnum.php b/src/Stubs/EmptyEnum.php new file mode 100644 index 0000000..6f571ec --- /dev/null +++ b/src/Stubs/EmptyEnum.php @@ -0,0 +1,20 @@ + + * @copyright 2026-present The FireHub Project - All rights reserved + * @license https://opensource.org/license/MIT MIT License + * + * @php-version >=8.1 + * @package Testing + */ + +namespace FireHub\Testing\Stubs; + +/** + * ### Normal enum + * @since 1.0.0 + */ +enum EmptyEnum {} \ No newline at end of file diff --git a/src/Stubs/EmptyInterface.php b/src/Stubs/EmptyInterface.php new file mode 100644 index 0000000..933fc1a --- /dev/null +++ b/src/Stubs/EmptyInterface.php @@ -0,0 +1,20 @@ + + * @copyright 2026-present The FireHub Project - All rights reserved + * @license https://opensource.org/license/MIT MIT License + * + * @php-version >=7.4 + * @package Testing + */ + +namespace FireHub\Testing\Stubs; + +/** + * ### Normal interface + * @since 1.0.0 + */ +interface EmptyInterface {} \ No newline at end of file diff --git a/src/Stubs/EmptyTrait.php b/src/Stubs/EmptyTrait.php new file mode 100644 index 0000000..5c99593 --- /dev/null +++ b/src/Stubs/EmptyTrait.php @@ -0,0 +1,20 @@ + + * @copyright 2026-present The FireHub Project - All rights reserved + * @license https://opensource.org/license/MIT MIT License + * + * @php-version >=7.4 + * @package Testing + */ + +namespace FireHub\Testing\Stubs; + +/** + * ### Normal trait + * @since 1.0.0 + */ +trait EmptyTrait {} \ No newline at end of file