예제 #1
0
파일: User.php 프로젝트: toin0u/yo-cli
 /**
  * {@inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $yo = $this->getHelper('yo')->getYo();
     $username = $input->getArgument('username');
     $parameters = $input->getArgument('parameters');
     $bag = null;
     if ($parameters && filter_var($parameters[0], FILTER_VALIDATE_URL)) {
         $bag = new Link($parameters[0]);
     } elseif (2 === count($parameters)) {
         $bag = new Location($parameters[0], $parameters[1]);
     }
     $output->write(sprintf('Yo <comment>`%s`</comment>', strtoupper($username)));
     if ($bag instanceof Bag) {
         $output->write(sprintf(' ~ <info>`%s`</info>', $bag->getValue()));
     }
     try {
         $yo->user($username, $bag);
     } catch (\Exception $e) {
         $output->writeln(sprintf('<error>%s</error>', $e->getMessage()));
     }
 }
예제 #2
0
파일: YoSpec.php 프로젝트: toin0u/yo
 /**
  * @param Ivory\HttpAdapter\HttpAdapterInterface      $adapter
  * @param Ivory\HttpAdapter\Message\ResponseInterface $response
  * @param Psr\Http\Message\StreamableInterface        $stream
  */
 function it_sends_a_yo_to_a_given_username_with_a_location($adapter, $response, $stream)
 {
     $location = new Location(55.699953, 12.552736);
     $stream->getContents()->willReturn('{"success":true}');
     $response->getBody()->willReturn($stream);
     $adapter->send(sprintf('%s/yo/', Yo::ENDPOINT), InternalRequestInterface::METHOD_POST, array(), array('api_token' => self::API_KEY, 'username' => 'FOOBAR', $location->getKey() => $location->getValue()))->willReturn($response);
     $this->user('foobar', $location)->shouldReturn(true);
 }