/**
* Tests an entity save.
*/
public function testEntitySave(): void
{ \Drupal::
cache()->
set('test_cache_pretransaction_foobar', 'something', Cache::PERMANENT,
['foobar'
]);
\Drupal::
cache()->
set('test_cache_pretransaction_entity_test_list', 'something', Cache::PERMANENT,
['entity_test_list'
]);
$entity = EntityTest::
create(['name' =>
$this->
randomString()]);
Database::
startLog('testEntitySave'
);
$entity->
save();
$executed_statements =
[];
foreach (Database::
getLog('testEntitySave'
) as $log) { $executed_statements[] =
$log['query'
];
} $last_statement_index =
max(array_keys($executed_statements));
$cachetag_statements =
array_keys($this->
getStatementsForTable($executed_statements, 'cachetags'
));
$this->
assertSame($last_statement_index -
count($cachetag_statements) + 1,
min($cachetag_statements), 'All of the last queries in the transaction are for the "cachetags" table.'
);
// Verify that a nested entity save occurred.