Skip to content

Complete AbstractMapper abstraction, add style tests#10

Merged
alganet merged 1 commit intomasterfrom
abstract-mapper
Mar 15, 2026
Merged

Complete AbstractMapper abstraction, add style tests#10
alganet merged 1 commit intomasterfrom
abstract-mapper

Conversation

@alganet
Copy link
Member

@alganet alganet commented Mar 15, 2026

Remove SQL-specific internals from AbstractMapper: make fetch() and fetchAll() abstract, remove createStatement(), fetchHydrated(), and parseHydrated() which encoded PDO/hydration patterns that don't belong in a generic data layer. The only abstract methods are now flush(), fetch(), and fetchAll().

Add comprehensive style tests: 6 pure naming-convention test files (AbstractStyle, Standard, CakePHP, NorthWind, Plural, Sakila) covering table/entity, column/property, foreign key, and composition naming for all styles.

Add InMemoryMapper test double that exercises the full AbstractMapper contract and all 7 Stylable methods using arrays instead of SQL. Add 4 integration test files with entity stubs that verify typed fetch, nested FK resolution, and persist/flush round-trips through the in-memory backend.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR refactors AbstractMapper to remove SQL/PDO-specific internals by making fetch() and fetchAll() part of the mapper’s abstract contract, and adds a comprehensive PHPUnit test suite for naming “styles” plus an in-memory mapper test double to exercise the full mapper/styling behavior without a database.

Changes:

  • Make AbstractMapper::fetch() and AbstractMapper::fetchAll() abstract, and remove the previous statement/hydration-specific implementation.
  • Add InMemoryMapper (test double) and multiple integration tests that validate typed fetching, FK resolution, and persist/flush round-trips across styles.
  • Add style-specific unit tests and update QA tooling configs (PHPCS + PHPStan) to accommodate test entity stubs.

Reviewed changes

Copilot reviewed 35 out of 35 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
src/AbstractMapper.php Moves fetch()/fetchAll() into the abstract contract and removes SQL/hydration internals.
tests/AbstractMapperTest.php Updates the test anonymous mapper to implement the new abstract fetch()/fetchAll() methods.
tests/InMemoryMapper.php Adds an array-backed mapper used by tests to exercise the mapper contract end-to-end.
tests/Styles/AbstractStyleTest.php Adds unit tests for AbstractStyle inflection and name conversion helpers.
tests/Styles/StandardTest.php Adds coverage for Standard naming conventions (table/entity, columns/properties, FK, composition).
tests/Styles/PluralTest.php Adds coverage for Plural naming conventions.
tests/Styles/CakePHPTest.php Adds coverage for CakePHP naming conventions.
tests/Styles/NorthWindTest.php Adds coverage for NorthWind naming conventions.
tests/Styles/SakilaTest.php Adds coverage for Sakila naming conventions.
tests/Styles/CakePHP/CakePHPIntegrationTest.php Integration tests for CakePHP style using InMemoryMapper.
tests/Styles/CakePHP/Author.php CakePHP-style entity stub for integration tests.
tests/Styles/CakePHP/Category.php CakePHP-style entity stub for integration tests.
tests/Styles/CakePHP/Comment.php CakePHP-style entity stub for integration tests.
tests/Styles/CakePHP/Post.php CakePHP-style entity stub for integration tests.
tests/Styles/CakePHP/PostCategory.php CakePHP-style entity stub for integration tests.
tests/Styles/Plural/PluralIntegrationTest.php Integration tests for Plural style using InMemoryMapper.
tests/Styles/Plural/Author.php Plural-style entity stub for integration tests.
tests/Styles/Plural/Category.php Plural-style entity stub for integration tests.
tests/Styles/Plural/Comment.php Plural-style entity stub for integration tests.
tests/Styles/Plural/Post.php Plural-style entity stub for integration tests.
tests/Styles/Plural/PostCategory.php Plural-style entity stub for integration tests.
tests/Styles/NorthWind/NorthWindIntegrationTest.php Integration tests for NorthWind style using InMemoryMapper.
tests/Styles/NorthWind/Authors.php NorthWind-style entity stub for integration tests.
tests/Styles/NorthWind/Categories.php NorthWind-style entity stub for integration tests.
tests/Styles/NorthWind/Comments.php NorthWind-style entity stub for integration tests.
tests/Styles/NorthWind/PostCategories.php NorthWind-style entity stub for integration tests.
tests/Styles/NorthWind/Posts.php NorthWind-style entity stub for integration tests.
tests/Styles/Sakila/SakilaIntegrationTest.php Integration tests for Sakila style using InMemoryMapper.
tests/Styles/Sakila/Author.php Sakila-style entity stub for integration tests.
tests/Styles/Sakila/Category.php Sakila-style entity stub for integration tests.
tests/Styles/Sakila/Comment.php Sakila-style entity stub for integration tests.
tests/Styles/Sakila/Post.php Sakila-style entity stub for integration tests.
tests/Styles/Sakila/PostCategory.php Sakila-style entity stub for integration tests.
phpstan.neon.dist Updates ignore patterns to account for InMemoryMapper dynamic property access in tests.
phpcs.xml.dist Excludes a naming-convention sniff for test code/stubs that use snake_case properties.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review. Take the survey.

Remove SQL-specific internals from AbstractMapper: make fetch()
and fetchAll() abstract, remove createStatement(), fetchHydrated(),
and parseHydrated() which encoded PDO/hydration patterns that
don't belong in a generic data layer. The only abstract methods
are now flush(), fetch(), and fetchAll().

Add comprehensive style tests: 6 pure naming-convention test
files (AbstractStyle, Standard, CakePHP, NorthWind, Plural,
Sakila) covering table/entity, column/property, foreign key,
and composition naming for all styles.

Add InMemoryMapper test double that exercises the full
AbstractMapper contract and all 7 Stylable methods using arrays
instead of SQL. Add 4 integration test files with entity stubs
that verify typed fetch, nested FK resolution, and persist/flush
round-trips through the in-memory backend.
@alganet alganet marked this pull request as ready for review March 15, 2026 05:53
@alganet alganet merged commit a306b3c into master Mar 15, 2026
2 checks passed
@alganet alganet deleted the abstract-mapper branch March 15, 2026 05:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants