How do I examine an entity's update SQL statement in order to write a unit test? I have a core patch (https://www.drupal.org/node/2342699) which ensures that SQL updates do not include the primary key in the field list. I need to write a unit test for this issue and EntityApiTest.php looks like the ideal place for this. This test class has a section

$entities = array_values($storage-&gt;loadByProperties(['name' =&gt; 'test']));
$entities[0]-&gt;name-&gt;value = 'test3';
$entities[0]-&gt;save();


The way I see it, I will need to examine the entity schema to find the database column name of the 'id' entity key, and then examine the SQL update object to ensure that the entity key is not in the field list. Any advice on how to do either of these steps?
Just write a test that attempts to update a primary key, and assert that it fails to do so.

There's no need to test the SQL generation mechanism of the storage class.