public function guestCantVisitRolesPage(FunctionalTester $I) { $I->am('a guest'); $I->wantTo('make sure I can\'t view the roles page'); //I can see the menu item $I->amOnPage('/roles'); $I->canSeeCurrentUrlEquals('/login'); }
public function canFetchPhoto(FunctionalTester $I) { $I->am('a developer'); $I->wantTo('ensure photos can be fetched'); $equipment = \BB\Entities\Equipment::findOrFail(2); $equipment->addPhoto('foo.png'); $equipment = \BB\Entities\Equipment::findOrFail(2); $I->assertEquals($equipment->getPhotoBasePath() . 'foo.png', $equipment->getPhotoPath(0)); }
public function tryToCreateModifyAndDeleteContent(FunctionalTester $I) { $I->am('Anonymous user'); $I->sendPOST('api/contents.json', $this->content3); $I->seeResponseCodeIs(401); $I->sendPUT('api/contents/' . $this->content2['key'] . '.json'); $I->seeResponseCodeIs(401); $I->sendDELETE('api/contents/' . $this->content2['key'] . '.json'); $I->seeResponseCodeIs(401); $I->am('ROLE_USER'); $I->login($this->user['email']); $I->sendPOST('api/contents.json', $this->content3); $I->seeResponseCodeIs(403); $I->sendPUT('api/contents/' . $this->content2['key'] . '.json'); $I->seeResponseCodeIs(403); $I->sendDELETE('api/contents/' . $this->content2['key'] . '.json'); $I->seeResponseCodeIs(403); $I->am('ROLE_ADMIN'); $I->login($this->admin['email']); $I->sendPOST('api/contents.json', $this->content3); $I->seeResponseCodeIs(200); $I->seeResponseContainsJson($this->content3); $id = $I->grabDataFromResponseByJsonPath('$.id')[0]; $I->sendGET('api/contents/' . $this->content3['key'] . '.json'); $I->seeResponseCodeIs(200); $I->seeResponseContainsJson($this->content3); $I->sendGET('api/contents/' . $id . '.json'); $I->seeResponseCodeIs(200); $I->seeResponseContainsJson($this->content3); $this->content3['title'] = 'new title'; $I->sendPUT('api/contents/' . $id . '.json', $this->content3); $I->seeResponseCodeIs(200); $I->seeResponseContainsJson($this->content3); $I->sendGET('api/contents/' . $id . '.json'); $I->seeResponseCodeIs(200); $I->seeResponseContainsJson($this->content3); $I->sendDELETE('api/contents/' . $id . '.json'); $I->seeResponseCodeIs(204); $I->sendGET('api/contents/' . $id . '.json'); $I->seeResponseCodeIs(404); $I->logout(); $I->sendGET('api/contents/' . $id . '.json'); $I->seeResponseCodeIs(401); }
public function tryToCreateModifyAndDeleteEvent(FunctionalTester $I) { $I->am('Anonymous user'); $I->sendPOST('api/events.json', $this->event3); $I->seeResponseCodeIs(401); $I->sendPUT('api/events/' . $this->event2Id . '.json'); $I->seeResponseCodeIs(401); $I->sendDELETE('api/events/' . $this->event2Id . '.json'); $I->seeResponseCodeIs(401); $I->am('ROLE_USER'); $I->login($this->user['email']); $I->sendPOST('api/events.json', $this->event3); $I->seeResponseCodeIs(400); $this->event3['type'] = 'conference'; $I->sendPOST('api/events.json', $this->event3); $I->seeResponseCodeIs(200); $I->seeResponseContainsJson($this->event3); $id = $I->grabDataFromResponseByJsonPath('$.id')[0]; $I->sendGET('api/events/' . $id . '.json'); $I->seeResponseCodeIs(200); $I->seeResponseContainsJson($this->event3); $this->event3['name'] = 'new name'; $I->sendPUT('api/events/' . $id . '.json', $this->event3); $I->seeResponseCodeIs(200); $I->seeResponseContainsJson($this->event3); $I->sendGET('api/events/' . $id . '.json'); $I->seeResponseCodeIs(200); $I->seeResponseContainsJson($this->event3); $I->sendDELETE('api/events/' . $id . '.json'); $I->seeResponseCodeIs(204); $I->sendGET('api/events/' . $id . '.json'); $I->seeResponseCodeIs(404); $I->sendPOST('api/events.json', $this->event4); $I->seeResponseCodeIs(200); $this->event4['dateEnd'] = $this->event4['dateStart']; $I->seeResponseContainsJson($this->event4); $id = $I->grabDataFromResponseByJsonPath('$.id')[0]; $this->event4['data'] = ['some' => ['custom', 'data'], 'to' => ['check' => 'if arbitrary data can be stored']]; $I->sendPUT('api/events/' . $id . '.json', $this->event4); $I->sendGET('api/events/' . $id . '.json'); $I->seeResponseCodeIs(200); $I->seeResponseContainsJson($this->event4); }
public function tryToCreateModifyAndDeleteTeam(FunctionalTester $I) { $I->am('Anonymous user'); $I->sendPOST('api/teams.json', $this->team3); $I->seeResponseCodeIs(401); $I->sendPUT('api/teams/' . $this->team2Id . '.json'); $I->seeResponseCodeIs(401); $I->sendDELETE('api/teams/' . $this->team2Id . '.json'); $I->seeResponseCodeIs(401); $I->am('ROLE_USER'); $I->login($this->user['email']); $I->sendPOST('api/teams.json', $this->team3); $I->seeResponseCodeIs(403); $I->sendPUT('api/teams/' . $this->team2Id . '.json'); $I->seeResponseCodeIs(403); $I->sendDELETE('api/teams/' . $this->team2Id . '.json'); $I->seeResponseCodeIs(403); $I->am('ROLE_ADMIN'); $I->login($this->admin['email']); $I->sendPOST('api/teams.json', $this->team3); $I->seeResponseCodeIs(200); $I->seeResponseContainsJson($this->team3); $id = $I->grabDataFromResponseByJsonPath('$.id')[0]; $I->sendGET('api/teams/' . $id . '.json'); $I->seeResponseCodeIs(200); $I->seeResponseContainsJson($this->team3); $I->sendGET('api/teams/' . $id . '.json'); $I->seeResponseCodeIs(200); $I->seeResponseContainsJson($this->team3); $this->team3['name'] = 'new name'; $I->sendPUT('api/teams/' . $id . '.json', $this->team3); $I->seeResponseCodeIs(200); $I->seeResponseContainsJson($this->team3); $I->sendGET('api/teams/' . $id . '.json'); $I->seeResponseCodeIs(200); $I->seeResponseContainsJson($this->team3); $I->sendDELETE('api/teams/' . $id . '.json'); $I->seeResponseCodeIs(204); $I->sendGET('api/teams/' . $id . '.json'); $I->seeResponseCodeIs(404); }
public function memberCanLeave(FunctionalTester $I) { $I->am('a member'); $I->wantTo('leave build brighton'); //Load and login a known member $user = User::find(1); Auth::login($user); $I->amOnPage('/account/' . $user->id . ''); $I->canSee('Active'); $I->click("Leave Build Brighton"); $I->canSee('Leaving'); }
public function teamMemberCanEditLog(FunctionalTester $I) { $I->am('a laser team member'); $I->wantTo('make sure I can edit laser logs'); //Load and login a known admin member $user = $I->loginLaserTeamMember(); $otherUser = User::find(1); $I->amOnPage('/equipment/laser'); $I->see($otherUser->name); $I->selectOption('form[name=equipmentLog] select[name=reason]', 'testing'); $I->click('Update'); }
public function financeMemberCanVisitPaymentPage(FunctionalTester $I) { $I->am('a member of the finance group'); $I->wantTo('make sure I can view the payments page'); //Load and login a known member $user = User::find(3); $role = Role::findByName('finance'); $role->users()->attach($user->id); Auth::login($user); $I->amOnPage('/payments'); $I->seeCurrentUrlEquals('/payments'); $I->see('Payments'); }
/** * @param FunctionalTester $I * * @actor FunctionalTester * * @return void */ public function deleteUser(FunctionalTester $I) { $I->am('Admin User'); $I->wantTo('delete an existing user details'); $admin = $I->createUser(1, 4); $user = $I->createUser(2, 1); $user1 = $I->createUser(3, 2); $I->amLoggedAs($admin); $I->amOnAction('Administration\\UsersController@getDelete', ['user' => $user]); $I->seeCurrentActionIs('Administration\\UsersController@getIndex'); $I->dontSee($user->fullname); $I->see($user1->fullname); }
/** * @param FunctionalTester $I * * @actor FunctionalTester * * @return void */ public function deleteProject(FunctionalTester $I) { $I->am('Admin User'); $I->wantTo('delete an existing project details'); $project = $I->createProject(1); $admin = $I->createUser(1, 4); $I->amLoggedAs($admin); $I->amOnAction('ProjectController@getEdit', ['project' => $project]); $I->click(trans('tinyissue.delete_something', ['name' => $project->name])); $I->seeCurrentActionIs('ProjectsController@getIndex'); $I->dontSeeLink('Project 1'); $I->amOnAction('ProjectsController@getIndex', ['status' => Project::STATUS_ARCHIVED]); $I->dontSeeLink('Project 1'); $I->dontSeeRecord($project->getTable(), ['name' => 'Project 1']); }
public function viewInvalidNote(FunctionalTester $I) { $I->am('Normal User'); $I->expectTo('see 401 error with mismatch note route parameters.'); $admin = $I->createUser(1, 4); // admin $project1 = $I->createProject(1, [$admin]); $project2 = $I->createProject(2, [$admin]); $note1 = $I->createNote(1, $admin, $project1); $I->amLoggedAs($admin); $I->amOnAction('ProjectController@getNotes', ['project' => $project1]); $uri = $I->getApplication()->url->action('ProjectController@postEditNote', ['project' => $project2, 'note' => $note1], false); $I->sendAjaxPostRequest($uri, ['body' => 'note one updated', '_token' => csrf_token()]); $I->seeResponseCodeIs(401); }
/** * @param FunctionalTester $I * * @actor FunctionalTester * * @return void */ public function updateTag(FunctionalTester $I) { $I->am('Admin User'); $I->wantTo('edit an existing tag'); $tag = (new Tag())->where('group', '=', false)->get()->random(1); $data = ['name' => 'tag updated']; $tagName = $tag->name; $I->amLoggedAs($I->createUser(1, 4)); $I->amOnAction('Administration\\TagsController@getIndex'); $I->click($this->_editTagSelector($tagName)); $I->seeCurrentActionIs('Administration\\TagsController@getEdit', ['tag' => $tag]); $I->submitForm('form', $data); $I->amOnAction('Administration\\TagsController@getIndex'); $I->see($data['name'], $this->_editTagSelector($data['name'])); $I->dontSee($data['name'], $this->_editTagSelector($tagName)); }
public function adminCanDeclineExpenses(FunctionalTester $I) { $I->am('an admin'); $I->wantTo('make sure I can decline an expense'); //Create a proposal that's currently open $I->haveInDatabase('expenses', ['id' => 4, 'category' => 'consumables', 'description' => 'Another Description', 'user_id' => '3', 'amount' => 1234, 'expense_date' => Carbon::now()]); //Load and login a known member $user = User::find(3); Auth::login($user); $I->amOnPage('/expenses'); $I->canSee('Expenses'); $I->canSee('Another Description'); $I->cantSee('Declined by'); $I->click('Decline'); $I->canSee('Declined by'); }
/** * @param FunctionalTester $I * * @actor FunctionalTester * * @return void */ public function assignToUser(FunctionalTester $I) { $I->am('Admin User'); $I->wantTo('not be able to assign an issue to a user'); $admin = $I->createUser(1, 4); $developer1 = $I->createUser(2, 2); // developer $I->amLoggedAs($admin); $project = $I->createProject(1, [$developer1]); $issue = $I->createIssue(1, $admin, null, $project); $I->amOnAction('Project\\IssueController@getIndex', ['project' => $project, 'issue' => $issue]); $I->dontSee($developer1->fullname, '.assigned-to .currently_assigned'); $uri = $I->getApplication()->url->action('Project\\IssueController@postAssign', ['project' => $project]); $I->sendAjaxPostRequest($uri, ['user_id' => $developer1->id, '_token' => csrf_token()]); $I->comment($I->getResponseContent()); $I->amOnAction('Project\\IssueController@getIndex', ['project' => $project, 'issue' => $issue]); $I->see($developer1->fullname, '.assigned-to .currently_assigned'); }
/** * @param FunctionalTester $I * * @actor FunctionalTester * * @return void */ public function deleteNote(FunctionalTester $I) { $I->am('Admin User'); $I->wantTo('delete an existing note from a project'); $admin = $I->createUser(1, 4); $I->amLoggedAs($admin); $project = $I->createProject(1); $note1 = $I->createNote(1, $admin, $project); $note2 = $I->createNote(2, $admin, $project); $I->amOnAction('ProjectController@getNotes', ['project' => $project]); $I->see('Note 1', '//li[@id="note' . $note1->id . '"]'); $I->see('Note 2', '//li[@id="note' . $note2->id . '"]'); $uri = $I->getApplication()->url->action('ProjectController@getDeleteNote', ['project' => $project, 'note' => $note2]); $I->sendAjaxGetRequest($uri); $I->seeResponseCodeIs(200); $I->amOnAction('ProjectController@getNotes', ['project' => $project]); $I->see('Note 1', '//li[@id="note' . $note1->id . '"]'); $I->dontSee('Note 2', '//li[@id="note' . $note2->id . '"]'); }
/** * @param FunctionalTester $I * * @actor FunctionalTester * * @return void */ public function deleteComment(FunctionalTester $I) { $I->am('Developer User'); $I->wantTo('delete a comment from an issue'); $admin = $I->createUser(2, 4); $I->amLoggedAs($admin); $project = $I->createProject(1, [$admin]); $issue = $I->createIssue(1, $admin, $admin, $project); $comment1 = $I->createComment(1, $admin, $issue); $comment2 = $I->createComment(2, $admin, $issue); $I->amOnAction('Project\\IssueController@getIndex', ['project' => $project, 'issue' => $issue]); $I->see($comment1->comment, '#comment' . $comment1->id . ' .content'); $I->see($comment2->comment, '#comment' . $comment2->id . ' .content'); $uri = $I->getApplication()->url->action('Project\\IssueController@getDeleteComment', ['comment' => $comment1]); $I->sendAjaxGetRequest($uri); $I->seeResponseCodeIs(200); $I->amOnAction('Project\\IssueController@getIndex', ['project' => $project, 'issue' => $issue]); $I->dontSee($comment1->comment); $I->see($comment2->comment); }
public function memberCanReturnBox(FunctionalTester $I) { $I->am('a member'); $I->wantTo('make sure I can return a box I own'); //Load and login a known member $user = User::find(1); $I->amLoggedAs($user); //Setup a box a already claimed $box = \BB\Entities\StorageBox::first(); $box->user_id = $user->id; $box->save(); $I->amOnPage('/storage_boxes'); //Make sure the db is correct $I->seeInDatabase('storage_boxes', ['user_id' => $user->id]); //The page should have our name next to the claimed box $I->see($user->name); $I->click('Return Box'); //We should be gone from the DB $I->dontSeeInDatabase('storage_boxes', ['user_id' => $user->id]); $I->cantSee($user->name); }
/** * @param FunctionalTester $I * * @actor FunctionalTester * * @return void */ public function viewOverview(FunctionalTester $I) { $I->am('Admin User'); $I->wantTo('To view administration overview page'); $admin = $I->createUser(1, 4); $project1 = $I->createProject(1); $project2 = $I->createProject(2); $project2->status = Tinyissue\Model\Project::STATUS_ARCHIVED; $project2->save(); $I->createProject(3); $I->createIssue(1, $admin, null, $project1); $I->createIssue(2, $admin, null, $project1); $issue3 = $I->createIssue(3, $admin, null, $project1); $issue3->changeStatus(Project\Issue::STATUS_CLOSED, $admin); $I->amLoggedAs($admin); $I->amOnAction('HomeController@getIndex'); $I->click(trans('tinyissue.administration')); $I->seeCurrentActionIs('AdministrationController@getIndex'); $I->see('1', '//li[@class="list-group-item" and text()[contains(.,\'' . trans('tinyissue.total_users') . '\')]]/span'); $I->see('2', '//li[@class="list-group-item" and text()[contains(.,\'' . trans('tinyissue.active_projects') . '\')]]/span'); $I->see('1', '//li[@class="list-group-item" and text()[contains(.,\'' . trans('tinyissue.archived_projects') . '\')]]/span'); $I->see('2', '//li[@class="list-group-item" and text()[contains(.,\'' . trans('tinyissue.open_issues') . '\')]]/span'); $I->see('1', '//li[@class="list-group-item" and text()[contains(.,\'' . trans('tinyissue.closed_issues') . '\')]]/span'); }
/** * @param FunctionalTester $I * * @actor FunctionalTester * * @return void */ public function viewIssues(FunctionalTester $I) { $I->am('Developer User'); $I->wantTo('view issues assigned to logged user in all projects'); $admin = $I->createUser(1, 4); $developer1 = $I->createUser(2, 2); $I->amLoggedAs($developer1); $project1 = $I->createProject(1, [$developer1]); $issue1 = $I->createIssue(1, $admin, $developer1, $project1); $issue2 = $I->createIssue(2, $admin, $developer1, $project1); $issue3 = $I->createIssue(3, $developer1, $developer1, $project1); $project2 = $I->createProject(2, [$developer1]); $issue4 = $I->createIssue(4, $admin, $developer1, $project2); $issue5 = $I->createIssue(5, $admin, $developer1, $project2); $issue6 = $I->createIssue(6, $admin, null, $project2); $I->amOnAction('HomeController@getIndex'); $I->click(trans('tinyissue.your_issues')); $I->seeLink($issue1->title); $I->seeLink($issue2->title); $I->seeLink($issue3->title); $I->seeLink($issue4->title); $I->seeLink($issue5->title); $I->dontSeeLink($issue6->title); }
<?php /** * ------------------------------------ * Reply deletion * ------------------------------------ */ $I = new FunctionalTester($scenario); Route::enableFilters(); $I->wantTo('Delete a reply as a visitor, normal member and admin.'); $topic = $I->postATopic(['title' => 'My Awsome Topic.']); $reply = $I->have('Reply', ['topic_id' => $topic->id]); // Testing as a visitor $I->am('as a visitor'); $I->amOnRoute('topics.show', $topic->id); $I->dontSeeElement('#reply-delete-' . $reply->id); $I->amOnRoute('topics.delete', $topic->id); $I->seeCurrentRouteIs('login-required'); // Test as a normal member $I->am('as a member'); $I->signIn(); $I->dontSeeElement('#reply-delete-' . $reply->id); $I->amOnRoute('topics.delete', $topic->id); $I->seeCurrentRouteIs('admin-required'); // Testing as a admin user $I->am('a Phphub admin'); $I->signInAsAdmin(); $I->amOnRoute('topics.show', $topic->id); $I->seeElement('#reply-delete-' . $reply->id); $I->click('#reply-delete-' . $reply->id); $I->dontSeeRecord('replies', ['id' => $reply->id]);
/** * @param \FunctionalTester $I * * @actor FunctionalTester * * @return void */ public function cantCreateUser(FunctionalTester $I) { $I->am('Manager User'); $I->expectTo('not be able to create new user'); $I->amLoggedAs($I->createUser(1, 3)); $I->amOnAction('Administration\\UsersController@getAdd'); $I->seeResponseCodeIs(401); }
<?php $I = new FunctionalTester($scenario); $I->wantTo('create a currency without data'); $I->am('a Administrator user'); $I->dontSeeAuthentication(); $I->amLoggedAs(['email' => '*****@*****.**', 'password' => 'admin']); $I->seeAuthentication(); //When $I->amOnPage('/settings/currency'); //And $I->see('Create'); $I->click('Create'); //Then $I->seeCurrentUrlEquals('/settings/currency/create'); //When $form = ['name' => '', 'symbol' => '']; //And $I->submitForm('//form', $form, 'Create'); //Then $I->seeFormErrorMessage('name', 'The name field is required.'); //
<?php $I = new FunctionalTester($scenario); $I->am('a Larabook member'); $I->wantTo('I want to view my profile.'); $I->signIn(); $I->postAStatus('My new status.'); $I->click('Your Profile'); $I->seeCurrentUrlEquals('/@Foobar'); $I->see('My new status.');
<?php $I = new FunctionalTester($scenario); $I->am('a member'); $I->wantTo('view my profile.'); // setup $I->signIn(); $I->amOnPage('statuses'); // action $I->fillField('body', 'walla yalla'); $I->click(Lang::get('status.Send')); $I->click(Lang::get('account.Your Profile')); // watching if status actually is posted to my wall $I->seeCurrentUrlEquals('/@Foobar'); $I->see('walla yalla');
<?php $I = new FunctionalTester($scenario); //setup $I->am('a guest'); $I->wantTo('register an account'); //action $I->amOnPage('/register'); $I->see('Inscription'); $I->fillField(['name' => 'firstname'], 'John'); $I->fillField(['name' => 'lastname'], 'Doe'); $I->fillField(['name' => 'email'], '*****@*****.**'); $I->fillField(['name' => 'password'], 'password'); $I->fillField(['name' => 'password_confirmation'], 'password'); $I->click('submit-register'); //verify $I->canSeeAuthentication(); $I->seeRecord('users', array('email' => '*****@*****.**'));
<?php use Laracasts\TestDummy\Factory; $I = new FunctionalTester($scenario); $I->am('a USC Todo member'); $I->wantTo('post a new project'); $email = '*****@*****.**'; $password = '******'; Factory::create('App\\User', ['email' => $email, 'password' => $password]); $I->amOnPage('/auth/login'); $I->fillField('email', $email); $I->fillField('password', $password); $I->click('Login!'); //$I->signIn(); $I->seeCurrentUrlEquals('/projects');
<?php /** * ------------------------------------ * Pin a topic to top * ------------------------------------ */ $I = new FunctionalTester($scenario); Route::enableFilters(); $I->wantTo('Pin a topic on Top of the topic default list'); $topic = $I->postATopic(['title' => 'My Awsome Topic.']); // Testing as a visitor $I->am('a Phphub visitor'); $I->amOnRoute('topics.show', $topic->id); $I->dontSeeElement('#topic-pin-button'); $I->amOnRoute('topics.pin', $topic->id); $I->seeCurrentRouteIs('login-required'); // Test as a normal member $I->am('a Phphub member'); $I->signIn(); $I->amOnRoute('topics.show', $topic->id); $I->dontSeeElement('#topic-pin-button'); $I->amOnRoute('topics.pin', $topic->id); $I->seeCurrentRouteIs('admin-required'); // Testing as a admin user $I->am('a Phphub admin'); $I->signInAsAdmin(); $I->amOnRoute('topics.show', $topic->id); $I->seeElement('#topic-pin-button'); $I->click('#topic-pin-button'); // check the list
<?php /** * ------------------------------------ * Testing User Show * ------------------------------------ */ $I = new FunctionalTester($scenario); $I->am('as a visitor'); $I->wantTo('See a user profile.'); $user = $I->have('User', ['name' => 'SuperMeOriganal2', 'created_at' => Carbon::now()->toDateTimeString()]); $I->seeRecord('users', ['id' => $user->id]); $I->amOnRoute('users.show', $user->id); $I->see('SuperMeOriganal2');
<?php $I = new FunctionalTester($scenario); $I->am('a CMS admin'); $I->wantTo('delete a section'); // When $id = $I->haveSection(); // And $I->amOnPage('admin/sections/' . $id); // Then $I->see('Delete section', 'button.btn-del'); // When $I->click('Delete section'); // Then $I->seeCurrentUrlEquals('/admin/sections'); $I->dontSeeRecord('sections', ['id' => $id]);
public function adminCantEditStartedProposal(FunctionalTester $I) { $I->am('an admin'); $I->wantTo('make sure I cannt edit a proposal thats been started'); //Create a proposal that's currently open $startDate = Carbon::now()->subDays(2)->format('Y-m-d'); $endDate = Carbon::now()->addDays(2)->format('Y-m-d'); $I->haveInDatabase('proposals', ['id' => 2, 'title' => 'Proposal 2', 'description' => 'Demo Description', 'user_id' => '3', 'start_date' => $startDate, 'end_date' => $endDate]); //Load and login a known member $user = User::find(3); Auth::login($user); $I->amOnPage('/proposals/2'); //I can visit the edit page $I->cantSee('Edit Proposal'); }