createPartialMock(Component::class, ['getActiveSession']); $userComp->method('getActiveSession')->willReturn(null); Yii::$app->set('user', $userComp); $model = new LogoutForm(); $this->assertTrue($model->logout()); } public function testActiveSessionShouldBeDeleted(): void { $session = $this->createPartialMock(AccountSession::class, ['delete']); $session->expects($this->once())->method('delete')->willReturn(true); $userComp = $this->createPartialMock(Component::class, ['getActiveSession']); $userComp->method('getActiveSession')->willReturn($session); Yii::$app->set('user', $userComp); $model = new LogoutForm(); $model->logout(); } }