Skip to content

Commit

Permalink
clean up network test
Browse files Browse the repository at this point in the history
  • Loading branch information
danslo committed Feb 10, 2025
1 parent 62bf16c commit 58be777
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions Test/Model/RuleTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,13 @@ public function testRuleRegex()

public function testRuleNetwork()
{
$_SERVER['REMOTE_ADDR'] = '123.123.123.123';
$rule = new Rule(new IP(), 'block', [
$ipMock = $this->getMockBuilder(IP::class)
->onlyMethods(['collectRequestIPs'])
->getMock();

$ipMock->method('collectRequestIPs')->willReturn(['123.123.123.123']);

$rule = new Rule($ipMock, 'block', [
new Condition('req.ip', 'network', '123.123.123.0/24')
]);
$this->assertTrue($rule->matches($this->createMock(Http::class)));
Expand Down

0 comments on commit 58be777

Please sign in to comment.