Ejemplo n.º 1
0
 /**
  * @depends testCreate
  */
 public function testCreateNonUnique()
 {
     $errorStack = TestBootstrap::app('errors');
     $errorStack->clear();
     $place = new VolunteerPlace();
     $this->assertFalse($place->create(['organization' => self::$org->id(), 'name' => 'Internal', 'address' => '83 West Miller Street, Orlando, FL 32806', 'place_type' => VolunteerPlace::INTERNAL]));
     $errors = $errorStack->errors('VolunteerPlace.create');
     $expected = [['error' => 'place_name_taken', 'message' => 'A volunteer place named Internal already exists. Please use the existing place or choose a different name.', 'context' => 'VolunteerPlace.create', 'params' => ['place_name' => 'Internal']]];
     $this->assertEquals($expected, $errors);
 }
Ejemplo n.º 2
0
 public function placesAdd($req, $res)
 {
     $org = $this->getOrgForAdmin($req, $res);
     if (!is_object($org)) {
         return;
     }
     $input = $req->request();
     $input['organization'] = $org->id();
     $input['verify_approved'] = true;
     $place = new VolunteerPlace();
     $place->create($input);
     if ($place) {
         $res->redirect($org->manageUrl() . '/places?success=t');
     } else {
         return $this->addPlaceForm($req, $res);
     }
 }
Ejemplo n.º 3
0
 public function addVolunteerPlace($req, $res)
 {
     $org = $this->getOrg($req, $res);
     if (!is_object($org)) {
         return $org;
     }
     $currentUser = $this->app['user'];
     // make sure the user is logged in
     if (!$currentUser->isLoggedIn()) {
         setcookie('redirect', $org->url() . '/places/add', time() + 3600, '/');
         return $res->redirect('/login');
     }
     // enforce all fields of input
     VolunteerPlace::$properties['address']['required'] = true;
     VolunteerPlace::$properties['address']['validate'] = 'string:5';
     VolunteerPlace::$properties['verify_name']['required'] = true;
     VolunteerPlace::$properties['verify_name']['validate'] = 'string:5';
     VolunteerPlace::$properties['verify_email']['required'] = true;
     VolunteerPlace::$properties['verify_email']['validate'] = 'email';
     $input = $req->request();
     $input['organization'] = $org->id();
     $input['place_type'] = VolunteerPlace::EXTERNAL;
     $input['verify_approved'] = false;
     $place = new VolunteerPlace();
     $success = $place->create($input);
     if ($success) {
         $res->redirect($org->url() . '/hours/report/2?place=' . $place->id());
     } else {
         return $this->addVolunteerPlaceForm($req, $res);
     }
 }