Ejemplo n.º 1
0
Archivo: YoSpec.php Proyecto: toin0u/yo
 /**
  * @param Symfony\Component\EventDispatcher\EventDispatcherInterface $eventDispatcher
  * @param Ivory\HttpAdapter\ConfigurationInterface                   $configuration
  * @param Ivory\HttpAdapter\HttpAdapterInterface                     $adapter
  */
 function let($eventDispatcher, $configuration, $adapter)
 {
     $configuration->setTimeout(Yo::TIMEOUT)->shouldBeCalled();
     $configuration->setUserAgent(Yo::USER_AGENT)->shouldBeCalled();
     $configuration->setEncodingType(ConfigurationInterface::ENCODING_TYPE_URLENCODED)->shouldBeCalled();
     $configuration->getEventDispatcher()->willReturn($eventDispatcher);
     $adapter->getConfiguration()->willReturn($configuration);
     $adapter->setConfiguration($configuration)->shouldBeCalled();
     $this->beConstructedWith($adapter, self::API_KEY);
 }
Ejemplo n.º 2
0
 /**
  * Prepares the raw body.
  *
  * @param string       $name   The name.
  * @param array|string $data   The data.
  * @param boolean      $isFile TRUE if the data is a file path else FALSE.
  *
  * @return string The formatted raw body.
  */
 private function prepareRawBody($name, $data, $isFile = false)
 {
     if (is_array($data)) {
         $body = '';
         foreach ($data as $subName => $subData) {
             $body .= $this->prepareRawBody($this->prepareName($name, $subName), $subData, $isFile);
         }
         return $body;
     }
     $body = '--' . $this->configuration->getBoundary() . "\r\n" . 'Content-Disposition: form-data; name="' . $name . '"';
     if ($isFile) {
         $body .= '; filename="' . basename($data) . '"';
         $data = file_get_contents($data);
     }
     return $body . "\r\n\r\n" . $data . "\r\n";
 }