예제 #1
0
 /**
  * @param SwiftObject $object
  * @param Container   $destination
  * @param string      $name
  *
  * @throws SwiftException
  *
  * @return SwiftObject
  *
  * @see DriverInterface::copyObject()
  */
 public function copyObject(SwiftObject $object, Container $destination, $name = null)
 {
     if (is_null($name)) {
         $name = $object->getName();
     }
     // detect circular reference
     if ($object->getContainer() === $destination && $object->getName() === $name) {
         throw new SwiftException('Destination is same as source');
     }
     return $this->driver->copyObject($object, $destination, $name);
 }
예제 #2
0
 /**
  * @param self $object
  *
  * @return bool
  */
 public function equals(Object $object)
 {
     return $this->getETag() === $object->getETag();
 }
예제 #3
0
 /**
  * @inheritdoc
  */
 public function copyObject(SwiftObject $object, Container $toContainer, $name)
 {
     $destination = sprintf('/%s/%s', $toContainer->getName(), $name);
     $headers = ['Destination' => $destination];
     $this->logger->info(sprintf('Copying "%s" => "%s"', $object->getPath(), $destination));
     $response = $this->copy($object->getPath(), null, $headers);
     return $this->assertResponse($response, [201 => function () use($toContainer, $name) {
         return $this->getObject($toContainer, $name);
     }]);
 }
 public function testCopyObjectDefaultName()
 {
     $container = new Container('foo');
     $object = new SwiftObject($container, 'baz');
     $destination = new Container('bar');
     $newObject = new SwiftObject($destination, $object->getName());
     $this->driver->expects($this->once())->method('copyObject')->with($object, $destination, $object->getName())->willReturn($newObject);
     $this->assertSame($newObject, $this->store->copyObject($object, $destination));
 }
 public function testDeleteNotFoundObject()
 {
     $container = new Container('foo');
     $object = new SwiftObject($container, 'bar');
     $this->mockClientRequest('delete', $object->getPath(), [], null, new Response(404));
     $this->assertTrue($this->driver->deleteObject($object));
 }