seeResponseContainsJson() публичный Метод

Checks whether the last JSON response contains provided array. The response is converted to array with json_decode($response, true) Thus, JSON is represented by associative array. This method matches that response array contains provided array. Examples: php seeResponseContainsJson(array('name' => 'john')); response {user: john, profile: { email: john@gmail.com }} $I->seeResponseContainsJson(array('email' => 'john@gmail.com')); ?> This method recursively checks if one array can be found inside of another.
См. также: Codeception\Module\REST::seeResponseContainsJson()
public seeResponseContainsJson ( array $json = null )
$json array
<?php

/*
 * This file is part of the Webception package.
 *
 * (c) James Healey <*****@*****.**>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */
$I = new WebGuy($scenario);
$I->wantTo('check AJAX call when the Codeception log check fails.');
$I->sendGET('logs?test=log_fail');
$I->seeResponseContainsJson(array('ready' => false, 'error' => "The Codeception Log directory does not exist. Please check the following path exists:"));
Пример #2
0
<?php

/*
 * This file is part of the Webception package.
 *
 * (c) James Healey <*****@*****.**>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */
$I = new WebGuy($scenario);
$I->wantTo('run a passing test');
$I->sendGET('run/acceptance/' . md5('acceptance' . 'TheTestThatPasses'));
$I->seeResponseContainsJson(array('message' => NULL, 'run' => true, 'passed' => true, 'state' => 'passed'));
Пример #3
0
<?php

/*
 * This file is part of the Webception package.
 *
 * (c) James Healey <*****@*****.**>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */
$I = new WebGuy($scenario);
$I->wantTo('run a failing test');
$I->sendGET('run/acceptance/' . md5('acceptance' . 'TheTestThatFails'));
$I->seeResponseContainsJson(array('run' => true, 'passed' => false, 'state' => 'failed'));
<?php

/*
 * This file is part of the Webception package.
 *
 * (c) James Healey <*****@*****.**>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */
$I = new WebGuy($scenario);
$I->wantTo('check AJAX call when executable fails');
$I->sendGET('executable?test=executable_fail');
$I->seeResponseContainsJson(array('ready' => false, 'error' => "The Codeception executable could not be found."));
Пример #5
0
<?php

/*
 * This file is part of the Webception package.
 *
 * (c) James Healey <*****@*****.**>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */
$I = new WebGuy($scenario);
$I->wantTo('run test that does not exist to confirm the response');
$I->sendGET('run/lol/fake-test-id');
$I->seeResponseContainsJson(array('message' => 'The test could not be found.', 'run' => false, 'passed' => false, 'state' => 'error', 'log' => NULL));
<?php

/*
 * This file is part of the Webception package.
 *
 * (c) James Healey <*****@*****.**>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */
$I = new WebGuy($scenario);
$I->wantTo('check AJAX call when executable passes.');
$I->sendGET('executable?test=pass');
$I->seeResponseContainsJson(array('ready' => true));