These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | |||
3 | declare(strict_types=1); |
||
4 | |||
5 | /* |
||
6 | * This file is part of the Sonata Project package. |
||
7 | * |
||
8 | * (c) Thomas Rabaix <[email protected]> |
||
9 | * |
||
10 | * For the full copyright and license information, please view the LICENSE |
||
11 | * file that was distributed with this source code. |
||
12 | */ |
||
13 | |||
14 | namespace Sonata\AdminBundle\Tests\Filter\Persister; |
||
15 | |||
16 | use PHPUnit\Framework\TestCase; |
||
17 | use Prophecy\Prophecy\ObjectProphecy; |
||
18 | use Sonata\AdminBundle\Filter\Persister\SessionFilterPersister; |
||
19 | use Symfony\Component\HttpFoundation\Session\SessionInterface; |
||
20 | |||
21 | class SessionFilterPersisterTest extends TestCase |
||
22 | { |
||
23 | /** |
||
24 | * @var SessionInterface|ObjectProphecy |
||
25 | */ |
||
26 | private $session; |
||
27 | |||
28 | public function setUp(): void |
||
29 | { |
||
30 | $this->session = $this->prophesize(SessionInterface::class); |
||
31 | } |
||
32 | |||
33 | public function tearDown(): void |
||
34 | { |
||
35 | unset($this->session); |
||
36 | } |
||
37 | |||
38 | public function testGetDefaultValueFromSessionIfNotDefined(): void |
||
39 | { |
||
40 | $this->session->get('admin.customer.filter.parameters', []) |
||
41 | ->shouldBeCalledTimes(1) |
||
42 | ->willReturn([]); |
||
43 | |||
44 | self::assertSame([], $this->createPersister()->get('admin.customer')); |
||
45 | } |
||
46 | |||
47 | public function testGetValueFromSessionIfDefined(): void |
||
48 | { |
||
49 | $filters = [ |
||
50 | 'active' => true, |
||
51 | '_page' => 1, |
||
52 | '_sort_by' => 'firstName', |
||
53 | '_sort_order' => 'ASC', |
||
54 | '_per_page' => 25, |
||
55 | ]; |
||
56 | $this->session->get('admin.customer.filter.parameters', []) |
||
57 | ->shouldBeCalledTimes(1) |
||
58 | ->willReturn($filters); |
||
59 | |||
60 | self::assertSame($filters, $this->createPersister()->get('admin.customer')); |
||
61 | } |
||
62 | |||
63 | public function testSetValueToSession(): void |
||
64 | { |
||
65 | $filters = [ |
||
66 | 'active' => true, |
||
67 | '_page' => 1, |
||
68 | '_sort_by' => 'firstName', |
||
69 | '_sort_order' => 'ASC', |
||
70 | '_per_page' => 25, |
||
71 | ]; |
||
72 | $this->session->set('admin.customer.filter.parameters', $filters) |
||
73 | ->shouldBeCalledTimes(1) |
||
74 | ->willReturn(null); |
||
75 | |||
76 | $this->createPersister()->set('admin.customer', $filters); |
||
77 | } |
||
78 | |||
79 | public function testResetValueToSession(): void |
||
80 | { |
||
81 | $this->session->remove('admin.customer.filter.parameters') |
||
82 | ->shouldBeCalledTimes(1) |
||
83 | ->willReturn(null); |
||
84 | |||
85 | $this->createPersister()->reset('admin.customer'); |
||
86 | } |
||
87 | |||
88 | private function createPersister(): SessionFilterPersister |
||
89 | { |
||
90 | return new SessionFilterPersister($this->session->reveal()); |
||
0 ignored issues
–
show
|
|||
91 | } |
||
92 | } |
||
93 |
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.