/** * @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); }]); }
/** * @return string */ public function getPath() { return sprintf('%s/%s', $this->container->getName(), $this->getName()); }
public function testCopyObject() { $container = new Container('foo'); $object = new SwiftObject($container, 'baz'); $destination = new Container('bar'); $newName = 'qux'; $this->mockClientRequest('copy', $container->getName(), [], null, new Response(201)); $this->mockClientRequest('head', $container->getName(), [], null, new Response(204, ['foo' => 'bar', 'X-Object-Meta-Bar' => 'baz'])); $newObject = $this->driver->copyObject($object, $destination, $newName); $this->assertInstanceOf(SwiftObject::class, $newObject); $this->assertSame($destination, $newObject->getContainer()); $this->assertSame($newName, $newObject->getName()); $this->assertSame(['bar'], $newObject->getHeaders()['foo']); $this->assertSame('baz', $newObject->getMetadata()->get('bar')); }