Skip to content

Add meaningful Laravel DX tests and cleanup docs index#5

Merged
h3mantD merged 5 commits intomasterfrom
improve-dx
Mar 13, 2026
Merged

Add meaningful Laravel DX tests and cleanup docs index#5
h3mantD merged 5 commits intomasterfrom
improve-dx

Conversation

@h3mantD
Copy link
Copy Markdown
Owner

@h3mantD h3mantD commented Mar 13, 2026

Summary

  • add behavior-focused Laravel DX tests for service provider wiring, installer command flow, and Laravel storage reconnect behavior
  • add focused parser/property/address-codec validation tests without relying on brittle private-method coverage hacks
  • remove stale docs index link and ignore generated coverage artifact directories (build/, tests/var/)

Validation

  • ./vendor/bin/phpunit --no-coverage
  • ./vendor/bin/pint --test
  • XDEBUG_MODE=coverage ./vendor/bin/phpunit --coverage-text

Summary by CodeRabbit

  • Documentation

    • Removed the Package Tracker link from the documentation map.
  • Tests

    • Added extensive new test suites covering model validations, property error handling, address codec and parser validations/behaviors, install command flows, and Laravel integration/storage scenarios.
  • Chores

    • Updated ignore rules to exclude build artifacts and test-generated directories.

h3mantD added 2 commits March 13, 2026 23:37
Add behavior-focused tests for provider wiring, installer command flow, parser/error paths, and Laravel storage reconnect behavior while ignoring generated coverage artifacts.
@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Mar 13, 2026

Warning

Rate limit exceeded

@h3mantD has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 8 minutes and 55 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: f39d2471-3c7f-4234-8eb8-d58236df1756

📥 Commits

Reviewing files that changed from the base of the PR and between b870e9a and 56c226e.

📒 Files selected for processing (5)
  • src/IP.php
  • src/Network.php
  • src/Parser.php
  • src/RangeSet.php
  • tests/InstallCommandTest.php
📝 Walkthrough

Walkthrough

Adds new PHPUnit test suites covering models, parsing, address codec, installer command behavior, and Laravel integration; updates .gitignore to ignore /build/ and /tests/var/; removes two lines from docs/README.md (Package Tracker link and its bullet).

Changes

Cohort / File(s) Summary
Configuration & Documentation
\.gitignore, docs/README.md
Added /build/ and /tests/var/ to ignore rules; removed Package Tracker link and its accompanying bullet from documentation map.
Unit Tests (coverage & probes)
tests/DxCoverageTest.php
New test suite adding DxCoverageTest with multiple assertions for IpRange, PropertyTrait error handling (via PropertyTraitProbe), AddressCodec, and Parser behavior/validation.
Install Command Tests
tests/InstallCommandTest.php
New tests for install command publishing and migration execution, including RecordingCommand and helper to wire command execution and capture calls; tests flag handling (--force, --no-migrate).
Laravel Integration Tests & Fakes
tests/LaravelIntegrationDxTest.php
Comprehensive integration tests that register/boot IPToolsServiceProvider, validate publishing paths, and exercise LaravelRangeStorage across PDO refresh; introduces FakeProviderApp, FakeArtisan, FakeConfig and other test harness helpers.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related PRs

Poem

🐰 Hop-hop, I stamped a tiny test,

I chased a bug and gave it rest,
From parser fields to Laravel's gate,
My little paws validate! 🥕

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 5.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title directly and specifically describes the main changes: adding Laravel DX tests and cleaning up the docs index, which aligns with the primary objectives.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch improve-dx
📝 Coding Plan
  • Generate coding plan for human review comments

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Avoid prompt runtime coupling in low-dependency CI by exercising InstallCommand::handle with wired input/output while preserving publish and migrate behavior assertions.
Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
tests/InstallCommandTest.php (1)

118-141: Consider extending FakeConsoleContainer for Prompts support.

The FakeConsoleContainer provides minimal implementations but may need additional methods or properties to satisfy Laravel Prompts dependencies (which is causing the pipeline failure). Once you add the Prompts fallback in setUp(), this container should work correctly.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@tests/InstallCommandTest.php` around lines 118 - 141, The
FakeConsoleContainer lacks support for Laravel Prompts, causing failures; update
FakeConsoleContainer (used in setUp) to provide a Prompts fallback by handling
Prompts::class in make() (returning a suitable Prompts instance tied to the
provided input/output or a minimal stub) and add any small helper methods
Prompts expects (e.g., methods to read/write or a simple constructor) so that
runningUnitTests(), make(), and call() satisfy Prompts dependencies when setUp
registers the fallback.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@tests/InstallCommandTest.php`:
- Around line 118-141: The FakeConsoleContainer lacks support for Laravel
Prompts, causing failures; update FakeConsoleContainer (used in setUp) to
provide a Prompts fallback by handling Prompts::class in make() (returning a
suitable Prompts instance tied to the provided input/output or a minimal stub)
and add any small helper methods Prompts expects (e.g., methods to read/write or
a simple constructor) so that runningUnitTests(), make(), and call() satisfy
Prompts dependencies when setUp registers the fallback.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 0088c7bd-9893-4e70-ab5e-65aff6f3fac3

📥 Commits

Reviewing files that changed from the base of the PR and between 11dfe4c and 0fb17f7.

📒 Files selected for processing (5)
  • .gitignore
  • docs/README.md
  • tests/DxCoverageTest.php
  • tests/InstallCommandTest.php
  • tests/LaravelIntegrationDxTest.php
💤 Files with no reviewable changes (1)
  • docs/README.md

Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
tests/InstallCommandTest.php (1)

45-52: Assert the exit code in the second test as well.

You currently verify call recording only. Capturing and asserting handle() return value here too makes failure mode clearer and keeps both tests consistent.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@tests/InstallCommandTest.php` around lines 45 - 52, In the second test in
InstallCommandTest update the invocation of InstallCommand::handle() to capture
and assert its exit code just like the other test does: call $exit =
$command->handle() and add an assertion that $exit equals the expected exit code
(e.g. 0) in addition to the existing assertion on RecordingCommand::$calls;
reference the same RecordingCommand and handle() usage so both tests
consistently verify the return value and recorded calls.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@tests/InstallCommandTest.php`:
- Around line 89-91: The test registers the 'tag' option with the default
VALUE_NONE mode but the test (and InstallCommand) passes a string value for
'--tag', causing Symfony to reject it; update the option registration in the
block where $this->name === 'vendor:publish' so that addOption('tag', ...) is
created with a value-accepting mode (e.g., InputOption::VALUE_REQUIRED or
InputOption::VALUE_OPTIONAL) while leaving addOption('force') as VALUE_NONE, and
ensure InputOption is imported or fully qualified when changing the addOption
call.

---

Nitpick comments:
In `@tests/InstallCommandTest.php`:
- Around line 45-52: In the second test in InstallCommandTest update the
invocation of InstallCommand::handle() to capture and assert its exit code just
like the other test does: call $exit = $command->handle() and add an assertion
that $exit equals the expected exit code (e.g. 0) in addition to the existing
assertion on RecordingCommand::$calls; reference the same RecordingCommand and
handle() usage so both tests consistently verify the return value and recorded
calls.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 0769bd43-2d94-49c8-8bdd-11a357f9809b

📥 Commits

Reviewing files that changed from the base of the PR and between 0fb17f7 and b870e9a.

📒 Files selected for processing (1)
  • tests/InstallCommandTest.php

Comment on lines +89 to +91
if ($this->name === 'vendor:publish') {
$this->addOption('tag');
$this->addOption('force');
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🔴 Critical

🧩 Analysis chain

🌐 Web query:

In Symfony Console, what mode does Command::addOption() use when mode is omitted, and does a VALUE_NONE option accept string values (e.g., --tag=foo)?

💡 Result:

  • If you omit the $mode in Command::addOption(), it is passed as null to InputOption, whose constructor converts null to InputOption::VALUE_NONE (the default behavior for options). [1], [2]
  • A VALUE_NONE option does not accept a value. Passing a value such as --tag=foo (or --tag foo) results in an error (The "--tag" option does not accept a value.). [3]

Sources
[1] https://raw.githubusercontent.com/symfony/console/7.2/Command/Command.php
[2] https://raw.githubusercontent.com/symfony/console/7.2/Input/InputOption.php
[3] https://raw.githubusercontent.com/symfony/console/7.2/Input/ArgvInput.php


🏁 Script executed:

# Find InstallCommand file
fd -t f "InstallCommand" | head -20

Repository: h3mantD/IPTools

Length of output: 118


🏁 Script executed:

# Also search for where --tag is being passed with a value
rg -n "tag.*iptools-config|--tag.*=|tag.*=>.*['\"]" --type php | head -20

Repository: h3mantD/IPTools

Length of output: 1217


🏁 Script executed:

# Read InstallCommand.php to see how it passes the tag
cat -n src/Console/InstallCommand.php | head -60

Repository: h3mantD/IPTools

Length of output: 2049


🏁 Script executed:

# Read InstallCommandTest.php to see the full context
cat -n tests/InstallCommandTest.php

Repository: h3mantD/IPTools

Length of output: 4801


🏁 Script executed:

# Verify the exact mode needed for tag option
rg -A 3 "addOption.*tag" tests/InstallCommandTest.php

Repository: h3mantD/IPTools

Length of output: 155


🏁 Script executed:

# Check Symfony InputOption constants to confirm VALUE_REQUIRED is the right mode
rg "VALUE_REQUIRED|VALUE_OPTIONAL|VALUE_NONE" --type php | grep -i inputoption | head -10

Repository: h3mantD/IPTools

Length of output: 41


tag option mode is incorrect and will cause sub-command invocation to fail.

Lines 90–91 define tag and force with default mode (VALUE_NONE). However, InstallCommand passes a string value for tag (['--tag' => 'iptools-config'] etc.), which Symfony Console will reject because VALUE_NONE options do not accept values. This breaks the test assertions.

Proposed fix
 use Symfony\Component\Console\Input\ArrayInput;
 use Symfony\Component\Console\Input\InputInterface;
+use Symfony\Component\Console\Input\InputOption;
 use Symfony\Component\Console\Output\BufferedOutput;
@@
         if ($this->name === 'vendor:publish') {
-            $this->addOption('tag');
-            $this->addOption('force');
+            $this->addOption('tag', null, InputOption::VALUE_REQUIRED);
+            $this->addOption('force', null, InputOption::VALUE_NONE);
@@
         if ($this->name === 'migrate') {
-            $this->addOption('force');
+            $this->addOption('force', null, InputOption::VALUE_NONE);
         }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
if ($this->name === 'vendor:publish') {
$this->addOption('tag');
$this->addOption('force');
use Symfony\Component\Console\Input\ArrayInput;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\BufferedOutput;
if ($this->name === 'vendor:publish') {
$this->addOption('tag', null, InputOption::VALUE_REQUIRED);
$this->addOption('force', null, InputOption::VALUE_NONE);
}
if ($this->name === 'migrate') {
$this->addOption('force', null, InputOption::VALUE_NONE);
}
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@tests/InstallCommandTest.php` around lines 89 - 91, The test registers the
'tag' option with the default VALUE_NONE mode but the test (and InstallCommand)
passes a string value for '--tag', causing Symfony to reject it; update the
option registration in the block where $this->name === 'vendor:publish' so that
addOption('tag', ...) is created with a value-accepting mode (e.g.,
InputOption::VALUE_REQUIRED or InputOption::VALUE_OPTIONAL) while leaving
addOption('force') as VALUE_NONE, and ensure InputOption is imported or fully
qualified when changing the addOption call.

h3mantD added 2 commits March 14, 2026 00:13
Simplify IP version detection, network host helpers, parser numeric guards, and range-set normalization while preserving behavior and reducing unnecessary branching.
Capture and verify InstallCommand::handle return value in the second scenario for consistent command outcome assertions across install command tests.
@h3mantD h3mantD merged commit f4949df into master Mar 13, 2026
7 checks passed
@h3mantD h3mantD deleted the improve-dx branch March 13, 2026 18:51
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.

1 participant