示例#1
0
 /**
  * Updates a file
  *
  * @param  File         $file
  * @return FileRepository
  */
 public function update(File $file)
 {
     $event = new FileEvent($file);
     $this->eventDispatcher->dispatch(Events::FILE_BEFORE_UPDATE, $event);
     $this->resourceRepository->update($file->getResource());
     $this->backend->updateFile($file);
     $event = new FileEvent($file);
     $this->eventDispatcher->dispatch(Events::FILE_AFTER_UPDATE, $event);
     return $file;
 }
 /**
  * @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();
 }