/**
  * @param \CF_Container $container
  * @param \CF_Object $object
  */
 function it_should_lazily_create_container_before_read($connectionFactory, $connection, $container, $object)
 {
     $this->beConstructedWith($connectionFactory, 'my_container', true);
     $connection->get_container(ANY_ARGUMENT)->shouldNotBeCalled();
     $connection->create_container('my_container')->willReturn($container)->shouldBeCalled();
     $object->read()->willReturn('some content');
     $container->get_object('filename')->willReturn($object);
     $this->read('filename')->shouldReturn('some content');
 }
Esempio n. 2
0
 /**
  * @see FileBackend::getFileContents()
  */
 public function getFileContents(array $params)
 {
     static $existsCache = [];
     list($srcCont, $srcRel) = $this->resolveStoragePathReal($params['src']);
     if ($srcRel === null) {
         return false;
         // invalid storage path
     }
     if (isset($existsCache[$params['src']])) {
         return $existsCache[$params['src']];
     }
     if (!$this->fileExists($params)) {
         $existsCache[$params['src']] = null;
         return null;
     }
     $data = false;
     try {
         $sContObj = $this->getContainer($srcCont);
         $obj = new CF_Object($sContObj, $srcRel, false, false);
         // skip HEAD request
         $data = $obj->read($this->headersFromParams($params));
     } catch (NoSuchContainerException $e) {
     } catch (InvalidResponseException $e) {
         $this->logException($e, __METHOD__, $params);
     } catch (Exception $e) {
         // some other exception?
         $this->logException($e, __METHOD__, $params);
     }
     return $data;
 }
Esempio n. 3
0
 /**
  * @see FileBackend::getFileContents()
  * @return bool|null|string
  */
 public function getFileContents(array $params)
 {
     list($srcCont, $srcRel) = $this->resolveStoragePathReal($params['src']);
     if ($srcRel === null) {
         return false;
         // invalid storage path
     }
     if (!$this->fileExists($params)) {
         return null;
     }
     $data = false;
     try {
         $sContObj = $this->getContainer($srcCont);
         $obj = new CF_Object($sContObj, $srcRel, false, false);
         // skip HEAD
         $data = $obj->read($this->headersFromParams($params));
     } catch (NoSuchContainerException $e) {
     } catch (CloudFilesException $e) {
         // some other exception?
         $this->handleException($e, null, __METHOD__, $params);
     }
     return $data;
 }
 /**
  * @param \CF_Container $container
  * @param \CF_Object $fromObject
  * @param \CF_Object $toObject
  */
 function it_should_rename_file($container, $fromObject, $toObject)
 {
     $fromObject->read()->willReturn('some content');
     $toObject->write('some content')->willReturn(true);
     $container->get_object('filename')->willReturn($fromObject);
     $container->get_object('filename1')->willReturn($toObject);
     $this->rename('filename', 'filename1')->shouldReturn(true);
 }