Skip to content

Commit e4c0968

Browse files
SamMousasamdark
authored andcommitted
Fixed issue #4769 (#5182)
1 parent 192809d commit e4c0968

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

src/Codeception/Lib/Connector/Yii2.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
namespace Codeception\Lib\Connector;
33

44
use Codeception\Exception\ConfigurationException;
5+
use Codeception\Exception\ModuleException;
56
use Codeception\Lib\Connector\Yii2\Logger;
67
use Codeception\Lib\Connector\Yii2\TestMailer;
78
use Codeception\Lib\InnerBrowser;
@@ -107,6 +108,7 @@ public function resetApplication()
107108
* Finds and logs in a user
108109
* @param $user
109110
* @throws ConfigurationException
111+
* @throws \RuntimeException
110112
*/
111113
public function findAndLoginUser($user)
112114
{
@@ -121,6 +123,9 @@ public function findAndLoginUser($user)
121123
// class name implementing IdentityInterface
122124
$identityClass = $app->user->identityClass;
123125
$identity = call_user_func([$identityClass, 'findIdentity'], $user);
126+
if (!isset($identity)) {
127+
throw new \RuntimeException('User not found');
128+
}
124129
}
125130
$app->user->login($identity);
126131
}

src/Codeception/Module/Yii2.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -408,6 +408,8 @@ public function amLoggedInAs($user)
408408
$this->client->findAndLoginUser($user);
409409
} catch (ConfigurationException $e) {
410410
throw new ModuleException($this, $e->getMessage());
411+
} catch (\RuntimeException $e) {
412+
throw new ModuleException($this, $e->getMessage());
411413
}
412414
}
413415

0 commit comments

Comments
 (0)