$traces =
$this->
getScriptTraces();
static::
assertArrayHasKey('store-api-cache-script::response',
$traces);
// assert that the response was cached, and thus the script was not called again
static::
assertCount(1,
$traces['store-api-cache-script::response'
]);
static::
assertArrayHasKey('apiAlias',
$response);
static::
assertArrayHasKey('foo',
$response);
static::
assertEquals('bar',
$response['foo'
]);
static::
assertSame('store_api_cache_script_response',
$response['apiAlias'
]);
// Login to get the `logged-in` invalidation state
$this->
login();
$this->browser->
request('GET', '/store-api/script/cache-script'
);
static::
assertNotFalse($this->browser->
getResponse()->
getContent());
$response = \
json_decode($this->browser->
getResponse()->
getContent(), true, 512, \JSON_THROW_ON_ERROR
);
static::
assertSame(Response::HTTP_OK,
$this->browser->
getResponse()->
getStatusCode(),
$this->browser->
getResponse()->
getContent());
$traces =
$this->
getScriptTraces();
static::
assertArrayHasKey('store-api-cache-script::response',
$traces);
// assert that when the invalidation state is present the response is not cached
static::
assertCount(2,
$traces['store-api-cache-script::response'
]);