/**
* Asserts describe response has all properties and deprecated paths response are identical current response
*
* @param string $basePath
* @param array $listPaths
* @param bool $environment optional if variable is true replace envId for test environment
*/
public function assertApiListResponse($basePath, $listPaths, $environment = false)
{
$this->assertNotEmpty($listPaths);
foreach ($listPaths as $path => $property) {
$pathInfo = $basePath . $path;
if ($environment) {
$pathInfo = str_replace('{envId}', static::$testEnvId, $pathInfo);
}
$resp = $this->request($pathInfo, Request::METHOD_GET);
$envelope = $resp->getBody();
$this->assertDescribeResponseNotEmpty($resp);
$pathInfoDeprecated = preg_replace("#/(v\\d.*?)/(user|admin|account)/#", '/$2/$1/', $pathInfo);
$resDepPath = $this->request($pathInfoDeprecated, Request::METHOD_GET);
$this->assertDescribeResponseNotEmpty($resDepPath);
$envelopeDep = $resDepPath->getBody();
$this->assertObjectHasAttribute('warnings', $envelopeDep);
$this->assertNotEmpty($envelopeDep->warnings);
$code = [];
$message = [];
/* @var $warning ApiMessage */
foreach ($envelopeDep->warnings as $warning) {
$code[] = $warning->code;
$message[] = $warning->message;
}
$this->assertContains(Response::getCodeMessage(301), $code);
$this->assertContains(sprintf('Location %s', $pathInfo), $message);
$this->assertEquals($envelope->data, $envelopeDep->data);
}
}