Skip to content

Commit

Permalink
Fix phpstan
Browse files Browse the repository at this point in the history
  • Loading branch information
franmomu committed Sep 4, 2021
1 parent a40f3df commit 8a4e7f5
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 28 deletions.
3 changes: 0 additions & 3 deletions phpstan-baseline.neon
Expand Up @@ -9,9 +9,6 @@ parameters:
- # https://github.com/phpstan/phpstan-strict-rules/issues/130
message: '#^Call to static method PHPUnit\\Framework\\Assert::.* will always evaluate to true\.$#'
path: tests/
- # BC for Symfony 4 since InputBag was introduce in Symfony 5
message: '#^Property Symfony\\Component\\HttpFoundation\\Request\:\:\$query \(Symfony\\Component\\HttpFoundation\\InputBag\) does not accept Symfony\\Component\\HttpFoundation\\ParameterBag\.$#'
path: tests/Admin/AdminTest.php
- # This error is made on purpose for php version < 8
message: '#^Method Sonata\\AdminBundle\\Tests\\Fixtures\\Entity\\FooToStringNull\:\:__toString\(\) should return string but returns null\.$#'
path: tests/Fixtures/Entity/FooToStringNull.php
Expand Down
37 changes: 12 additions & 25 deletions tests/Admin/AdminTest.php
Expand Up @@ -80,7 +80,6 @@
use Symfony\Component\Form\FormFactory;
use Symfony\Component\Form\FormRegistry;
use Symfony\Component\Form\ResolvedFormTypeFactory;
use Symfony\Component\HttpFoundation\ParameterBag;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Session\SessionInterface;
use Symfony\Component\Routing\RouterInterface;
Expand Down Expand Up @@ -1528,21 +1527,16 @@ public function testGetFilterParameters(): void
$postAdmin = new PostAdmin('sonata.post.admin.post', Post::class, 'Sonata\NewsBundle\Controller\PostAdminController');
$postAdmin->addChild($commentAdmin, 'post__author');

$request = $this->createMock(Request::class);
$query = new ParameterBag();
$query
->set('filter', [
'filter' => [
DatagridInterface::PAGE => '1',
DatagridInterface::PER_PAGE => '32',
],
]);
$request = new Request();

$request->query = $query;
$request->query->set('filter', [
'filter' => [
DatagridInterface::PAGE => '1',
DatagridInterface::PER_PAGE => '32',
],
]);

$request
->method('get')
->willReturn($authorId);
$request->attributes->set($postAdmin->getIdParameter(), $authorId);

$commentAdmin->setRequest($request);

Expand Down Expand Up @@ -1998,10 +1992,8 @@ public function testDefaultFilters(): void

$subjectId = uniqid();

$request = $this->createMock(Request::class);
$query = new ParameterBag();
$query
->set('filter', [
$request = new Request([
'filter' => [
'a' => [
'value' => 'b',
],
Expand All @@ -2013,13 +2005,8 @@ public function testDefaultFilters(): void
'type' => '5',
'value' => 'test',
],
]);

$request->query = $query;

$request
->method('get')
->willReturn($subjectId);
],
]);

$admin->setRequest($request);

Expand Down

0 comments on commit 8a4e7f5

Please sign in to comment.