public function testUrl() { $user = new User(); $user->username = '******'; $this->assertEquals(TestBootstrap::app('base_url') . 'users/test', $user->url()); }
private function createVolunteerApp() { $uid = TestBootstrap::app('user')->id(); if ((new VolunteerApplication($uid))->exists()) { return; } self::$app = new VolunteerApplication(); self::$app->grantAllPermissions(); self::$app->create(['uid' => $uid, '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')]); }
/** * @depends testCreate */ public function testDelete() { $user = TestBootstrap::app('user'); self::$hour->grantAllPermissions(); $this->assertTrue(self::$hour->delete()); $user->load(); $this->assertEquals(6, $user->volunteer_hours); }
public function testGetBogusReport() { $this->assertFalse(Report::getReport(TestBootstrap::app(), self::$org, 'blah', time() - 3600, time() + 3600)); }
/** * @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); }
/** * @depends testCreate */ public function testTopVolunteers() { $start = mktime(0, 0, 0, 5, 11, 2013); $end = mktime(0, 0, 0, 5, 15, 2013); $topVolunteers = self::$org->topVolunteers(5, $start, $end); $this->assertCount(2, $topVolunteers); $this->assertEquals(TestBootstrap::app('user')->id(), $topVolunteers[0]['user']->id()); $this->assertEquals(15, $topVolunteers[0]['hours']); $this->assertEquals(-3, $topVolunteers[1]['user']->id()); $this->assertEquals(5, $topVolunteers[1]['hours']); }