private function uploadFile(Bucket $bucket) { print "Uploading hello world file to bucket: " . $bucket->getName() . PHP_EOL; $contents = "Hello world"; $uploadFilename = "hello_world_" . time() . ".txt"; $filepath = __DIR__ . '/upload_file.txt'; file_put_contents($filepath, $contents); $uploadUrlResponse = $this->m_b2->getUploadUrl($bucket->getId()); $b2File = $this->m_b2->uploadFile($uploadFilename, $filepath, $uploadUrlResponse); return $b2File; }
<?php require_once 'autoload.php'; $bucket = new Bucket(5, 2, 'Test'); echo 'Testing constructor', PHP_EOL; assert($bucket->getMaxVolume() === 5); assert($bucket->getCurrentVolume() === 2); assert($bucket->getName() === 'Test'); echo 'END Testing', PHP_EOL; echo 'Testing Bucket::getRemainingSpace', PHP_EOL; assert($bucket->getRemainingSpace() === 3); echo 'End testing Bucket::getRemainingSpace', PHP_EOL; echo 'Testing Bucket::addLiquid', PHP_EOL; $bucket->addLiquid(2); assert($bucket->getCurrentVolume() === 4); $bucket->addLiquid(2); assert($bucket->getCurrentVolume() <= $bucket->getMaxVolume()); echo 'End testing Bucket::addLiquid', PHP_EOL;