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'
]);
// invalidate the custom cache tag
$cacheInvalidator =
$this->
getContainer()->
get(CacheInvalidator::
class);
$cacheInvalidator->
invalidate(['my-custom-tag'
], true
);
$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 cache tag was invalidated the script is executed again
static::
assertCount(2,
$traces['store-api-cache-script::response'
]);