again a write isn't always necessary though - as you can see here https://github.com/NightJar/ssrigging-slug/blob/master/tests/SlugTest.php#L69-L70 (edited)

Attachments:
tests/SlugTest.php:80-81
tests/SlugTest.php:80-81

This class tests an extension in various ways @webbower - you could look there :) The key with testing the extensions is that calling onBeforeWrite directly is good to unit test... unless that method is also set up to affect the model it's a DataExtension for... because in that case it expects to have access to a model (or an owner of some form), so it must be called indirectly.

Ah, and $extra_dataobjects is how to add in the TestOnly classes

(1) 🙂 (1)

I'm not 100% on the last one, but the first two yeah. Only need one.

Anyway, thanks for the additional info about writing tests for SS

My goal for the test in question is to test the onBeforeWrite() logic of a DataExtension so I don’t really need to write to the DB to make sure the test works

https://github.com/silverstripe/silverstripe-framework/blob/4/src/Dev/SapphireTest.php#L72-L79 (edited)

Attachments:
src/Dev/SapphireTest.php:72-79