Пример #1
0
 function testCreationReturnsFalseWhenItFailsToCreateFile()
 {
     $filename = $this->createDirPath($this->tempdir, 'foo.txt');
     File::create($filename, 'boo!');
     $this->setExpectedException('Asar\\FileHelper\\Exception\\FileAlreadyExists');
     $this->helper->create($filename, "Foo!");
 }
Пример #2
0
 function create($filename, $contents)
 {
     try {
         return File::create($filename)->write($contents)->save();
     } catch (\Asar\File\Exception\FileAlreadyExists $e) {
         throw new FileAlreadyExists("The file '{$filename}' already exists.");
     }
 }
Пример #3
0
 function testSettingContentUsingArrayAsArgument()
 {
     $content = array('AA', 'BB', 'CC', 'DD');
     $testFileName = $this->getTempFileName('temp/XXXXXXtest.txt');
     mkdir($this->getTempFileName('temp'));
     $file = File::create($testFileName)->write($content)->save();
     $this->assertEquals("AA\nBB\nCC\nDD", $file->getContent());
 }