Hi there,
I need some help with functional tests.
I want to test logout action:
I try to make GET request to logout method and I want to catch exception ‘Method Not Allowed. This url can only handle the following request methods: POST.’
How can I catch this exception in a test?
I tried
... here is success login action ...
$I->amGoingTo('try to logout by url');
try {
$I->amOnPage(Yii::$app->urlManager->createUrl('site/logout'));
} catch(Exception $exc) {
$I->expectTo('see error page');
$I->see('Method Not Allowed. This url can only handle the following request methods: POST.');
}
also I tried
$I->amGoingTo('try to logout by url');
try {
$I->amOnPage(Yii::$app->urlManager->createUrl('site/logout'));
} catch(Exception $exc) {
}
$I->expectTo('see error page');
$I->see('Method Not Allowed. This url can only handle the following request methods: POST.');
But test did not pass because
$I->amOnPage(Yii::$app->urlManager->createUrl('site/logout'));
don’t navigate $I to another page and $I get previous page when trying to
$I->see('Method Not Allowed. This url can only handle the following request methods: POST.');
What am I doing wrong?
Thank you!