setQuota() public static method

sets quota to given amount of bytes
Since: 1.1.0
public static setQuota ( integer $bytes )
$bytes integer
コード例 #1
0
 public function testFilePutContentsWriteError()
 {
     // Force error by simulating full disk
     vfsStream::setQuota(3);
     $filename = $this->_root->url() . '/test.txt';
     try {
         FileObject::filePutContents($filename, 'content');
         $this->fail('Expected exception has not been thrown');
     } catch (\RuntimeException $e) {
         $this->assertEquals("Error writing to file {$filename}", $e->getMessage());
         // A truncated file should remain on disk
         $this->assertFileExists($filename);
         $this->assertEquals('con', file_get_contents($filename));
     }
 }
コード例 #2
0
 public function testSaveRemovesFileOnError()
 {
     $root = vfsStream::setup('root');
     $filename = $root->url() . '/test.xml';
     $document = new DomDocument();
     vfsStream::setQuota(1);
     // File is opened, written but truncated
     try {
         $document->save($filename);
         $this->fail('Expected exception has not been thrown');
     } catch (\RuntimeException $e) {
         $this->assertEquals("Error writing to file {$filename}", $e->getMessage());
         $this->assertFileNotExists($filename);
     }
 }