public function testGetObjectUrl() { $container = new Container('foo'); $container->setPublic(); $url = 'http://swift.example.org/container/object'; $object = new SwiftObject($container, 'bar'); $this->driver->expects($this->once())->method('getObjectUrl')->with($object)->willReturn($url); $this->assertEquals($url, $this->store->getObjectUrl($object)); }
public function testFactoryMethodWithHeaders() { $container = Container::create('foo', ['X-Container-Meta-Read' => '.r:*', 'X-Container-Object-Count' => '10', 'X-Container-Bytes-Used' => '1024']); $this->assertTrue($container->isPublic()); $this->assertCount(10, $container); $this->assertSame(10, $container->getObjectCount()); $this->assertSame(1024, $container->getBytesUsed()); }
/** * Create a container. * * @param string $name * @param bool $private * * @throws SwiftException * * @return Container * * @see DriverInterface::createContainer() */ public function createContainer($name, $private = true) { if (false === isset($this->containers[$name])) { $container = new Container($name); $private ? $container->setPrivate() : $container->setPublic(); if (!$this->driver->createContainer($container)) { throw new SwiftException(sprintf('Could not create container %s', $name)); } $this->containers[$name] = $container; } return $this->containers[$name]; }
/** * @return string */ public function getPath() { return sprintf('%s/%s', $this->container->getName(), $this->getName()); }
/** * @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 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')); }