/**
  * Run the migrations.
  *
  * @return void
  */
 public function up()
 {
     $user = User::create(['username' => 'admin', 'email' => '*****@*****.**', 'password' => 'admin']);
     // add admin role
     $adminRole = Role::where('name', 'admin')->first();
     $user->attachRole($adminRole);
 }
Exemplo n.º 2
0
 /**
  * @test
  */
 public function it_allow_to_verificaiton_after_registration()
 {
     // remove all users
     User::truncate();
     $this->assertNull(User::first());
     // create verified user
     $formUser = factory(User::class, 'form')->make(['verified' => 1, 'password' => bcrypt('passwordOne')]);
     $formUser->save();
     $this->assertTrue(Auth::guest(), 'User is logged in');
     // send reset link
     MailThief::hijack();
     $this->visit('/password/reset')->type($formUser->email, 'email')->press(trans('user::user.reset_password'))->see('alert-success');
     $password_resets = DB::table('password_resets')->where('email', $formUser->email)->first();
     $this->assertNotNull($password_resets);
     // check mail
     $this->assertTrue(MailThief::hasMessageFor($formUser->email));
     $this->assertEquals('Reset Password', MailThief::lastMessage()->subject);
     $emailContent = MailThief::lastMessage()->getBody();
     $this->assertTrue(strpos($emailContent, $password_resets->token) !== false);
     // click link
     $this->visit('/password/reset/' . $password_resets->token)->see(trans('user::user.reset_password'))->type($formUser->email, 'email')->type('passwordTwo', 'password')->type('passwordTwo', 'password_confirmation')->press(trans('user::user.reset_password'))->see('alert-success');
     $this->assertFalse(Auth::guest(), 'User is NOT logged in');
     // check new password
     $passwordCorrect = app('hash')->check('passwordTwo', User::first()->password);
     $this->assertTrue($passwordCorrect, 'Password not equals with bcrypt');
 }
Exemplo n.º 3
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     // Roles
     $admin = new Role();
     $admin->name = 'admin';
     $admin->display_name = 'Admin';
     $admin->description = 'Administration users';
     $admin->save();
     $user = new Role();
     $user->name = 'user';
     $user->display_name = 'User';
     $user->description = 'Registered users';
     $user->save();
     // Permissions
     $permission_user = new Permission();
     $permission_user->name = 'user-administration';
     $permission_user->display_name = 'User: Administration';
     $permission_user->description = 'CRUD users';
     $permission_user->save();
     $permission_video = new Permission();
     $permission_video->name = 'video-administration';
     $permission_video->display_name = 'Video: Administration';
     $permission_video->description = 'CRUD video';
     $permission_video->save();
     $admin->attachPermissions([$permission_user, $permission_video]);
     // User
     $admin_user = User::create(['name' => 'admin', 'email' => '*****@*****.**', 'password' => 'admin']);
     $admin_user->attachRole($admin);
 }
Exemplo n.º 4
0
 /**
  * @test
  */
 public function it_allow_to_verificaiton_after_registration()
 {
     MailThief::hijack();
     // remove all users
     User::truncate();
     $this->assertNull(User::first());
     // register a user
     Honeypot::disable();
     $formUser = $this->registerUser();
     $this->assertTrue(Auth::guest(), 'User is logged in');
     // check database
     $user = User::first();
     $this->assertEquals('0', $user->verified);
     $this->assertNotEmpty($user->email_token);
     // check mail
     $this->assertTrue(MailThief::hasMessageFor($user->email));
     $this->assertEquals('Verification - My Application', MailThief::lastMessage()->subject);
     $emailContent = MailThief::lastMessage()->getBody();
     $this->assertTrue(strpos($emailContent, $user->email_token) !== false);
     // verify
     $this->visit('/register/verify/' . $user->email_token)->see('alert-success');
     // check db
     $this->assertEquals('1', User::first()->verified);
     $this->assertEquals(null, User::first()->email_token);
     // login
     $this->visit('/login')->type($formUser->email, 'email')->type($formUser->password, 'password')->press(trans('user::user.login'))->see('alert-success');
     $this->assertFalse(Auth::guest(), 'User is NOT logged in');
 }
Exemplo n.º 5
0
 /**
  * @test
  */
 public function it_allows_choice_no_category()
 {
     $this->actingAs(User::first());
     // create a page with a category
     $this->visit(route('backend.page.create'))->type('Hallo', 'title')->type('hallo', 'slug')->select('', 'category_id')->type('Content', 'body')->press('Save')->see('alert-success');
     $page = Page::whereSlug('hallo')->first();
     $this->assertNotNull($page);
     $this->assertEquals($page->category_id, '', 'Category id saved in page');
 }
Exemplo n.º 6
0
 /**
  * @test
  */
 public function it_not_allows_update_page_to_a_frontpage()
 {
     // log in
     $adminUser = User::first();
     $this->actingAs($adminUser);
     // create a page without slug
     $this->visit('/backend/page/create')->type('WildWest', 'title')->type('wild', 'slug')->type('Soo cool', 'body')->press(trans('crud::crud.save'))->see('alert-success');
     // try to update this page without a slug
     $this->visit('/backend/page/2/edit')->type('Wildeast', 'title')->type('', 'slug')->type('Soo cool', 'body')->press(trans('crud::crud.save'))->see('alert-success');
     $page = Page::whereTitle('Wildeast')->firstOrFail();
     $this->assertEquals('wildeast', $page->slug);
 }
Exemplo n.º 7
0
 /**
  * @test
  */
 public function it_allows_change_menu()
 {
     // create menus
     $firstMenu = factory(Menu::class)->create();
     $secondMenu = factory(Menu::class)->create();
     // login
     $adminUser = User::first();
     $this->actingAs($adminUser);
     // create a block
     $this->visit('/backend/block/create')->type('Navigation', 'name')->select($firstMenu->id, 'menu_id')->press(trans('crud::crud.save'))->see('alert-success');
     $block = Block::first();
     $this->assertEquals($firstMenu->id, $block->menu_id);
     // update a block
     $this->visit('/backend/block/1/edit')->select($secondMenu->id, 'menu_id')->press(trans('crud::crud.save'))->see('alert-success');
     $block = Block::first();
     $this->assertEquals($secondMenu->id, $block->menu_id);
 }
Exemplo n.º 8
0
 /**
  * @test
  */
 public function it_allows_destroy_entry()
 {
     $adminUser = User::first();
     $this->actingAs($adminUser);
     $this->it_allows_create_entry();
     // get index url
     /** @var CrudContract $controller */
     $controller = $this->getControllerClass();
     $urlBuilder = new UrlBuilder($controller, $this->getUrlParameters());
     /** @var Model $model */
     $model = $controller->getModelClass();
     // get last item
     $emptyModel = new $model();
     $columnId = $emptyModel->getKeyName();
     $lastEntry = $model::orderBy($columnId, 'desc')->first();
     $url = $urlBuilder->getUrlDestroy($lastEntry->getKey());
     // check
     $this->delete($url, ['_token' => csrf_token()])->see('Redirecting');
 }
Exemplo n.º 9
0
 /**
  * @test
  */
 public function it_allow_see_email_password_reset()
 {
     $adminUser = User::first();
     $this->actingAs($adminUser);
     $this->visit('/backend/email/passwort_reset')->see(trans('user::user.reset_password'));
 }
Exemplo n.º 10
0
 /**
  * @test
  */
 public function it_allows_create_entry_with_gif_file()
 {
     $adminUser = User::first();
     $this->actingAs($adminUser);
     $controller = $this->getControllerClass();
     // get create url
     $urlBuilder = new UrlBuilder($controller, $this->getUrlParameters());
     $url = $urlBuilder->getUrlCreate();
     // call
     $this->visit($url);
     // fill the form
     $this->type($this->gifFilepath, 'file');
     // check
     $this->press($this->getCreateButtonText())->see('alert-success');
 }
Exemplo n.º 11
0
 public function verify($token)
 {
     User::where('email_token', $token)->firstOrFail()->verified();
     Flash::success(trans('user::user.verification_successful'));
     return redirect('login');
 }
Exemplo n.º 12
0
 /**
  * Create a new user instance after a valid registration.
  *
  * @param array $data
  *
  * @return User
  */
 protected function create(array $data)
 {
     return User::create(['username' => $data['username'], 'email' => $data['email'], 'password' => $data['password']]);
 }