Permalink
Browse files

better test coverage, updated stuff forms

  • Loading branch information...
1 parent 2175eb6 commit a481eb1c089351510e5928a38c5237f38d3c0b46 @bshaffer committed May 7, 2010
@@ -17,6 +17,7 @@ public function configure()
$this->useFields(array(
'title',
'quantity',
+ 'neighborhood',
'address_1',
'address_2',
'city',
@@ -17,6 +17,7 @@ public function configure()
$this->useFields(array(
'title',
'quantity',
+ 'neighborhood',
'address_1',
'address_2',
'city',
@@ -21,6 +21,12 @@
</div>
</div>
+ <?php echo $form['neighborhood']->renderLabel() ?>
+ <div>
+ <?php echo $form['neighborhood']->renderError() ?>
+ <?php echo $form['neighborhood']->render() ?>
+ </div>
+
<?php echo $form['address_1']->renderLabel() ?>
<div>
<?php echo $form['address_1']->renderError() ?>
@@ -29,6 +29,12 @@
</li>
<li>
+ <?php echo $form['neighborhood']->renderLabel() ?>
+ <div>
+ <?php echo $form['neighborhood']->renderError() ?>
+ <?php echo $form['neighborhood']->render() ?>
+ </div>
+
<?php echo $form['address_1']->renderLabel() ?>
<div>
<?php echo $form['address_1']->renderError() ?>
@@ -22,6 +22,8 @@ Resource:
is_fulfilled:
type: boolean
default: false
+ neighborhood:
+ type: string(100)
address_1:
type: string(255)
address_2:
@@ -32,6 +34,8 @@ Resource:
type: string(100)
zip:
type: string(100)
+ county:
+ type: string(100)
phone_1:
type: string(100)
phone_2:
@@ -62,6 +62,10 @@ StuffResource:
User: sgu_bshaffer
title: Car
transaction_type: need
+ address_1: 5157 Whitaker Dr
+ city: Nashville
+ state: TN
+ zip: 37211
stuff_resource2:
User: sgu_bshaffer
title: Broom
@@ -27,6 +27,24 @@ public function configure()
'show_info' => 'Show my info as well as a contact form',
'web_form' => 'Show a contact form, but hide my information',
)));
+
+ $neighborhoods = array(
+ 'Outside Nashville' => 'Outside Nashville',
+ 'areas' => ' -- Nashville Areas --',
+ 'North Nashville' => 'North Nashville',
+ 'South Nashville' => 'South Nashville',
+ 'East Nashville' => 'East Nashville',
+ 'West Nashville' => 'West Nashville',
+ 'neighborhoods' => ' -- Nashville Neighborhoods --',
+ 'Antioch' => 'Antioch',
+ 'Brentwood' => 'Brentwood',
+ );
+
+ $this->widgetSchema['neighborhood'] = new sfWidgetFormChoice(array('choices' => $neighborhoods));
+
+ // Unset invalid options
+ unset($neighborhoods['areas'], $neighborhoods['neighborhoods']);
+ $this->validatorSchema['neighborhood'] = new sfValidatorChoice(array('choices' => array_keys($neighborhoods)));
}
/**
@@ -18,6 +18,7 @@ public function configure()
$this->useFields(array(
'title',
'quantity',
+ 'neighborhood',
'address_1',
'address_2',
'city',
@@ -28,4 +28,50 @@ public function getOppositeType()
{
return $this['transaction_type'] == 'need' ? 'have' : 'need';
}
+
+ /*
+ Code to capture the county for the item
+ */
+ public function retrieveGeocodesFromUrl($url)
+ {
+ $locationInfo = array('latitude' => null, 'longitude' => null, 'county' => null);
+
+ $json = json_decode(file_get_contents($url));
+
+ if (!isset($json->Placemark[0]))
+ {
+ return $locationInfo;
+ }
+
+ $info = $json->Placemark[0];
+
+ if (isset($info->Point->coordinates))
+ {
+ $coordinates = $info->Point->coordinates;
+ $locationInfo['latitude'] = $coordinates[1];
+ $locationInfo['longitude'] = $coordinates[0];
+ }
+
+ if (isset($info->AddressDetails->Country->AdministrativeArea->SubAdministrativeArea->SubAdministrativeAreaName))
+ {
+ $county = $info->AddressDetails->Country->AdministrativeArea->SubAdministrativeArea->SubAdministrativeAreaName;
+ $locationInfo['county'] = $county;
+ }
+
+ return $locationInfo;
+ }
+
+ public function refreshGeocodes($url = null)
+ {
+ if (!$url)
+ {
+ $url = $this->buildUrlFromQuery($this->buildGeoQuery());
+ $url = substr($url, 0, strrpos($url, 'csv')) . 'json';
+ }
+
+ $geocodes = $this->retrieveGeocodesFromUrl($url);
+ $this['latitude'] = $geocodes['latitude'];
+ $this['longitude'] = $geocodes['longitude'];
+ $this['county'] = $geocodes['county'];
+ }
}
@@ -4,6 +4,10 @@
$browser = new dnTestFunctional(new sfBrowser());
+$neededStuff = csFactory::create('StuffResource', array('transaction_type' => 'need', 'title' => csFactory::generate('Stuff Resource '), 'owner_id' => csFactory::selectRandomId('sfGuardUser')));
+
+$neededStuff->save();
+
$browser
->get('/')
@@ -22,19 +26,25 @@
->with('response')->begin()
->matches('!/pump/i')
->end()
-
+
->call('/stuff/list', 'post', $parameters = array('q' => 'picnic', 'type' => 'need'))
->isModuleAction('resource', 'stuffList')
+
+ ->with('response')->begin()
+ ->matches('/picnic/i')
+ ->end()
+
+ ->call('/stuff/list', 'post', $parameters = array('q' => $neededStuff['title'], 'type' => 'need'))
+ ->isModuleAction('resource', 'stuffList')
->with('response')->begin()
- ->matches('/picnic table/i')
+ ->matches(sprintf('/%s/i', $neededStuff['title']))
->end()
- ->click('Picnic Table')
+ ->get(sprintf('/have/stuff/%s', $neededStuff['id']))
->isModuleAction('stuff', 'show')
->with('response')->begin()
- ->matches(sprintf('/%s/', 'Picnic Table'))
- // ->checkForm('contactResrouceOwnerForm')
+ ->matches(sprintf('/%s/', $neededStuff['title']))
->end()
;
@@ -4,6 +4,12 @@
$browser = new dnTestFunctional(new sfBrowser());
+$neededTime = csFactory::create('TimeResource', array('transaction_type' => 'need', 'title' => csFactory::generate('Time Resource '), 'owner_id' => csFactory::selectRandomId('sfGuardUser')));
+
+$neededTime['resource_date'] = date('Y-m-d');
+
+$neededTime->save();
+
$browser
->get('/')
@@ -13,18 +19,17 @@
->click('Time')
->isModuleAction('time', 'have')
- ->call('/time/list', 'post', $parameters = array('start'=>'2010-05-04 00:00:00'))
+ ->call('/time/list', 'post', $parameters = array('start' => date('Y-m-d')))
->isModuleAction('resource', 'timeList')
-
+
->with('response')->begin()
- ->matches('/<li><a href/')
+ ->matches(sprintf('/%s/i', $neededTime['title']))
->end()
- ->click('5/5 from 6:00 to 8:00')
+ ->get(sprintf('/have/time/%s', $neededTime['id']))
->isModuleAction('time', 'show')
->with('response')->begin()
- // ->matches('/5157 Whitaker Dr/')
- // ->checkForm('contactResrouceOwnerForm')
+ ->matches(sprintf('/%s/', $neededTime['title']))
->end()
;
@@ -14,7 +14,6 @@
->isModuleAction('resource', 'place')
->with('response')->begin()
- ->matches('/Tennessean/')
- // ->checkForm('contactResrouceOwnerForm')
+ ->matches('/FEMA/')
->end()
;
@@ -4,6 +4,10 @@
$browser = new dnTestFunctional(new sfBrowser());
+$availableStuff = csFactory::create('StuffResource', array('transaction_type' => 'have', 'title' => csFactory::generate('Stuff Resource '), 'owner_id' => csFactory::selectRandomId('sfGuardUser')));
+
+$availableStuff->save();
+
// Delete all existing data
$browser
->get('/')
@@ -30,18 +34,32 @@
->matches('/sump/i')
->end()
- ->click('Sump Pump')
+ ->call('/stuff/list', 'post', $parameters = array('q' => $availableStuff['title'], 'type' => 'have'))
+ ->isModuleAction('resource', 'stuffList')
+
+ ->with('response')->begin()
+ ->matches(sprintf('/%s/i', $availableStuff['title']))
+ ->end()
+
+ ->get(sprintf('/need/stuff/%s', $availableStuff['id']))
->isModuleAction('stuff', 'show')
->with('response')->begin()
- ->matches('/Stuff Details: Sump Pump/')
- ->checkForm('ContactResourceOwnerForm')
+ ->matches(sprintf('/%s/', $availableStuff['title']))
->end()
;
$resource = Doctrine_Core::getTable('stuffResource')->findOneByTitle('Sump Pump');
$browser
+ ->get(sprintf('/need/stuff/%s', $resource['id']))
+ ->isModuleAction('stuff', 'show')
+
+ ->with('response')->begin()
+ ->matches(sprintf('/%s/', $resource['title']))
+ ->checkForm('ContactResourceOwnerForm')
+ ->end()
+
->call('/stuff/'.$resource->id.'/message', 'post', array('contact'=>array(
'email'=>'lacyrhoades@gmail.com',
'name'=>'Lacy',

0 comments on commit a481eb1

Please sign in to comment.