public function testSize() { $this->assertNull(HumanHelper::size(null)); $this->assertNull(HumanHelper::size('adasd')); $this->assertNull(HumanHelper::size(-100)); $this->assertEquals('0 B', HumanHelper::size(0)); $this->assertEquals('100 B', HumanHelper::size(100)); $this->assertEquals('0 KB', HumanHelper::size(100, 'KB')); $this->assertEquals('2 KB', HumanHelper::size(2050)); $this->assertEquals('0 MB', HumanHelper::size(2050, 'MB')); $this->assertEquals('10 MB', HumanHelper::size('10685760')); $this->assertEquals('0 GB', HumanHelper::size('10685760', 'GB')); $this->assertEquals('10 GB', HumanHelper::size('10937418240')); }
private function checkParameters() { // Check path. if (!is_dir($this->path)) { throw new InvalidConfigException($this->path . ' is not a directory.'); } if (!is_writable($this->path)) { throw new InvalidConfigException($this->path . ' is not writable.'); } // Check chunksize. $bytes = HumanHelper::maxBytesUpload(); if ($this->chunksize >= $bytes) { throw new InvalidConfigException('Chunksize value must be less than ' . $bytes . 'B. Current value is ' . $this->chunksize . '.'); } }