Skip to content

Integration Tests for PHP 8 Attributes DataSource, SinglePropDataSource, PropertyInstantiatingHook

Pre-release
Pre-release

Choose a tag to compare

@kassko kassko released this 03 Jan 21:00
· 14 commits to 2.0 since this release
5f8da45

Summary: Integration Tests for PHP 8 Attributes

Date: 2026-01-03
Branch: feat/tests/CoverPhpAttributes

Overview

Added comprehensive integration test coverage for three PHP 8 attributes and created new test documentation.

Changes Made

1. PropertyInstantiatingHook Tests

Location: tests/Integration/Attributes/PropertyInstantiatingHook/

Files Added:

  • PropertyInstantiatingHookTest.php (7 tests)
  • Fixtures/TrackedEntity.php
  • Fixtures/TrackedEntityDataSource.php
  • Fixtures/MultiHookEntity.php
  • Fixtures/EntityWithExternalHook.php
  • Fixtures/InstantiationTracker.php

Test Coverage:

  • Basic hook execution after instantiation
  • Hook method tracking
  • Multiple hooks with priority
  • External service hooks via service locator
  • Multiple entity tracking
  • Lazy loading combined with hooks

2. SinglePropDataSource Tests

Location: tests/Integration/Attributes/SinglePropDataSource/

Files Added:

  • SinglePropDataSourceTest.php (8 tests)
  • Fixtures/Product.php
  • Fixtures/ProductDataSource.php
  • Fixtures/Article.php
  • Fixtures/ArticleDataSource.php

Test Coverage:

  • Single property lazy loading
  • Multiple property loading per entity
  • ID parameter passing
  • Unknown ID handling
  • Property caching
  • Multiple entity instances

3. DataSource Tests (Alias)

Location: tests/Integration/Attributes/DataSource/

Files Added:

  • DataSourceTest.php (8 tests)
  • Fixtures/User.php
  • Fixtures/UserDataSource.php
  • Fixtures/Post.php
  • Fixtures/PostDataSource.php

Test Coverage:

  • Same as SinglePropDataSource (verifies alias works identically)

4. Test Documentation

Location: docs/tests/

Files Added:

  • README.md - Testing documentation overview
  • INTEGRATION_TESTS.md - Detailed integration testing guide

Content:

  • Test organization and structure
  • Naming conventions
  • Fixture patterns
  • Best practices
  • Example code

Statistics

Metric Value
New Test Files 3
New Fixture Files 13
New Documentation Files 2
New Test Cases 23
Previous Test Count 321
New Test Count 344

Test Results

PHPUnit 11.5.46

Time: 00:00.233

Tests: 344, Assertions: 811, Skipped: 3
OK

Patterns Used

All tests follow established patterns:

  • LocalFixtureAutoloadTrait for fixture autoloading
  • Fixtures in Kassko\Sample\<AttributeName>\ namespace
  • LoaderRegistry::clear() in tearDown
  • DataMapperProviderInterface for portable tests