public function putContents($data) { if (@file_put_contents($this->createParentDirectory(), $data) === false) { throw new exception('Unable to put data \'' . $data . '\' in file \'' . $this . '\''); } return $this; }
public function testPutContents() { $this->if($path = new testedClass('/a/b', '/'))->and($adapter = new atoum\test\adapter())->and($adapter->mkdir = true)->and($adapter->file_put_contents = true)->and($path->setAdapter($adapter))->then->object($path->putContents($data = uniqid()))->isEqualTo($path)->adapter($adapter)->call('mkdir')->withArguments('/a', true)->once()->call('file_put_contents')->withArguments((string) $path, $data)->once()->if($adapter->file_put_contents = false)->then->exception(function () use($path, &$data) { $path->putContents($data = uniqid()); })->isInstanceOf('mageekguy\\atoum\\fs\\path\\exception')->hasMessage('Unable to put data \'' . $data . '\' in file \'' . $path . '\''); }