Download the PHP package kodhe/test without Composer
On this page you can find all versions of the php package kodhe/test. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Vendor kodhe
Package test
Short Description Kodhe test library - Refactored for modularity and maintainability
License MIT
Package test
Short Description Kodhe test library - Refactored for modularity and maintainability
License MIT
Please rate this library. Is it a good library?
Informations about the package test
Unit Test Library Refactoring Documentation
Architecture Overview
The refactored Unit Test library follows a modular architecture while maintaining full backward compatibility with CodeIgniter 3 API.
Folder Structure
Backward Compatibility Matrix
| Legacy API | New Implementation | Status |
|---|---|---|
$active property |
$active property |
✅ PASS |
$results property |
$results property |
✅ PASS |
$strict property |
$strict property |
✅ PASS |
run() |
UnitTest::run() |
✅ PASS |
report() |
UnitTest::report() |
✅ PASS |
result() |
UnitTest::result() |
✅ PASS |
set_test_items() |
UnitTest::set_test_items() |
✅ PASS |
use_strict() |
UnitTest::use_strict() |
✅ PASS |
active() |
UnitTest::active() |
✅ PASS |
set_template() |
UnitTest::set_template() |
✅ PASS |
reset() |
UnitTest::reset() |
✅ PASS |
is_true() helper |
Kodhe\Test\is_true() |
✅ PASS |
is_false() helper |
Kodhe\Test\is_false() |
✅ PASS |
Public API Preserved
Properties
public $active- Active flag (default: true)public $results- Test results arraypublic $strict- Strict comparison flag (default: false)
Methods
run($test, $expected = true, $test_name = 'undefined', $notes = '')- Run a testreport($result = [])- Generate HTML reportresult($results = [])- Get raw result dataset_test_items($items)- Set visible test itemsuse_strict($state = true)- Enable/disable strict comparisonactive($state = true)- Enable/disable testingset_template($template)- Set custom templatereset()- Reset all results
Helper Functions
is_true($test)- Test for boolean TRUEis_false($test)- Test for boolean FALSE
Type Checking Functions Supported
The following type functions are supported in the run() method:
is_objectis_stringis_boolis_trueis_falseis_intis_numericis_floatis_doubleis_arrayis_nullis_resource
Usage Examples
Legacy API (Fully Compatible)
Modern Internal API
Custom Assertion Example
PSR Standards Compliance
PSR-4 Autoloading
- Namespace:
Kodhe\Test\ - Base directory:
src/ - All classes follow PSR-4 naming conventions
PSR-12 Coding Style
- Strict types declared
- Proper namespace usage
- Consistent brace placement
- Proper PHPDoc formatting
- No tabs, spaces only
Key Improvements
1. Separation of Concerns
- Assertion Logic: Moved to dedicated assertion classes
- Result Handling: Encapsulated in value objects
- Reporting: Separated from test execution
- Formatting: Isolated in formatter classes
2. Extensibility
- Custom assertions via
AssertionInterface - Custom reporters via
ReporterInterface - Custom formatters via
FormatterInterface - Assertion registry for dynamic registration
3. Testability
- Each component can be unit tested independently
- Mock-friendly interfaces
- No hidden dependencies
4. Maintainability
- Clear class responsibilities
- Documented code with PHPDoc
- Type hints where possible
- Consistent naming conventions
Performance Considerations
- Lazy initialization of internal components
- No unnecessary object creation
- Minimal reflection usage
- Efficient result collection
Security Notes
- HTML output is properly escaped in formatters
- No eval() or code execution
- Input validation on type functions
- Error messages don't leak sensitive data
Migration Guide
From Original CI3 Unit Test
No migration needed! The refactored library maintains 100% API compatibility.
For New Code
You can optionally use the modern internal API for better control:
Known Limitations
- Language Dependency: Still requires
kodhe()->langfor label translation - Backtrace: Uses
debug_backtrace()which has performance overhead - HTML Output: Default reporter produces HTML (by design for CI3 compatibility)
Testing Strategy
PHPUnit Tests (To Be Added)
Test Coverage Areas
- [ ] Basic instantiation
- [ ] All public methods
- [ ] Type checking functions
- [ ] Strict vs loose comparison
- [ ] Template handling
- [ ] Result collection
- [ ] Custom assertions
- [ ] Edge cases
Definition of Done Checklist
- [x] All public APIs identified and preserved
- [x] Compatibility facade implemented
- [x] Assertion engine modular
- [x] Result objects created
- [x] Runner separated
- [x] Reporter separated
- [x] Formatter separated
- [x] PSR-4 autoloading configured
- [x] PSR-12 coding style applied
- [x] PHPDoc added
- [x] Helper functions preserved
- [x] No breaking changes introduced
Version History
- 2.0.0 - Refactored version with modular architecture
- 1.1.0 - Original version
License
MIT License - Same as original CodeIgniter Unit Test library
All versions of test with dependencies
PHP Build Version
Package Version
Requires
php Version
>=8.1
The package kodhe/test contains the following files
Loading the files please wait ...