/** * @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'); }
/** * @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'); }
/** * @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'); }
/** * @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); }
/** * @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); }
/** * @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'); }
/** * @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')); }
/** * @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'); }