/** * @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); }
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)); }