public function test__destruct() { $this->if($adapter = new atoum\test\adapter())->and($adapter->fopen = $handle = uniqid())->and($adapter->fwrite = function () { })->and($adapter->fclose = function () { })->and($adapter->is_writable = function () { return true; })->and($file = new writers\file(null, $adapter))->and($file->write('something'))->then->when(function () use($file) { $file->__destruct(); })->adapter($adapter)->call('fclose')->withArguments($handle)->once(); }
public function test__destruct() { $this->if($adapter = new atoum\test\adapter())->and($adapter->fopen = $resource = uniqid())->and($adapter->flock = true)->and($adapter->ftruncate = true)->and($adapter->fwrite = function ($resource, $data) { return strlen($data); })->and($adapter->fflush = function () { })->and($adapter->fclose = function () { })->and($file = new testedClass(null, $adapter))->when(function () use($file) { $file->__destruct(); })->then->adapter($adapter)->call('fclose')->never()->if($file = new testedClass(null, $adapter))->and($file->write('something'))->when(function () use($file) { $file->__destruct(); })->then->adapter($adapter)->call('fclose')->withArguments($resource)->once(); }