Skip to content

test: refactor StreamSocketClient tests into focused test cases#166

Open
guillaumedelre wants to merge 1 commit into
bzikarsky:masterfrom
guillaumedelre:feature/issue-112
Open

test: refactor StreamSocketClient tests into focused test cases#166
guillaumedelre wants to merge 1 commit into
bzikarsky:masterfrom
guillaumedelre:feature/issue-112

Conversation

@guillaumedelre
Copy link
Copy Markdown

Split the two existing test files (Tcp and Udp) into four focused test cases as described in issue #112:

  • StreamSocketClientTest: general protocol-agnostic tests extracted from the TCP file (context management, timeout, socket lifecycle, invalid constructor arguments)
  • StreamSocketClientTcpTest: TCP-specific data transfer tests only (write, bad write, multi-write, read, close behaviors)
  • StreamSocketClientUdpTest: trimmed to UDP-specific write test only, removing duplicates now covered by the general test case
  • StreamSocketClientSslTest: new test case covering SSL failure path (connecting with ssl:// to a plain TCP server) and SSL context preservation through the constructor

Fix three pre-existing Psalm errors surfaced during this work:

  • Logger.php: add @param docblock for $message (string|\Stringable) without touching the PHP signature, which must stay untyped for psr/log ^1 compatibility (see gelf-php 2.0.0 incompatible with psr/log:^1 due to method signature being too strict #151)
  • Message.php: add explicit mixed type and @psalm-suppress on the empty() call inside the array_filter closure to preserve the existing behavior
  • HttpTransport.php: replace truthy check on null|string with strict null and empty-string comparisons in fromUrl()

Closes #112

Split the two existing test files (Tcp and Udp) into four focused test cases
as described in issue bzikarsky#112:

- StreamSocketClientTest: general protocol-agnostic tests extracted from
  the TCP file (context management, timeout, socket lifecycle, invalid
  constructor arguments)
- StreamSocketClientTcpTest: TCP-specific data transfer tests only
  (write, bad write, multi-write, read, close behaviors)
- StreamSocketClientUdpTest: trimmed to UDP-specific write test only,
  removing duplicates now covered by the general test case
- StreamSocketClientSslTest: new test case covering SSL failure path
  (connecting with ssl:// to a plain TCP server) and SSL context
  preservation through the constructor

Fix three pre-existing Psalm errors surfaced during this work:

- Logger.php: add @param docblock for $message (string|\Stringable) without
  touching the PHP signature, which must stay untyped for psr/log ^1
  compatibility (see bzikarsky#151)
- Message.php: add explicit mixed type and @psalm-suppress on the empty()
  call inside the array_filter closure to preserve the existing behavior
- HttpTransport.php: replace truthy check on null|string with strict
  null and empty-string comparisons in fromUrl()

Closes bzikarsky#112

Signed-off-by: Guillaume Delre <delre.guillaume@gmail.com>
@guillaumedelre
Copy link
Copy Markdown
Author

Hey @bzikarsky, this PR fixes #112 — happy to adjust if anything looks off.

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.

Refactor StreamSocketClient testing

1 participant