If you need to CRUD files during a test you may use the FileSandboxTrait.
Put the following in your test's setUp method:
public function setUp() {
parent::setUp();
$this->newFileSandbox();
}
Use $this->sb as the scratch directory path.
$this->newFileSandbox() at any time to empty it's contents.