1 | <?php |
||
2 | declare(strict_types=1); |
||
3 | |||
4 | namespace IntegerNet\SessionUnblocker\Test\Integration; |
||
5 | |||
6 | use IntegerNet\SessionUnblocker\Plugin\SessionStoragePlugin; |
||
7 | use IntegerNet\SessionUnblocker\MethodLog; |
||
8 | use IntegerNet\SessionUnblocker\Test\Util\SectionLoadActionSpy; |
||
9 | use IntegerNet\SessionUnblocker\Test\Util\SessionSpy; |
||
10 | use Magento\Customer\Controller\Section\Load as LoadAction; |
||
11 | use Magento\Framework\Session\Generic as GenericSession; |
||
12 | use Magento\TestFramework\Helper\Bootstrap; |
||
0 ignored issues
–
show
|
|||
13 | use Magento\TestFramework\ObjectManager; |
||
0 ignored issues
–
show
The type
Magento\TestFramework\ObjectManager was not found. Maybe you did not declare it correctly or list all dependencies?
The issue could also be caused by a filter entry in the build configuration.
If the path has been excluded in your configuration, e.g. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths ![]() |
|||
14 | use Magento\TestFramework\TestCase\AbstractController; |
||
0 ignored issues
–
show
The type
Magento\TestFramework\TestCase\AbstractController was not found. Maybe you did not declare it correctly or list all dependencies?
The issue could also be caused by a filter entry in the build configuration.
If the path has been excluded in your configuration, e.g. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths ![]() |
|||
15 | |||
16 | /** |
||
17 | * @magentoAppIsolation enabled |
||
18 | * @magentoAppArea frontend |
||
19 | */ |
||
20 | abstract class AbstractSessionTest extends AbstractController |
||
21 | { |
||
22 | /** |
||
23 | * @var ObjectManager |
||
24 | */ |
||
25 | private $objectManager; |
||
26 | |||
27 | protected function setUp() |
||
28 | { |
||
29 | parent::setUp(); |
||
30 | $this->objectManager = Bootstrap::getObjectManager(); |
||
31 | $this->setUpSpies(); |
||
32 | } |
||
33 | |||
34 | protected function given_session_already_exists(): void |
||
35 | { |
||
36 | $this->dispatch('customer/account/login'); |
||
37 | MethodLog::instance()->reset(); |
||
38 | } |
||
39 | |||
40 | protected function when_dispatched($uri): void |
||
41 | { |
||
42 | $_SERVER['REQUEST_METHOD'] = 'GET'; // to make \Magento\Framework\App\Request\Http::isSafeMethod() return true |
||
43 | $this->dispatch($uri); |
||
44 | } |
||
45 | |||
46 | protected function then_sessions_have_been_started_and_closed_before_action() |
||
47 | { |
||
48 | $methodLog = MethodLog::instance(); |
||
49 | $this->assertTrue( |
||
50 | $methodLog->hasSessionWriteCloseBeforeAction(), |
||
51 | "Session should be closed before controller action. Method log: \n" . |
||
52 | $methodLog->asString() |
||
53 | ); |
||
54 | $this->assertFalse( |
||
55 | $methodLog->hasSessionStartAfterAction(), |
||
56 | "No session should be initialized during or after controller action. Method log: \n" . |
||
57 | $methodLog->asString() |
||
58 | ); |
||
59 | $this->assertTrue( |
||
60 | $methodLog->hasSessionStartBeforeAction(), |
||
61 | "Session should be initialized before controller action. Method log: \n" . |
||
62 | $methodLog->asString() |
||
63 | ); |
||
64 | } |
||
65 | |||
66 | protected function then_sessions_have_not_been_modified_after_write() |
||
67 | { |
||
68 | $methodLog = MethodLog::instance(); |
||
69 | $this->assertFalse( |
||
70 | $methodLog->hasModifyAfterSessionWriteClose(), |
||
71 | "Session should not be modified after close. Method log: \n" . |
||
72 | $methodLog->asString() |
||
73 | ); |
||
74 | } |
||
75 | |||
76 | private function setUpSpies(): void |
||
77 | { |
||
78 | $this->objectManager->configure( |
||
79 | [ |
||
80 | 'preferences' => [ |
||
81 | LoadAction::class => SectionLoadActionSpy::class, |
||
82 | GenericSession::class => SessionSpy::class, |
||
83 | ], |
||
84 | SessionStoragePlugin::class => [ |
||
85 | 'arguments' => ['doLogMethods' => true] |
||
86 | ] |
||
87 | ] |
||
88 | ); |
||
89 | } |
||
90 | } |
||
91 |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths