Browse Source

Show deprecated message only if session handler found in Network/Session namespace

Edgaras Janušauskas 7 years ago
parent
commit
7a4ca2195c
2 changed files with 7 additions and 8 deletions
  1. 3 1
      src/Http/Session.php
  2. 4 7
      tests/TestCase/Http/SessionTest.php

+ 3 - 1
src/Http/Session.php

@@ -257,8 +257,10 @@ class Session
         $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(

+ 4 - 7
tests/TestCase/Http/SessionTest.php

@@ -534,13 +534,10 @@ class SessionTest extends TestCase
      */
     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');
     }
 
     /**