Skip to content

refactor: move the smtp option parsing into a pure class - #6

Merged
vitormattos merged 1 commit into
test/integration-harnessfrom
refactor/option-values-in-src
Sep 26, 2026
Merged

vitormattos merged 1 commit into
test/integration-harnessfrom
refactor/option-values-in-src

Conversation

@YvesCesar

Copy link
Copy Markdown
Member

Stacked on #5.

The two decisions the plugin makes on its options, whether smtp_auth means "on" and whether an SSL option turns a certificate check on, off or leaves the default, were written inline in the phpmailer_init callback, so they could only be tested through WordPress.

  • Adds src/OptionValue.php, two pure static methods: smtp_auth() keeps the existing rules (TRUE, ON, 1, OK, any non-zero number), and ssl() returns true, false or null for "keep the PHP default". The main file loads the class with require_once; the Composer autoloader only serves PHPUnit and PHPStan.
  • librecode_simple_smtp_mail_sender() now only reads the options and hands them to OptionValue.
  • Adds a unit suite (phpunit.xml.dist, composer test:unit) that runs without WordPress or a database, with named data providers for both methods. composer test runs unit, then integration.

No behaviour change: the integration suite from #5 passes unchanged. composer ci passes with 31 unit and 38 integration tests.

Signed-off-by: YvesCesar <yvesamorim73@gmail.com>
@vitormattos
vitormattos merged commit 42c215d into test/integration-harness Sep 26, 2026
17 checks passed
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