Beispiel #1
0
 public function testClear()
 {
     $this->if($adapter = new atoum\test\adapter())->if($adapter->fopen = false)->and($file = new testedClass(null, $adapter))->and($adapter->resetCalls())->then->exception(function () use($file) {
         $file->clear();
     })->isInstanceOf('mageekguy\\atoum\\exceptions\\runtime')->hasMessage('Unable to open file \'' . $file->getFilename() . '\'')->if($adapter->fopen = $resource = uniqid())->and($adapter->flock = true)->and($adapter->ftruncate = false)->and($adapter->fclose = function () {
     })->and($adapter->resetCalls())->then->exception(function () use($file) {
         $file->clear();
     })->isInstanceOf('mageekguy\\atoum\\exceptions\\runtime')->hasMessage('Unable to truncate file \'' . $file->getFilename() . '\'')->adapter($adapter)->call('fopen')->withArguments($file->getFilename(), 'c')->once()->call('flock')->withArguments($resource, LOCK_EX)->once()->if($adapter->ftruncate = true)->then->object($file->clear())->isIdenticalTo($file)->adapter($adapter)->call('fopen')->withArguments($file->getFilename(), 'c')->once()->call('ftruncate')->withArguments($resource, 0)->after($this->adapter($adapter)->call('flock')->withArguments($resource, LOCK_EX))->twice();
 }
Beispiel #2
0
 public function testGetFilename()
 {
     $this->if($file = new writers\file())->then->string($file->getFilename())->isEqualTo('atoum.log')->if($file->setFilename('anotherName'))->then->string($file->getFilename())->isEqualTo('anotherName');
 }