Exemplo n.º 1
0
 /**
  * @param FileLibrary $filelib
  */
 public function attachTo(FileLibrary $filelib)
 {
     $this->fileRepository = $filelib->getFileRepository();
     $this->profiles = $filelib->getProfileManager();
     $this->storage = $filelib->getStorage();
     $this->eventDispatcher = $filelib->getEventDispatcher();
 }
Exemplo n.º 2
0
 /**
  * @test
  */
 public function initializes()
 {
     $filelib = new FileLibrary(new MemoryStorageAdapter(), new MemoryBackendAdapter());
     $asynchrony = new Asynchrony($filelib);
     $this->assertInstanceOf('Xi\\Filelib\\Asynchrony\\FileRepository', $filelib->getFileRepository());
     $this->assertInstanceOf('Xi\\Filelib\\Asynchrony\\ExecutionStrategy\\SynchronousExecutionStrategy', $asynchrony->getStrategy(ExecutionStrategies::STRATEGY_SYNC));
 }
Exemplo n.º 3
0
 /**
  * @test
  * @group luszo
  */
 public function deletesExclusiveResource()
 {
     $upload = ROOT_TESTS . '/data/self-lussing-manatee.jpg';
     $file = $this->filelib->getFileRepository()->upload($upload, null, 'tussi');
     $this->filelib->getFileRepository()->delete($file);
     $this->ed->dispatch(Events::FILE_AFTER_DELETE, Argument::type('Xi\\Filelib\\Event\\FileEvent'))->shouldHaveBeenCalled();
     $this->assertFalse($this->filelib->getStorage()->exists($file->getResource()));
 }
Exemplo n.º 4
0
 /**
  * @test
  */
 public function findByFilenameDelegates()
 {
     $param1 = Folder::create();
     $param2 = 'xooxox';
     $expected = 'tus';
     $this->repo->findByFilename($param1, $param2)->shouldBeCalled()->willReturn($expected);
     $ret = $this->filelib->getFileRepository()->findByFilename($param1, $param2);
     $this->assertEquals($expected, $ret);
 }
Exemplo n.º 5
0
 /**
  * @param FileLibrary $filelib
  */
 public function attachTo(FileLibrary $filelib)
 {
     $this->fileRepository = $filelib->getFileRepository();
     $this->profiles = $filelib->getProfileManager();
     $this->eventDispatcher = $filelib->getEventDispatcher();
     $this->eventDispatcher->addSubscriber($this);
     $this->adapter->attachTo($filelib);
     $this->linker->attachTo($filelib);
 }
 /**
  * @test
  */
 public function serializesAndUnserializesAfterUpload()
 {
     $filelib = new FileLibrary(new MemoryStorageAdapter(), new MemoryBackendAdapter());
     $file = $filelib->getFileRepository()->upload(ROOT_TESTS . '/data/self-lussing-manatee.jpg');
     $serializer = new AsynchronyDataSerializer();
     $serializer->attachTo($filelib);
     $unserializedCallback = new SerializedCallback([$filelib->getFileRepository(), 'afterUpload'], [$file]);
     $this->assertTrue($serializer->willSerialize($unserializedCallback));
     $serializedCallback = $serializer->serialize($unserializedCallback);
     $deserializedCallback = $serializer->unserialize($serializedCallback);
     $this->assertEquals($unserializedCallback, $deserializedCallback);
 }
 /**
  * @param FileLibrary $filelib
  */
 public function attachTo(FileLibrary $filelib)
 {
     $this->fileRepository = $filelib->getFileRepository();
 }
Exemplo n.º 8
0
 /**
  * @test
  */
 public function fileRepositoryCanBeSet()
 {
     $repo = $this->prophesize('Xi\\Filelib\\File\\FileRepositoryInterface')->reveal();
     $filelib = new FileLibrary($this->getMockedStorageAdapter(), $this->getMockedBackendAdapter());
     $filelib->setFileRepository($repo);
     $this->assertSame($repo, $filelib->getFileRepository());
 }
Exemplo n.º 9
0
 public function __construct(FileLibrary $filelib)
 {
     $this->filelib = $filelib;
     $filelib->setFileRepository(new FileRepository($filelib->getFileRepository(), $this));
     $this->addStrategy(new SynchronousExecutionStrategy());
 }