Ejemplo n.º 1
0
 public function testDefault()
 {
     $followers = array(array('id' => '14139010', 'name' => 'Pascal de Vink', 'screen_name' => 'pascaldevink', 'description' => 'Mock description', 'location' => 'Amsterdam, NL', 'url' => '', 'protected' => false, 'followers_count' => 45, 'profile_image_url' => 'http://a1.twimg.com/profile_images/429161922/twtr_normal.png'), array('id' => '14139011', 'name' => 'Jan de Vries', 'screen_name' => 'jandevries', 'description' => 'Mock description', 'location' => 'Lutjebroek, NL', 'url' => '', 'protected' => false, 'followers_count' => 2, 'profile_image_url' => 'http://a1.twimg.com/profile_images/429161922/twtr_normal.png'));
     // Setup mocking
     $mock = Mockery::mock('twitter');
     $mock->shouldReceive('getFollowers')->once()->andReturn($followers)->ordered();
     $mock->shouldReceive('existsFriendship')->with(Mockery::type('string'), Mockery::type('string'))->twice()->andReturn(true, false);
     $mock->shouldReceive('createFriendship')->with(Mockery::type('string'))->once();
     // Call the task and inject the mock
     $harvester = new HarvestFollowers($mock);
     $harvester->execute();
     // Verify the mock
     $mock->mockery_verify();
     // Verify if there are indeed 2 followers
     $t = $this->getTest();
     $criteria = new Criteria(FollowerPeer::TABLE_NAME);
     $this->getTest()->is(2, count(FollowerPeer::doSelect($criteria)), 'Test for created followers');
 }
Ejemplo n.º 2
0
 /**
  * Retrieve multiple objects by pkey.
  *
  * @param      array $pks List of primary keys
  * @param      PropelPDO $con the connection to use
  * @throws     PropelException Any exceptions caught during processing will be
  *		 rethrown wrapped into a PropelException.
  */
 public static function retrieveByPKs($pks, PropelPDO $con = null)
 {
     if ($con === null) {
         $con = Propel::getConnection(FollowerPeer::DATABASE_NAME, Propel::CONNECTION_READ);
     }
     $objs = null;
     if (empty($pks)) {
         $objs = array();
     } else {
         $criteria = new Criteria(FollowerPeer::DATABASE_NAME);
         $criteria->add(FollowerPeer::ID, $pks, Criteria::IN);
         $objs = FollowerPeer::doSelect($criteria, $con);
     }
     return $objs;
 }