Ajax относится к приемочному тесту. Возвращаемый Ajax, который я тестировал, должен быть сначала зарегистрирован
use tests\codeception\frontend\AcceptanceTester; $I = new AcceptanceTester($scenario); $I->wantTo('perform actions and see result'); $I - > amonpage ('/'); // switch to the configuration site http://admin.handone.com $I - > see ('login '); // assert that you can see the specified text on this page $I->amGoingTo('try to login with correct credentials'); $I - > fillfield ('input [name = "loginform [t_email]] ',' user name '); $I - > fillfield ('input [name = "loginform [T" password]] ',' password '); $I - > Click ('login '); $I->expectTo('see that user is logged'); $I - > SeeLink ('exit '); $I - > dontseelink ('login ');
Перейдите на целевую страницу после успешного входа в систему
$I->wantTo('perform actions and see result'); $I->amOnPage('http://xxx.xxx.xx/sales/index'); $I - > see ('add customer ');
При заполнении параметров
$param = [ 'Sales[t_clues_cat]'=> 9, 'keys_str' => 10449, ]; $I->sendAjaxRequest('post', 'http://xxx.xxx.xx/sales/sales-free', $param); $I->seeResponseCodeIs(200); $I - > see ('1 '); // 1 means success
Когда параметр пуст
$param = []; $I->sendAjaxRequest('post', 'http://xxx.xxx.xx/sales/sales-free', $param); $I->seeResponseCodeIs(200); $I - > see ('2 '); // 2 means failure
Функция
Проверьте операцию и распечатайте слишком много информации, а не рисунок выше
codecept run acceptance SalesCept --debug
Справочная статья:
http://www.kkh86.com/it/codec… https://www.cloudxns.net/Supp…