public function testCountCheckinsByPlaceType() { $pub1 = date(date('Y-m-d H:i:s', strtotime("now -2 week"))); $pub2 = date(date('Y-m-d H:i:s', strtotime("now +1 hour"))); $hour1 = date('H', strtotime("now")); $hour2 = date('H', strtotime("now +1 hour")); // Add some foursquare checkins (done here due to time dependenacy of test) $checkin_builder[] = FixtureBuilder::build('posts', array('post_id' => '1000', 'author_user_id' => '31', 'author_username' => 'user1', 'author_fullname' => 'User 1', 'network' => 'foursquare', 'post_text' => 'I just checked in', 'source' => '', 'pub_date' => $pub1, 'location' => 'England', 'old_retweet_count_cache' => 0, 'in_rt_of_user_id' => null, 'place' => 'The Park', 'place_id' => '12345b', 'reply_count_cache' => 0, 'retweet_count_cache' => 0, 'network' => 'foursquare', 'in_reply_to_user_id' => null, 'in_reply_to_post_id' => null, 'geo' => '52.477192843264,-1.484333726346')); $checkin_builder[] = FixtureBuilder::build('posts', array('post_id' => '999', 'author_user_id' => '31', 'author_username' => 'user1', 'author_fullname' => 'User 1', 'network' => 'foursquare', 'post_text' => 'I just checked in again', 'source' => '', 'pub_date' => $pub2, 'location' => 'England', 'old_retweet_count_cache' => 0, 'in_rt_of_user_id' => null, 'place' => 'The Garage', 'place_id' => '12345c', 'reply_count_cache' => 0, 'retweet_count_cache' => 0, 'network' => 'foursquare', 'in_reply_to_user_id' => null, 'in_reply_to_post_id' => null, 'geo' => '52.477192843264,-1.484333726346')); // Add place information $place1['place_id'] = '12345b'; $place1['place_type'] = "Park"; $place1['name'] = "A Park"; $place1['full_name'] = "The Greatest Park"; $place1['country_code'] = "UK"; $place1['country'] = "United Kingdom"; $place1['icon'] = "http://www.iconlocation.com"; $place1['network'] = "foursquare"; $place1['longlat'] = "GeometryFromText( 'Point(51.514 -0.1167)' )"; $place1['bounding_box'] = "PolygonFromText( 'Polygon(-0.213503 51.512805,-0.105303 51.512805," . "-0.105303 51.572068,-0.213503 51.572068, -0.213503 51.512805)')"; $place1['map_image'] = "http://www.mapimage.com"; // Insert the place $place_builder1 = FixtureBuilder::build('places', $place1); // Set all possible fields $place2['place_id'] = '12345c'; $place2['place_type'] = "Garage"; $place2['network'] = "foursquare"; $place2['name'] = "A Garage"; $place2['full_name'] = "The Greatest Garage"; $place2['country_code'] = "UK"; $place2['country'] = "United Kingdom"; $place2['icon'] = "http://www.iconlocation.com"; $place2['longlat'] = "GeometryFromText( 'Point(51.514 -0.1167)' )"; $place2['bounding_box'] = "PolygonFromText( 'Polygon((-0.213503 51.512805,-0.105303 51.512805," . "-0.105303 51.572068,-0.213503 51.572068, -0.213503 51.512805)))')"; // Insert the place $place_builder2 = FixtureBuilder::build('places', $place2); // Query the database for the number of checkins per type of place in the last week $post_dao = new PostMySQLDAO(); $res = $post_dao->countCheckinsToPlaceTypes('31', 'foursquare'); $valid_json = '{"rows":[{"c":[{"v":"Garage","f":"Garage"},{"v":1}]},{"c":[{"v":"Park","f":"Park"},{"v":1}]}],'; $valid_json .= '"cols":[{"type":"string","label":"Place Type"},{"type":"number","label":"Number of Checkins to'; $valid_json .= ' this place type"}]}'; $this->assertEqual($res, $valid_json); }