/** * @test */ public function storeDelegates() { $resource = Resource::create(); $path = '/tenhunen/lipaisee.lus'; $this->adapter->expects($this->once())->method('store')->with($resource, $path)->will($this->returnValue('lus')); $this->ed->expects($this->once())->method('dispatch')->with(Events::BEFORE_STORE, $this->isInstanceOf('Xi\\Filelib\\Event\\StorageEvent')); $this->assertEquals('lus', $this->storage->store($resource, $path)); }
/** * Creates a resource * * @param Resource $resource * @param string $path */ public function create(Resource $resource, $path) { $event = new ResourceEvent($resource); $this->eventDispatcher->dispatch(Events::RESOURCE_BEFORE_CREATE, $event); $resource->setUuid(Uuid::uuid4()->toString()); $this->backend->createResource($resource); // @todo: this has to be correctly robustified. try { $this->storage->store($resource, $path); } catch (\Exception $e) { $this->backend->deleteResource($resource); throw $e; } $event = new ResourceEvent($resource); $this->eventDispatcher->dispatch(Events::RESOURCE_AFTER_CREATE, $event); return $resource; }