public function testImmutableOption() { $expectedLang = 'fr'; $this->twitter->setOptions(new Twitter\SearchOptions(array('language' => $expectedLang))); $options = $this->twitter->getOptions(); $options->setLanguage('en'); $actualOptions = $this->twitter->getOptions(); $this->assertEquals($expectedLang, $actualOptions->getLanguage()); }
/** * @see Command * * @throws \InvalidArgumentException When namespace doesn't end with Bundle * @throws \RuntimeException When bundle can't be executed */ protected function execute(InputInterface $input, OutputInterface $output) { $em = $this->container->get('doctrine.orm.default_entity_manager'); $search = new Search(); $results = $search->search('#linktuesday', array('lang' => 'en')); foreach ($results->results as $result) { $uri = ''; $parts = explode(' ', $result->text); foreach ($parts as $part) { if (substr($part, 0, 7) == 'http://') { $uri = $part; } } if (!empty($uri)) { $link = new Link(); $link->setUri($uri); $existing = $em->getRepository('IngewikkeldLinkTuesdayBundle:Link')->getByFullUri($link->getFullUri()); if ($existing) { $link = $existing; } if ($link->getId() < 1) { $em->persist($link); } $tweetDate = new \DateTime($result->created_at); $existingTweet = $em->getRepository('IngewikkeldLinkTuesdayBundle:Tweet')->findOneBy(array('date' => $tweetDate->format('Y-m-d G:i:s'), 'user' => $result->from_user, 'content' => $result->text)); if (!$existingTweet) { $tweet = new Tweet(); $tweet->setContent($result->text); $tweet->setLink($link); $tweet->setDate(new \DateTime($result->created_at)); $tweet->setProfileImage($result->profile_image_url); $tweet->setUser($result->from_user); $tweet->setUri('test'); $em->persist($tweet); } $em->flush(); } } }
public function testAtomSearchShowUserReturnsObject() { $this->twitter->setResponseType('atom'); $response = $this->twitter->execute('zend', array('show_user' => 'true')); $this->assertInstanceOf('Zend\\Feed\\Reader\\Feed\\Atom', $response); }