<?php $I = new ApiGuy($scenario); $I->wantTo('get Stations by Name'); $I->haveHttpHeader('Content-Type', 'application/json'); include 'constant.php'; $I->sendGET('/station/search/' . $station_name); $st = $I->grabDataFromResponseByJsonPath('$..data[1].station_id'); $stat = serialize($st); $station = substr("{$stat}", 14, -3); $I->seeResponseCodeIs(200);
<?php $I = new ApiGuy($scenario); $I->wantTo('GET Favorite Stations'); $I->haveHttpHeader('Content-Type', 'application/json'); require_once 'loginCept.php'; $I->amBearerAuthenticated($token); $I->sendGET('/favorite/station'); $st1 = $I->grabDataFromResponseByJsonPath('$..data[0].station_id'); #[] выбор массива $stat1 = serialize($st1); $favorite_station = substr("{$stat1}", 14, -3); $st2 = $I->grabDataFromResponseByJsonPath('$..data[2].name'); #[] выбор массива $stat2 = serialize($st2); $search_station = substr($stat2, 14, strpos($stat2, ' ')); $I->seeResponseCodeIs(200);
<?php $I = new ApiGuy($scenario); $I->wantTo('GET current Track'); $I->haveHttpHeader('Content-Type', 'application/json'); include 'getRandomStationCept.php'; $I->sendGET('/stream/track?stationId=' . $station_id); $c_tr = $I->grabDataFromResponseByJsonPath('$..data.currentTrack'); $cur_tr = serialize($c_tr); $current_track = substr("{$cur_tr}", 15, -3); $track = str_replace(" ", "%20", $current_track); $song_url = str_replace("-", "+", $track); $I->seeResponseCodeIs(200);
<?php $I = new ApiGuy($scenario); $I->wantTo('Get random Station'); $I->sendGET('/station/random/'); $sl = $I->grabDataFromResponseByJsonPath('$..data[0].slug'); $s = serialize($sl[0]); $slug = substr("{$s}", 6, -2); $st_id = $I->grabDataFromResponseByJsonPath('$..data[0].id'); $stat_id = serialize($st_id[0]); $station_id = substr("{$stat_id}", 5, -2); $I->seeResponseCodeIs(200);
<?php $I = new ApiGuy($scenario); $I->wantTo('GET Favorite Tracks'); $I->haveHttpHeader('Content-Type', 'application/json'); include 'loginCept.php'; $I->amBearerAuthenticated($token); $I->sendGET('/favorite/track'); $f_tr = $I->grabDataFromResponseByJsonPath('$.data[0].id'); $fav_tr = serialize($f_tr); $favorite_track = substr("{$fav_tr}", 14, -3); $s_tr = $I->grabDataFromResponseByJsonPath('$.data[2].track_name'); $ser_tr = serialize($s_tr); $search_track = substr("{$ser_tr}", 15, -3); $I->seeResponseCodeIs(200);
<?php $I = new ApiGuy($scenario); $I->wantTo('Логин'); $I->haveHttpHeader('Content-Type', 'application/json'); include 'constant.php'; $I->sendPOST('/auth/login', array('email' => $email, 'password' => $pass)); $tok = $I->grabDataFromResponseByJsonPath('$..data[0].token'); $t = serialize($tok[0]); $token = substr("{$t}", 7, -2); $I->seeResponseCodeIs(200); $I->seeResponseIsJson();