test: Phase 2 — Unit tests for Model/Poll, Feedback and Voter (#13)#17
Open
sabbir1991 wants to merge 13 commits into
Open
test: Phase 2 — Unit tests for Model/Poll, Feedback and Voter (#13)#17sabbir1991 wants to merge 13 commits into
sabbir1991 wants to merge 13 commits into
Conversation
Regenerated by composer install after dev dependencies (Brain\Monkey, wp-phpunit, phpunit polyfills) were resolved for the PHPUnit testing setup. https://claude.ai/code/session_01H4AnuTdcudBToKnMKmQb54
…n trait (#12) - Add POLLIFY_FILTER_SANITIZE_STRING, POLLIFY_PATH constants and require helpers/functions.php in tests/bootstrap.php - tests/Unit/Helpers/FunctionsTest.php — covers all functions in includes/helpers/functions.php (country name, formatted votes, shorthand styles, border styles, block filtering, load template, filter input, nav, display IP) - tests/Unit/FeedbackFactoryTest.php — covers constructor (array/object input), get() error cases (empty/unknown type), Poll instantiation, data hydration, get_class_map(), and filter-extended map via @runInSeparateProcess - tests/Unit/Traits/SingletonTest.php — covers same-instance guarantee, init action fires once, action not fired on repeated calls, distinct instances for distinct classes 107 tests, 165 assertions — all passing https://claude.ai/code/session_01H4AnuTdcudBToKnMKmQb54
…an run on updated HEAD
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
tests/Unit/Model/PollTest.php— 7 tests coveringPoll::vote(): validation short-circuits (empty options, poll closed, login required), DB insert failure, success path, sensitive field stripping, and view-result confirmation with template renderingtests/Unit/Model/FeedbackTest.php— 8 new tests coveringis_valid_poll_option(),get_settings(),get_data(),get_options(),get_response()tests/Unit/Model/VoterTest.php— 4 new tests coveringget_user_agent(), Class B private IP range inis_local_ip(), CloudflareCF-Connecting-IPheader, andX-Forwarded-Forignored when proxy not trustedAll tests follow the established patterns from
VotesTest.php: same$wpdbanonymous-class mock, same Brain\Monkey stubs insetUp(), samemock_poll_cache()helper forFeedbackManager::get()cache hits.Test plan
composer test— 125 tests, 206 assertions, 0 failurescomposer cs— PHPCS passes on all production codestatuskey to settings defaults to satisfyis_poll_closed())Closes #13
Generated by Claude Code
Test in WP Playground
▶ Test in WP Playground