/** * Create a test user. * * @return GovTribe\LaravelKinvey\Database\Eloquent\User */ public static function createTestUser() { Kinvey::setAuthMode('app'); $user = new User(); $user->setRawAttributes(array('email' => '*****@*****.**', 'first_name' => 'Test', 'last_name' => 'Guy', 'password' => str_random(8), 'original' => 'baz')); $user->save(); Kinvey::setAuthMode('admin'); return $user; }
/** * The "booting" method of the model. * * @return void */ public static function boot() { parent::boot(); User::creating(function ($user) { if (!$user->email) { throw new \Exception('User model must contain a not-null email attribute'); } if (!$user->username) { $user->username = $user->email; } }); }
/** * Tear down the test environment. * * @return array */ public function tearDown() { Kinvey::setAuthMode('admin'); $user = User::withTrashed()->where('_id', $this->testUser->_id)->first()->forceDelete(); Kinvey::setAuthMode('app'); }