Skip to content

Commit

Permalink
PostDAO tests should use new POINT and POLYGON FixtureBuilder support
Browse files Browse the repository at this point in the history
  • Loading branch information
ginatrapani committed Aug 31, 2012
1 parent 220b007 commit 14e83cb
Showing 1 changed file with 68 additions and 98 deletions.
166 changes: 68 additions & 98 deletions tests/TestOfPostMySQLDAO.php
Expand Up @@ -2894,35 +2894,22 @@ public function testGetOnThisDayFlashbackPostsNoFromDate(){
// Add a link for this post // Add a link for this post
$link_builder3 = FixtureBuilder::build('links', array('post_key'=>$post_key, 'url'=>'http://bit.ly/blahb')); $link_builder3 = FixtureBuilder::build('links', array('post_key'=>$post_key, 'url'=>'http://bit.ly/blahb'));


// Add the place information for future foursquare checkin test (We do it this way due to the fixture builder // Add the place information
// not being able to handle the MySQL point type $place['place_id'] = '12345a';
// Set all possible fields
$place['id'] = '12345a';
$place['place_type'] = "Park"; $place['place_type'] = "Park";
$place['name'] = "A Park"; $place['name'] = "A Park";
$place['full_name'] = "The Greatest Park"; $place['full_name'] = "The Greatest Park";
$place['country_code'] = "UK"; $place['country_code'] = "UK";
$place['country'] = "United Kingdom"; $place['country'] = "United Kingdom";
$place['icon'] = "http://www.iconlocation.com"; $place['icon'] = "http://www.iconlocation.com";
$place['lat_lng'] = 'POINT(51.514 -0.1167)'; $place['network'] = "foursquare";
$place['bounding_box'] = 'POLYGON((-0.213503 51.512805,-0.105303 51.512805,-0.105303 51.572068,'. $place['longlat'] = "GeometryFromText( 'Point(51.514 -0.1167)' )";
'-0.213503 51.572068, -0.213503 51.512805)))'; $place['bounding_box'] = "PolygonFromText( 'Polygon(-0.213503 51.512805,-0.105303 51.512805,".
$place['bounding_box'] = array ( "-0.105303 51.572068,-0.213503 51.572068, -0.213503 51.512805)')";
'type' => 'Polygon',
'coordinates' => array (
array(
array(-97.73818308, 30.29930703),
array(-97.710741, 30.29930703),
array(-97.710741, 30.31480602),
array(-97.73818308, 30.31480602),
)
)
);
$place['map_image'] = "http://www.mapimage.com"; $place['map_image'] = "http://www.mapimage.com";


// Insert the place // Insert the place
$place_dao = new PlaceMySQLDAO(); $place_builder = FixtureBuilder::build('places', $place);
$place_dao->insertGenericPlace($place, 'foursquare');


// Query the database for last year's post // Query the database for last year's post
$post_dao = new PostMySQLDAO(); $post_dao = new PostMySQLDAO();
Expand Down Expand Up @@ -3019,35 +3006,22 @@ public function testGetOnThisDayFlashbackPostsWithFromDate(){
// Add a link for this post // Add a link for this post
$link_builder3 = FixtureBuilder::build('links', array('post_key'=>$post_key, 'url'=>'http://bit.ly/blahb')); $link_builder3 = FixtureBuilder::build('links', array('post_key'=>$post_key, 'url'=>'http://bit.ly/blahb'));


// Add the place information for future foursquare checkin test (We do it this way due to the fixture builder // Add the place information
// not being able to handle the MySQL point type $place['place_id'] = '12345a';
// Set all possible fields
$place['id'] = '12345a';
$place['place_type'] = "Park"; $place['place_type'] = "Park";
$place['name'] = "A Park"; $place['name'] = "A Park";
$place['full_name'] = "The Greatest Park"; $place['full_name'] = "The Greatest Park";
$place['country_code'] = "UK"; $place['country_code'] = "UK";
$place['country'] = "United Kingdom"; $place['country'] = "United Kingdom";
$place['icon'] = "http://www.iconlocation.com"; $place['icon'] = "http://www.iconlocation.com";
$place['lat_lng'] = 'POINT(51.514 -0.1167)'; $place['network'] = "foursquare";
$place['bounding_box'] = 'POLYGON((-0.213503 51.512805,-0.105303 51.512805,-0.105303 51.572068,'. $place['longlat'] = "GeometryFromText( 'Point(51.514 -0.1167)' )";
'-0.213503 51.572068, -0.213503 51.512805)))'; $place['bounding_box'] = "PolygonFromText( 'Polygon(-0.213503 51.512805,-0.105303 51.512805,".
$place['bounding_box'] = array ( "-0.105303 51.572068,-0.213503 51.572068, -0.213503 51.512805)')";
'type' => 'Polygon',
'coordinates' => array (
array(
array(-97.73818308, 30.29930703),
array(-97.710741, 30.29930703),
array(-97.710741, 30.31480602),
array(-97.73818308, 30.31480602),
)
)
);
$place['map_image'] = "http://www.mapimage.com"; $place['map_image'] = "http://www.mapimage.com";


// Insert the place // Insert the place
$place_dao = new PlaceMySQLDAO(); $place_builder = FixtureBuilder::build('places', $place);
$place_dao->insertGenericPlace($place, 'foursquare');


// Query the database for last year's post // Query the database for last year's post
$post_dao = new PostMySQLDAO(); $post_dao = new PostMySQLDAO();
Expand Down Expand Up @@ -3099,24 +3073,22 @@ public function testGetOnThisDayFlashbackPostsWithFromDate(){
} }


public function testGetAllCheckins(){ public function testGetAllCheckins(){
/* Add the place information for the foursquare checkins (We do it this way due to the fixture builder not // Add place information for foursquare checkins
being able to handle the MySQL point type */ $place['place_id'] = '12345a';
$place_dao = new PlaceMySQLDAO(); $place['place_type'] = "Park";
// Set all possible fields $place['name'] = "A Park";
$places['id'] = '12345a'; $place['full_name'] = "The Greatest Park";
$places['place_type'] = "Park"; $place['country_code'] = "UK";
$places['name'] = "A Park"; $place['country'] = "United Kingdom";
$places['full_name'] = "The Greatest Park"; $place['icon'] = "http://www.iconlocation.com";
$places['country_code'] = "UK"; $place['network'] = "foursquare";
$places['country'] = "United Kingdom"; $place['longlat'] = "GeometryFromText( 'Point(51.514 -0.1167)' )";
$places['icon'] = "http://www.iconlocation.com"; $place['bounding_box'] = "PolygonFromText( 'Polygon(-0.213503 51.512805,-0.105303 51.512805,".
$places['lat_lng'] = 'POINT(51.514 -0.1167)'; "-0.105303 51.572068,-0.213503 51.572068, -0.213503 51.512805)')";
$places['bounding_box'] = 'POLYGON((-0.213503 51.512805,-0.105303 51.512805,-0.105303 51.572068,'. $place['map_image'] = "http://www.mapimage.com";
'-0.213503 51.572068, -0.213503 51.512805)))';
$places['map_image'] = "http://www.mapimage.com";


// Insert the place // Insert the place
$place_dao->insertGenericPlace($places, 'foursquare'); $place_builder = FixtureBuilder::build('places', $place);


// Add A link for this checkin // Add A link for this checkin
$checkin_builder[] = FixtureBuilder::build('links', array('post_key'=>'20020', 'url'=>'http://bit.ly/blah')); $checkin_builder[] = FixtureBuilder::build('links', array('post_key'=>'20020', 'url'=>'http://bit.ly/blah'));
Expand Down Expand Up @@ -3172,23 +3144,22 @@ public function testGetAllCheckins(){
} }


public function testCountCheckinsToPlaceTypes(){ public function testCountCheckinsToPlaceTypes(){
/* Add the place information for these foursquare checkins (We do it this way due to the fixture builder not // Add place information for checkins
being able to handle the MySQL point type */ $place['place_id'] = '12345a';
$place_dao = new PlaceMySQLDAO(); $place['place_type'] = "Park";
// Set all possible fields $place['name'] = "A Park";
$places['id'] = '12345a'; $place['full_name'] = "The Greatest Park";
$places['place_type'] = "Park"; $place['country_code'] = "UK";
$places['name'] = "A Park"; $place['country'] = "United Kingdom";
$places['full_name'] = "The Greatest Park"; $place['icon'] = "http://www.iconlocation.com";
$places['country_code'] = "UK"; $place['network'] = "foursquare";
$places['country'] = "United Kingdom"; $place['longlat'] = "GeometryFromText( 'Point(51.514 -0.1167)' )";
$places['icon'] = "http://www.iconlocation.com"; $place['bounding_box'] = "PolygonFromText( 'Polygon(-0.213503 51.512805,-0.105303 51.512805,".
$places['lat_lng'] = 'POINT(51.514 -0.1167)'; "-0.105303 51.572068,-0.213503 51.572068, -0.213503 51.512805)')";
$places['bounding_box'] = 'POLYGON((-0.213503 51.512805,-0.105303 51.512805,-0.105303 51.572068,'. $place['map_image'] = "http://www.mapimage.com";
'-0.213503 51.572068, -0.213503 51.512805)))';


// Insert the place // Insert the place
$place_dao->insertGenericPlace($places, 'foursquare'); $place_builder = FixtureBuilder::build('places', $place);


// Query the database for the number of checkins per type of place // Query the database for the number of checkins per type of place
$post_dao = new PostMySQLDAO(); $post_dao = new PostMySQLDAO();
Expand All @@ -3201,7 +3172,6 @@ public function testCountCheckinsToPlaceTypes(){
} }


public function testCountCheckinsToPlaceTypesLastWeek(){ public function testCountCheckinsToPlaceTypesLastWeek(){

// Build the pub_date string which needs to be a date within the last week // Build the pub_date string which needs to be a date within the last week
$pub1 = date(date( 'Y-m-d H:i:s' , strtotime("now"))); $pub1 = date(date( 'Y-m-d H:i:s' , strtotime("now")));
$pub2 = date(date( 'Y-m-d H:i:s' , strtotime("now +1 hour"))); $pub2 = date(date( 'Y-m-d H:i:s' , strtotime("now +1 hour")));
Expand All @@ -3226,38 +3196,38 @@ public function testCountCheckinsToPlaceTypesLastWeek(){
'in_reply_to_user_id' =>null, 'in_reply_to_post_id' => null, 'in_reply_to_user_id' =>null, 'in_reply_to_post_id' => null,
'geo'=>'52.477192843264,-1.484333726346')); 'geo'=>'52.477192843264,-1.484333726346'));


/* Add the place information for these foursquare checkins (We do it this way due to the fixture builder not // Add place information
being able to handle the MySQL point type */ $place1['place_id'] = '12345b';
$place_dao = new PlaceMySQLDAO(); $place1['place_type'] = "Park";
// Set all possible fields $place1['name'] = "A Park";
$places['id'] = '12345b'; $place1['full_name'] = "The Greatest Park";
$places['place_type'] = "Park"; $place1['country_code'] = "UK";
$places['name'] = "A Park"; $place1['country'] = "United Kingdom";
$places['full_name'] = "The Greatest Park"; $place1['icon'] = "http://www.iconlocation.com";
$places['country_code'] = "UK"; $place1['network'] = "foursquare";
$places['country'] = "United Kingdom"; $place1['longlat'] = "GeometryFromText( 'Point(51.514 -0.1167)' )";
$places['icon'] = "http://www.iconlocation.com"; $place1['bounding_box'] = "PolygonFromText( 'Polygon(-0.213503 51.512805,-0.105303 51.512805,".
$places['lat_lng'] = 'POINT(51.514 -0.1167)'; "-0.105303 51.572068,-0.213503 51.572068, -0.213503 51.512805)')";
$places['bounding_box'] = 'POLYGON((-0.213503 51.512805,-0.105303 51.512805,-0.105303 51.572068,'. $place1['map_image'] = "http://www.mapimage.com";
'-0.213503 51.572068, -0.213503 51.512805)))';


// Insert the place // Insert the place
$place_dao->insertGenericPlace($places, 'foursquare'); $place_builder1 = FixtureBuilder::build('places', $place1);


// Set all possible fields // Set all possible fields
$places['id'] = '12345c'; $place2['place_id'] = '12345c';
$places['place_type'] = "Garage"; $place2['place_type'] = "Garage";
$places['name'] = "A Garage"; $place2['network'] = "foursquare";
$places['full_name'] = "The Greatest Garage"; $place2['name'] = "A Garage";
$places['country_code'] = "UK"; $place2['full_name'] = "The Greatest Garage";
$places['country'] = "United Kingdom"; $place2['country_code'] = "UK";
$places['icon'] = "http://www.iconlocation.com"; $place2['country'] = "United Kingdom";
$places['lat_lng'] = 'POINT(51.514 -0.1167)'; $place2['icon'] = "http://www.iconlocation.com";
$places['bounding_box'] = 'POLYGON((-0.213503 51.512805,-0.105303 51.512805,-0.105303 51.572068,'. $place2['longlat'] = "GeometryFromText( 'Point(51.514 -0.1167)' )";
'-0.213503 51.572068, -0.213503 51.512805)))'; $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 // Insert the place
$place_dao->insertGenericPlace($places, 'foursquare'); $place_builder2 = FixtureBuilder::build('places', $place2);


// Query the database for the number of checkins per type of place in the last week // Query the database for the number of checkins per type of place in the last week
$post_dao = new PostMySQLDAO(); $post_dao = new PostMySQLDAO();
Expand Down

0 comments on commit 14e83cb

Please sign in to comment.