/** * Set up tests. */ public function setUp() { parent::setUp(); // Set up the database Artisan::call('migrate:refresh'); Artisan::call('db:seed'); // Run the tests in English App::setLocale('en'); /** * Create class properties to be used in tests */ $this->admin = User::find(1); $this->executive = User::find(2); $this->user = User::find(3); $this->adminRole = Role::find(1); $this->executiveRole = Role::find(2); $this->userRole = Role::find(3); }
/** * Run the database seed. * * @return void */ public function run() { if (DB::connection()->getDriverName() == 'mysql') { DB::statement('SET FOREIGN_KEY_CHECKS=0;'); } if (DB::connection()->getDriverName() == 'mysql') { DB::table(config('access.permission_role_table'))->truncate(); } elseif (DB::connection()->getDriverName() == 'sqlite') { DB::statement('DELETE FROM ' . config('access.permission_role_table')); } else { //For PostgreSQL or anything else DB::statement('TRUNCATE TABLE ' . config('access.permission_role_table') . ' CASCADE'); } /** * Assign view backend and manage user permissions to executive role as example */ Role::find(2)->permissions()->sync([1, 2]); /** * */ if (DB::connection()->getDriverName() == 'mysql') { DB::statement('SET FOREIGN_KEY_CHECKS=1;'); } }
/** * @return mixed */ public function getDefaultUserRole() { if (is_numeric(config('access.users.default_role'))) { return Role::where('id', (int) config('access.users.default_role'))->first(); } return Role::where('name', config('access.users.default_role'))->first(); }
/** * @return mixed */ public function getDefaultUserRole() { return Role::where('name', config('access.users.default_role'))->first(); }