public function testDestruct() { $tmpfile = tempnam(sys_get_temp_dir(), 'composer_unit_test_'); $req = new CopyRequest('http://example.com/', $tmpfile, false, $this->iop->reveal(), $this->configp->reveal()); $this->assertFileExists($tmpfile); // if $req->success === true ... $req->makeSuccess(); unset($req); // then tmpfile remain $this->assertFileExists($tmpfile); unlink($tmpfile); $req = new CopyRequest('http://example.com/', $tmpfile, false, $this->iop->reveal(), $this->configp->reveal()); // if $req->success === false (default) ... // $req->makeSuccess(); unset($req); // then cleaned tmpfile automatically $this->assertFileNotExists($tmpfile); }