Skip to content

Commit 83f19ce

Browse files
enumagdg
authored andcommitted
composer: removed dependency on nette/security (#132)
1 parent f0b5ac0 commit 83f19ce

File tree

3 files changed

+54
-27
lines changed

3 files changed

+54
-27
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
"nette/component-model": "~2.3",
1919
"nette/http": "~2.2",
2020
"nette/reflection": "~2.2",
21-
"nette/security": "~2.2",
2221
"nette/utils": "~2.4"
2322
},
2423
"suggest": {
@@ -30,6 +29,7 @@
3029
"nette/di": "~2.3",
3130
"nette/forms": "~2.2",
3231
"nette/robot-loader": "~2.2",
32+
"nette/security": "~2.2",
3333
"latte/latte": "~2.4",
3434
"tracy/tracy": "^2.3"
3535
},

src/Application/UI/Presenter.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1080,7 +1080,7 @@ public function storeRequest($expiration = '+ 10 minutes')
10801080
$key = Nette\Utils\Random::generate(5);
10811081
} while (isset($session[$key]));
10821082

1083-
$session[$key] = [$this->getUser()->getId(), $this->request];
1083+
$session[$key] = [$this->user ? $this->user->getId() : NULL, $this->request];
10841084
$session->setExpiration($expiration, $key);
10851085
return $key;
10861086
}

tests/UI/Presenter.storeRequest().phpt

Lines changed: 52 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -81,28 +81,55 @@ class MockUser extends Security\User
8181
}
8282
}
8383

84-
85-
$presenter = new TestPresenter();
86-
$presenter->injectPrimary(
87-
NULL,
88-
NULL,
89-
new Application\Routers\SimpleRouter,
90-
new Http\Request(new Http\UrlScript),
91-
new Http\Response,
92-
$session = new MockSession,
93-
$user = new MockUser
94-
);
95-
96-
$section = $session->testSection = new MockSessionSection($session);
97-
98-
$applicationRequest = new Application\Request('', '', []);
99-
$presenter->run($applicationRequest);
100-
101-
$expiration = '+1 year';
102-
$key = $presenter->storeRequest($expiration);
103-
104-
Assert::same($expiration, $section->testExpiration);
105-
Assert::same($key, $section->testExpirationVariables);
106-
Assert::same($key, $section->testedKeyExistence);
107-
Assert::same($key, $section->storedKey);
108-
Assert::same([$user->getId(), $applicationRequest], $section->storedValue);
84+
test(function () {
85+
$presenter = new TestPresenter();
86+
$presenter->injectPrimary(
87+
NULL,
88+
NULL,
89+
new Application\Routers\SimpleRouter,
90+
new Http\Request(new Http\UrlScript),
91+
new Http\Response,
92+
$session = new MockSession,
93+
$user = new MockUser
94+
);
95+
96+
$section = $session->testSection = new MockSessionSection($session);
97+
98+
$applicationRequest = new Application\Request('', '', []);
99+
$presenter->run($applicationRequest);
100+
101+
$expiration = '+1 year';
102+
$key = $presenter->storeRequest($expiration);
103+
104+
Assert::same($expiration, $section->testExpiration);
105+
Assert::same($key, $section->testExpirationVariables);
106+
Assert::same($key, $section->testedKeyExistence);
107+
Assert::same($key, $section->storedKey);
108+
Assert::same([$user->getId(), $applicationRequest], $section->storedValue);
109+
});
110+
111+
test(function () {
112+
$presenter = new TestPresenter();
113+
$presenter->injectPrimary(
114+
NULL,
115+
NULL,
116+
new Application\Routers\SimpleRouter,
117+
new Http\Request(new Http\UrlScript),
118+
new Http\Response,
119+
$session = new MockSession
120+
);
121+
122+
$section = $session->testSection = new MockSessionSection($session);
123+
124+
$applicationRequest = new Application\Request('', '', []);
125+
$presenter->run($applicationRequest);
126+
127+
$expiration = '+1 year';
128+
$key = $presenter->storeRequest($expiration);
129+
130+
Assert::same($expiration, $section->testExpiration);
131+
Assert::same($key, $section->testExpirationVariables);
132+
Assert::same($key, $section->testedKeyExistence);
133+
Assert::same($key, $section->storedKey);
134+
Assert::same([null, $applicationRequest], $section->storedValue);
135+
});

0 commit comments

Comments
 (0)