/**
  * @covers Aws\Glacier\Model\MultipartUpload\UploadPartContext::isEmpty
  * @covers Aws\Glacier\Model\MultipartUpload\UploadPartContext::isFull
  */
 public function testIsEmptyAndFullAsExpected()
 {
     $context = new UploadPartContext(10);
     $this->assertTrue($context->isEmpty());
     $this->assertFalse($context->isFull());
     $this->assertEquals(0, $this->readAttribute($context, 'size'));
     $context->addData('abcde');
     $this->assertFalse($context->isEmpty());
     $this->assertFalse($context->isFull());
     $this->assertEquals(5, $this->readAttribute($context, 'size'));
     $context->addData('fghij');
     $this->assertFalse($context->isEmpty());
     $this->assertTrue($context->isFull());
     $this->assertEquals(10, $this->readAttribute($context, 'size'));
 }
 /**
  * Performs the work of reading the body stream, creating tree hashes, and creating UploadPartContext objects
  *
  * @param EntityBodyInterface $body The body to create parts from
  */
 protected function generateUploadParts(EntityBodyInterface $body)
 {
     // Rewind the body stream
     $body->seek(0);
     // Initialize variables for tracking data for upload
     $uploadContext = new UploadPartContext($this->partSize, $body->ftell());
     // Read the data from the streamed body in 1MB chunks
     $data = $this->readPart($body);
     while (strlen($data) > 0) {
         // Add data to the hashes and size calculations
         $uploadContext->addData($data);
         // If the upload part is complete, generate an upload object and reset the currently tracked upload data
         if ($uploadContext->isFull()) {
             $this->updateTotals($uploadContext->generatePart());
             $uploadContext = new UploadPartContext($this->partSize, $body->ftell());
         }
         $data = $this->readPart($body);
     }
     // Handle any leftover data
     if (!$uploadContext->isEmpty()) {
         $this->updateTotals($uploadContext->generatePart());
     }
     // Rewind the body stream
     $body->seek(0);
 }