Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Show deprecated message only if session handler found in Network/Sess…
…ion namespace
  • Loading branch information
garas committed Jun 21, 2018
1 parent 07457ed commit 7a4ca21
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
4 changes: 3 additions & 1 deletion src/Http/Session.php
Expand Up @@ -257,8 +257,10 @@ public function engine($class = null, array $options = [])
$className = App::className($class, 'Http/Session');

if (!$className) {
deprecationWarning('Session adapters should be moved to the Http/Session namespace.');
$className = App::className($class, 'Network/Session');
if ($className) {
deprecationWarning('Session adapters should be moved to the Http/Session namespace.');
}
}
if (!$className) {
throw new InvalidArgumentException(
Expand Down
11 changes: 4 additions & 7 deletions tests/TestCase/Http/SessionTest.php
Expand Up @@ -534,13 +534,10 @@ public function testEngineWithPreMadeInstance()
*/
public function testBadEngine()
{
// Not actually deprecated, but we need to supress the deprecation warning.
$this->deprecated(function () {
$this->expectException(\InvalidArgumentException::class);
$this->expectExceptionMessage('The class "Derp" does not exist and cannot be used as a session engine');
$session = new Session();
$session->engine('Derp');
});
$this->expectException(\InvalidArgumentException::class);
$this->expectExceptionMessage('The class "Derp" does not exist and cannot be used as a session engine');
$session = new Session();
$session->engine('Derp');
}

/**
Expand Down

0 comments on commit 7a4ca21

Please sign in to comment.