/** * ============ json array =================== * @Given /^the response contains (\[[^]]*\])$/ * * ============ json object ================== * @Given /^the response contains (\{(?>[^\{\}]+|(?1))*\})$/ * * ============ json string ================== * @Given /^the response contains ("[^"]*")$/ * * ============ json int ===================== * @Given /^the response contains ([-+]?[0-9]*\.?[0-9]+)$/ * * ============ json null or boolean ========= * @Given /^the response contains (null|true|false)$/ */ public function theResponseContains($response) { $data = json_encode($this->_data); if (!String::contains($data, $response)) { throw new Exception("Response value does not contain '{$response}' only\n\n" . $this->echoLastResponse()); } }
/** * @access hybrid * @return \stdClass */ public function index() { if (!static::$accessControlFunction && Defaults::$accessControlFunction) { static::$accessControlFunction = Defaults::$accessControlFunction; } $version = $this->restler->getRequestedApiVersion(); $allRoutes = Util::nestedValue(Routes::toArray(), "v{$version}"); $r = $this->_resourceListing(); $map = array(); if (isset($allRoutes['*'])) { $this->_mapResources($allRoutes['*'], $map, $version); unset($allRoutes['*']); } $this->_mapResources($allRoutes, $map, $version); foreach ($map as $path => $description) { if (!String::contains($path, '{')) { //add id $r->apis[] = array('path' => $path . $this->formatString, 'description' => $description); } } if (Defaults::$useUrlBasedVersioning && static::$listHigherVersions) { $nextVersion = $version + 1; if ($nextVersion <= $this->restler->getApiVersion()) { list($status, $data) = $this->_loadResource("/v{$nextVersion}/resources.json"); if ($status == 200) { $r->apis = array_merge($r->apis, $data->apis); $r->apiVersion = $data->apiVersion; } } } return $r; }