Skip to content

Commit

Permalink
Fix tests (#11)
Browse files Browse the repository at this point in the history
  • Loading branch information
rustamwin committed Sep 17, 2022
1 parent 86ff5d2 commit 75f605a
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
9 changes: 8 additions & 1 deletion tests/IpFilterTest.php
Expand Up @@ -11,6 +11,7 @@
use Psr\Http\Message\ServerRequestInterface;
use Psr\Http\Server\RequestHandlerInterface;
use Yiisoft\Http\Status;
use Yiisoft\Translator\TranslatorInterface;
use Yiisoft\Validator\SimpleRuleHandlerContainer;
use Yiisoft\Validator\Validator;
use Yiisoft\Yii\Middleware\IpFilter;
Expand Down Expand Up @@ -118,6 +119,12 @@ public function testProcessCallsRequestHandlerWithSetClientIpAttribute(): void

protected function createValidator(): Validator
{
return new Validator(new SimpleRuleHandlerContainer());
$translator = $this->createMock(TranslatorInterface::class);
$translator->method('translate')
->willReturnCallback(function ($message, $parameters) {
return $message;
});

return new Validator(new SimpleRuleHandlerContainer($translator));
}
}
9 changes: 8 additions & 1 deletion tests/TrustedHostsNetworkResolverTest.php
Expand Up @@ -10,6 +10,7 @@
use Psr\Http\Message\ServerRequestInterface;
use RuntimeException;
use Yiisoft\Http\Status;
use Yiisoft\Translator\TranslatorInterface;
use Yiisoft\Validator\SimpleRuleHandlerContainer;
use Yiisoft\Validator\Validator;
use Yiisoft\Yii\Middleware\TrustedHostsNetworkResolver;
Expand Down Expand Up @@ -382,8 +383,14 @@ private function createRequestWithSchemaAndHeaders(

private function createTrustedHostsNetworkResolver(): TrustedHostsNetworkResolver
{
$translator = $this->createMock(TranslatorInterface::class);
$translator->method('translate')
->willReturnCallback(function ($message, $parameters) {
return $message;
});

return new TrustedHostsNetworkResolver(
new Validator(new SimpleRuleHandlerContainer())
new Validator(new SimpleRuleHandlerContainer($translator))
);
}
}

0 comments on commit 75f605a

Please sign in to comment.