Skip to content

Commit 2aa91e4

Browse files
authored
Merge pull request #97 from baningo/fix/broken-i-am-logged-in-as
Fix broken `amLoggedInAs` - method parameter is being overwritten
2 parents 219fbd9 + eb609b1 commit 2aa91e4

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/Codeception/Lib/Connector/Yii2.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -133,22 +133,22 @@ public function resetApplication(bool $closeSession = true): void
133133
public function findAndLoginUser(int|string|IdentityInterface $user): void
134134
{
135135
$app = $this->getApplication();
136-
$user = $app->get('user');
137-
if (!$user instanceof User) {
136+
$userComponent = $app->get('user');
137+
if (!$userComponent instanceof User) {
138138
throw new ConfigurationException('The user component is not configured');
139139
}
140140

141141
if ($user instanceof \yii\web\IdentityInterface) {
142142
$identity = $user;
143143
} else {
144144
// class name implementing IdentityInterface
145-
$identityClass = $user->identityClass;
145+
$identityClass = $userComponent->identityClass;
146146
$identity = call_user_func([$identityClass, 'findIdentity'], $user);
147147
if (!isset($identity)) {
148148
throw new \RuntimeException('User not found');
149149
}
150150
}
151-
$user->login($identity);
151+
$userComponent->login($identity);
152152
}
153153

154154
/**

0 commit comments

Comments
 (0)