Browse Source

Fixing use of deprecated methods in \Auth tests

Florian Krämer 8 years ago
parent
commit
bc74e85b99

+ 3 - 3
tests/TestCase/Auth/BasicAuthenticateTest.php

@@ -68,8 +68,8 @@ class BasicAuthenticateTest extends TestCase
             'userModel' => 'AuthUser',
             'fields' => ['username' => 'user', 'password' => 'password']
         ]);
-        $this->assertEquals('AuthUser', $object->config('userModel'));
-        $this->assertEquals(['username' => 'user', 'password' => 'password'], $object->config('fields'));
+        $this->assertEquals('AuthUser', $object->getConfig('userModel'));
+        $this->assertEquals(['username' => 'user', 'password' => 'password'], $object->getConfig('fields'));
     }
 
     /**
@@ -220,7 +220,7 @@ class BasicAuthenticateTest extends TestCase
      */
     public function testAuthenticateFailReChallenge()
     {
-        $this->auth->config('scope.username', 'nate');
+        $this->auth->setConfig('scope.username', 'nate');
         $request = new ServerRequest([
             'url' => 'posts/index',
             'environment' => [

+ 5 - 5
tests/TestCase/Auth/DigestAuthenticateTest.php

@@ -83,10 +83,10 @@ class DigestAuthenticateTest extends TestCase
             'fields' => ['username' => 'user', 'password' => 'pass'],
             'nonce' => 123456
         ]);
-        $this->assertEquals('AuthUser', $object->config('userModel'));
-        $this->assertEquals(['username' => 'user', 'password' => 'pass'], $object->config('fields'));
-        $this->assertEquals(123456, $object->config('nonce'));
-        $this->assertEquals(env('SERVER_NAME'), $object->config('realm'));
+        $this->assertEquals('AuthUser', $object->getConfig('userModel'));
+        $this->assertEquals(['username' => 'user', 'password' => 'pass'], $object->getConfig('fields'));
+        $this->assertEquals(123456, $object->getConfig('nonce'));
+        $this->assertEquals(env('SERVER_NAME'), $object->getConfig('realm'));
     }
 
     /**
@@ -357,7 +357,7 @@ class DigestAuthenticateTest extends TestCase
      */
     public function testAuthenticateFailReChallenge()
     {
-        $this->auth->config('scope.username', 'nate');
+        $this->auth->setConfig('scope.username', 'nate');
         $request = new ServerRequest([
             'url' => 'posts/index',
             'environment' => ['REQUEST_METHOD' => 'GET']

+ 10 - 10
tests/TestCase/Auth/FormAuthenticateTest.php

@@ -75,8 +75,8 @@ class FormAuthenticateTest extends TestCase
             'userModel' => 'AuthUsers',
             'fields' => ['username' => 'user', 'password' => 'password']
         ]);
-        $this->assertEquals('AuthUsers', $object->config('userModel'));
-        $this->assertEquals(['username' => 'user', 'password' => 'password'], $object->config('fields'));
+        $this->assertEquals('AuthUsers', $object->getConfig('userModel'));
+        $this->assertEquals(['username' => 'user', 'password' => 'password'], $object->getConfig('fields'));
     }
 
     /**
@@ -259,7 +259,7 @@ class FormAuthenticateTest extends TestCase
         $user['password'] = password_hash(Security::getSalt() . 'cake', PASSWORD_BCRYPT);
         $PluginModel->save(new Entity($user));
 
-        $this->auth->config('userModel', 'TestPlugin.AuthUsers');
+        $this->auth->setConfig('userModel', 'TestPlugin.AuthUsers');
 
         $request = new ServerRequest('posts/index');
         $request->data = [
@@ -291,7 +291,7 @@ class FormAuthenticateTest extends TestCase
             'password' => 'password'
         ];
 
-        $this->auth->config([
+        $this->auth->setConfig([
             'userModel' => 'AuthUsers',
             'finder' => 'auth'
         ]);
@@ -303,7 +303,7 @@ class FormAuthenticateTest extends TestCase
         ];
         $this->assertEquals($expected, $result, 'Result should not contain "created" and "modified" fields');
 
-        $this->auth->config([
+        $this->auth->setConfig([
             'finder' => ['auth' => ['return_created' => true]]
         ]);
 
@@ -329,7 +329,7 @@ class FormAuthenticateTest extends TestCase
             'password' => 'password'
         ];
 
-        $this->auth->config([
+        $this->auth->setConfig([
             'userModel' => 'AuthUsers',
             'finder' => 'username'
         ]);
@@ -341,7 +341,7 @@ class FormAuthenticateTest extends TestCase
         ];
         $this->assertEquals($expected, $result);
 
-        $this->auth->config([
+        $this->auth->setConfig([
             'finder' => ['username' => ['username' => 'nate']]
         ]);
 
@@ -360,13 +360,13 @@ class FormAuthenticateTest extends TestCase
      */
     public function testPasswordHasherSettings()
     {
-        $this->auth->config('passwordHasher', [
+        $this->auth->setConfig('passwordHasher', [
             'className' => 'Default',
             'hashType' => PASSWORD_BCRYPT
         ]);
 
         $passwordHasher = $this->auth->passwordHasher();
-        $result = $passwordHasher->config();
+        $result = $passwordHasher->getConfig();
         $this->assertEquals(PASSWORD_BCRYPT, $result['hashType']);
 
         $hash = password_hash('mypass', PASSWORD_BCRYPT);
@@ -395,7 +395,7 @@ class FormAuthenticateTest extends TestCase
             'fields' => ['username' => 'username', 'password' => 'password'],
             'userModel' => 'Users'
         ]);
-        $this->auth->config('passwordHasher', [
+        $this->auth->setConfig('passwordHasher', [
             'className' => 'Default'
         ]);
         $this->assertEquals($expected, $this->auth->authenticate($request, $this->response));

+ 1 - 1
tests/TestCase/Auth/PasswordHasherFactoryTest.php

@@ -39,7 +39,7 @@ class PasswordHasherFactoryTest extends TestCase
             'hashOptions' => ['foo' => 'bar']
         ]);
         $this->assertInstanceof('Cake\Auth\DefaultPasswordHasher', $hasher);
-        $this->assertEquals(['foo' => 'bar'], $hasher->config('hashOptions'));
+        $this->assertEquals(['foo' => 'bar'], $hasher->getConfig('hashOptions'));
 
         Plugin::load('TestPlugin');
         $hasher = PasswordHasherFactory::build('TestPlugin.Legacy');

+ 2 - 2
tests/TestCase/Auth/WeakPasswordHasherTest.php

@@ -58,12 +58,12 @@ class WeakPasswordHasherTest extends TestCase
     public function testHashAndCheck()
     {
         $hasher = new WeakPasswordHasher();
-        $hasher->config('hashType', 'md5');
+        $hasher->setConfig('hashType', 'md5');
         $password = $hasher->hash('foo');
         $this->assertTrue($hasher->check('foo', $password));
         $this->assertFalse($hasher->check('bar', $password));
 
-        $hasher->config('hashType', 'sha1');
+        $hasher->setConfig('hashType', 'sha1');
         $this->assertFalse($hasher->check('foo', $password));
     }
 }