public function testCreate() { self::$org = new Organization(); self::$org->grantAllPermissions(); $this->assertTrue(self::$org->create(['name' => 'Test Organization', 'email' => '*****@*****.**', 'username' => 'test' . time()])); self::$org2 = new Organization(); self::$org2->grantAllPermissions(); $this->assertTrue(self::$org2->create(['name' => 'Test Org', 'email' => '*****@*****.**', 'username' => 'test2' . time()])); /* Create some volunteers */ $user = TestBootstrap::app('user'); $uid = $user->id(); $user->enableSU(); $volunteer = new Volunteer(); $this->assertTrue($volunteer->create(['uid' => $uid, 'organization' => self::$org->id(), 'role' => Volunteer::ROLE_ADMIN])); $user->disableSU(); $volunteer = new Volunteer(); $this->assertTrue($volunteer->create(['uid' => -2, 'organization' => self::$org->id(), 'role' => Volunteer::ROLE_AWAITING_APPROVAL])); $volunteer = new Volunteer(); $this->assertTrue($volunteer->create(['uid' => -3, 'organization' => self::$org->id(), 'role' => Volunteer::ROLE_VOLUNTEER])); $volunteer = new Volunteer(); $this->assertTrue($volunteer->create(['organization' => self::$org->id(), 'uid' => -4, 'timestamp' => time(), 'approved' => true])); /* Create some hours */ for ($i = 0; $i < 5; ++$i) { $hour = new VolunteerHour(); $this->assertTrue($hour->create(['organization' => self::$org->id(), 'uid' => -3, 'hours' => 1, 'timestamp' => mktime(0, 0, 0, 5, 11, 2013), 'approved' => true])); } $hour = new VolunteerHour(); $this->assertTrue($hour->create(['organization' => self::$org->id(), 'uid' => -4, 'hours' => 10, 'timestamp' => mktime(0, 0, 0, 5, 12, 2013), 'approved' => true])); $hour = new VolunteerHour(); $this->assertTrue($hour->create(['organization' => self::$org->id(), 'uid' => $uid, 'timestamp' => mktime(10, 10, 10, 5, 10, 2013), 'hours' => 11, 'approved' => true])); // unapproved hours $hour = new VolunteerHour(); $this->assertTrue($hour->create(['organization' => self::$org->id(), 'uid' => $uid, 'timestamp' => mktime(0, 0, 0, 5, 11, 2013), 'hours' => 10, 'tags' => ['yo', 'hello', 'test'], 'approved' => false])); // approved hours $hour = new VolunteerHour(); $this->assertTrue($hour->create(['organization' => self::$org->id(), 'uid' => $uid, 'timestamp' => mktime(0, 0, 0, 5, 11, 2013), 'hours' => 5, 'approved' => true, 'tags' => ['test']])); $hour = new VolunteerHour(); $this->assertTrue($hour->create(['organization' => self::$org->id(), 'uid' => $uid, 'timestamp' => mktime(0, 0, 0, 5, 11, 2013), 'hours' => 10, 'approved' => true, 'tags' => ['test', 'test2']])); // official, outside hours $user->enableSU(); $hour = new VolunteerHour(); $this->assertTrue($hour->create(['organization' => self::$org2->id(), 'uid' => $uid, 'timestamp' => mktime(0, 0, 0, 5, 15, 2013), 'hours' => 12, 'approved' => true])); $user->disableSU(); self::$ogUserId = $uid; }