function test_location_crud() { // create $location = $this->get_nv_test_location(); $id = GeoMashupDB::set_location($location, $do_lookups = false); $this->assertFalse(is_wp_error($id)); $this->assertTrue(is_numeric($id)); $this->assertTrue($id > 0); // read $out = GeoMashupDB::get_location($id); $this->assertEquals($location->lat, $out->lat); $this->assertEquals($location->lng, $out->lng); // read cache $lcache = wp_cache_get($id, 'geo_mashup_locations'); $this->assertInstanceOf('stdClass', $lcache); $this->assertEquals($id, $lcache->id); // update $out->locality_name = rand_str(); $update_id = GeoMashupDB::set_location($out, $do_lookups = false); $this->assertEquals($update_id, $id); $out2 = GeoMashupDB::get_location($id); $this->assertEquals($id, $out2->id); $this->assertEquals($out->locality_name, $out2->locality_name); // delete GeoMashupDB::delete_location($id); $out = GeoMashupDB::get_location($id); $this->assertNull($out); }