public function testCreate() { Database::delete('VolunteerApplications', ['uid' => -2]); self::$app = new VolunteerApplication(); self::$app->grantAllPermissions(); $this->assertTrue(self::$app->create(['uid' => -2, 'first_name' => 'Test', 'middle_name' => 'meh', 'last_name' => 'User', 'address' => 'abc st', 'city' => 'Tulsa', 'state' => 'OK', 'zip_code' => '74104', 'phone' => '1234567890', 'alternate_phone' => '1234567899', 'birth_date' => strtotime('21 years ago')])); }
public static function setUpBeforeClass() { Database::delete('Users', ['user_email' => '*****@*****.**']); self::$twitterProfile = new TwitterProfile(); self::$twitterProfile->create(['id' => 100, 'profile_image_url' => 'twitter_profile_picture']); self::$instagramProfile = new InstagramProfile(); self::$instagramProfile->create(['id' => 100, 'profile_picture' => 'instagram_profile_picture']); }
protected function postDeleteHook() { // nuke all volunteers, hours, etc... $nuke = ['Volunteers', 'VolunteerHourTags', 'VolunteerHours', 'VolunteerPlaces']; foreach ($nuke as $tablename) { Database::delete($tablename, ['organization' => $this->id()]); } }
public static function setUpBeforeClass() { Database::delete('Users', ['user_email' => '*****@*****.**']); self::$user = new User(); self::$user->grantAllPermissions(); self::$user->create(['user_email' => '*****@*****.**', 'username' => 'testvolunteer1', 'user_password' => ['testpassword', 'testpassword'], 'ip' => '10.0.0.1', 'about' => 'bio']); Database::delete('Users', ['user_email' => '*****@*****.**']); self::$user2 = new User(); self::$user2->grantAllPermissions(); self::$user2->create(['user_email' => '*****@*****.**', 'username' => 'testvolunteer2', 'user_password' => ['testpassword', 'testpassword'], 'ip' => '10.0.0.1', 'about' => 'bio']); Database::delete('Users', ['user_email' => '*****@*****.**']); Database::delete('Users', ['user_email' => '*****@*****.**']); }
protected function postSetHook() { $user = $this->relation('uid'); // increment user's stats $metrics = $this->metrics(); foreach ($this->_delta as $key => &$value) { $value = $metrics[$key] - $value; } $user->incrementStats($this->_delta); // update tags if ($this->setTags) { // remove existing tags Database::delete('VolunteerHourTags', ['hour' => $this->id()]); $tags = array_unique($this->setTags); foreach ($tags as $tag) { $tagModel = new VolunteerHourTag(); $tagModel->grantAllPermissions(); $tagModel->create(['tag' => $tag, 'hour' => $this->id(), 'organization' => $this->organization]); } $this->setTags = false; } // email user if going from unapproved to approved if ($this->needsApproveEmail) { if (!$this->canSendEmail()) { return; } $org = $this->relation('organization'); $user->sendEmail('volunteer-hours-approved', ['subject' => 'Your volunteer hours were approved on InspireVive', 'orgname' => $org->name, 'place_name' => $this->relation('place')->name, 'day' => date('l, M j, Y', $this->timestamp), 'hours' => $this->hours]); // update last sent time $volunteer = $this->volunteer(); $volunteer->grantAllPermissions(); $volunteer->set('last_email_sent_about_hours', time()); $this->needsApproveEmail = false; } }