/** * @test */ public function updates() { $resource = Resource::create(['id' => 'xoo-xoo-xoo']); $res = $this->op->create($resource, ROOT_TESTS . '/data/self-lussing-manatee.jpg'); $this->assertSame($res, $resource); $this->assertNotFalse($this->op->find($res->getId())); $this->assertNotFalse($this->filelib->getStorage()->exists($resource)); $this->op->update($res); $this->ed->dispatch(Events::RESOURCE_BEFORE_UPDATE, Argument::type('Xi\\Filelib\\Event\\ResourceEvent'))->shouldHaveBeenCalled(); $this->ed->dispatch(Events::RESOURCE_AFTER_UPDATE, Argument::type('Xi\\Filelib\\Event\\ResourceEvent'))->shouldHaveBeenCalled(); }
/** * Handles impostor's resource * * @param File $file */ private function handleImpostorResource(File $file) { $oldResource = $file->getResource(); if ($oldResource->isExclusive()) { $retrieved = $this->storage->retrieve($oldResource); $resource = Resource::create(); $resource->setDateCreated(new DateTime()); $resource->setHash($oldResource->getHash()); $resource->setSize($oldResource->getSize()); $resource->setMimetype($oldResource->getMimetype()); $this->resourceRepository->create($resource, $retrieved); $file->setResource($resource); } }