/** * @test * it should render extended shortcode */ public function it_should_render_extended_shortcode(\FunctionalTester $I) { $content = 'Lorem ipsum [idlikethis]Some idea of mine[/idlikethis]'; $post_id = $I->havePostInDatabase(['post_name' => 'foo', 'post_content' => $content]); $I->amOnPage('/foo'); $text = "Some idea of mine"; $I->seeElement('.idlikethis-button[data-post-id="' . $post_id . '"][data-text="' . $text . '"] button'); }
public function deleteADiscussion(FunctionalTester $I, UserSteps $userSteps) { $userId = $userSteps->amRegularUser(); $catId = $userSteps->haveCategory(); $postId = $userSteps->havePost(['title' => 'Is there a way to validate only some fields?', 'users_id' => $userId, 'categories_id' => $catId]); $I->amOnPage("/discussion/{$postId}/abc"); $I->seeInTitle('Is there a way to validate only some fields? - Discussion'); $I->seeElement(['css' => 'a.btn-delete-post']); $I->click(['css' => 'a.btn-delete-post']); $I->see('Discussion was successfully deleted', '//body/div[1]/div/div/div'); }
public function deleteADiscussion(FunctionalTester $I, UserSteps $userSteps) { $userId = $userSteps->amRegularUser(); $catId = $userSteps->haveCategory(['name' => 'Some Category', 'slug' => 'some-category', 'description' => 'A description of the category']); $postId = $userSteps->havePost(['title' => 'Is there a way to validate only some fields?', 'content' => 'as I see, only the form itself can be validated. It validates if all fields passes, right?' . ' Well, this time I have to validate 3 fields - but those fields what passes, should go inside database.' . ' With the original schema, I cant do that', 'users_id' => $userId, 'slug' => 'is-there-a-way-to-validate-only-some-fields', 'categories_id' => $catId]); $I->amOnPage("/discussion/{$postId}/is-there-a-way-to-validate-only-some-fields"); $I->seeInTitle('Is there a way to validate only some fields? - Discussion - Phalcon Framework'); $I->seeElement(['css' => 'a.btn-delete-post']); $I->click(['css' => 'a.btn-delete-post']); $I->see('Discussion was successfully deleted', '//body/div[1]/div/div/div'); }
<?php $I = new FunctionalTester($scenario); // Prep $sentry = $I->grabService('sentry'); $user = $sentry->findUserByLogin('*****@*****.**'); // Test $I->amActingAs('*****@*****.**'); $I->wantTo('edit my own profile'); $I->amOnPage('/users/' . $user->id . '/edit'); $I->seeElement('form', ['class' => 'form-horizontal']); $I->fillField('first_name', 'Irina'); $I->fillField('last_name', 'Sergeyevna'); $I->click('Submit Changes'); $I->seeRecord('users', ['email' => '*****@*****.**', 'first_name' => 'Irina', 'last_name' => 'Sergeyevna']);
/** * ------------------------------------ * Mark a topic as Wiki * ------------------------------------ */ $I = new FunctionalTester($scenario); Route::enableFilters(); $I->wantTo('Mark a topic as Community Wiki being a visitor, normal member and admin.'); $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-wiki-button'); $I->amOnRoute('topics.wiki', $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-wiki-button'); $I->amOnRoute('topics.wiki', $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-wiki-button'); $I->click('#topic-wiki-button'); // Succeed $I->seeElement('.ribbon-wiki'); $I->seeRecord('topics', ['id' => $topic->id, 'is_wiki' => true]);
* ------------------------------------ * 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 $I->amOnRoute('topics.index'); $I->seeElement('#pin-' . $topic->id); $I->seeRecord('topics', ['id' => $topic->id, 'order' => 1]);
<?php $I = new FunctionalTester($scenario); $I->wantTo('ensure that User create work'); $I->fixtureLogin('user1'); $I->go(['/user/user/create']); $I->testForm('#user-form', 'User', [], ['email' => 123, 'password' => '']); $I->testForm('#user-form', 'User', ['email' => '*****@*****.**', 'password' => 'admin']); $I->seeElement('.alert-warning'); // needs polling
<?php /** * ------------------------------------ * Down vote a topic * ------------------------------------ */ $I = new FunctionalTester($scenario); Route::enableFilters(); $I->wantTo('Down Vote Topic as a visitor and a menber.'); $topic = $I->postATopic(['title' => 'My Awsome Topic.']); // --------------- As a visitor -------------- $I->am('as a Visitor'); $I->amOnRoute('topics.show', $topic->id); $I->click('#down-vote'); $I->seeCurrentUrlEquals('/login-required'); // --------------- As a member -------------- $user = $I->signIn(); $I->am('as a Member'); $I->amOnRoute('topics.show', $topic->id); $I->seeElement('#down-vote'); $I->click('#down-vote'); $I->see('My Awsome Topic.'); $I->seeRecord('topics', ['id' => $topic->id, 'vote_count' => -1]);
<?php $I = new FunctionalTester($scenario); $I->mockMuleConnectorServiceForVatStatus(); $I->reloadFixtures(); $I->wantTo('create account'); $I->amOnPage('/account/create'); $I->seeResponseCodeIs(200); $I->see('Create Account', '#top-menu'); $I->seeElement('form'); $I->see('VAT country', 'form'); $I->see('VAT number', 'form'); $I->see('DK', 'form select option'); $I->click('Create Account', 'form button'); $I->seeResponseCodeIs(200); $I->see('This value should not be blank.'); $I->submitForm('form', ['create_account' => ['vatCountry' => 'DK', 'vatNumber' => '00000000']]); $I->see('This value should not be equal to "00000000".'); $I->submitForm('form', ['create_account' => ['vatCountry' => 'DK', 'vatNumber' => '12345']]); //$I->see('VAT Status', 'h2'); //$I->seeElement('#status-table'); //$I->see('Error', '#status-table td'); //$I->see('Duplicate', '#status-table td'); //$I->see('Success', '#status-table td'); //$I->see('Back', 'a.btn');
<?php $I = new FunctionalTester($scenario); $I->am('registered common user'); $I->wantTo('perform authentication actions'); // When $I->amOnPage('login'); // Then $I->see('Log in', 'h2'); $I->see('Username', 'label'); $I->see('Password', 'label'); $I->see('Remember me', 'label'); $I->seeElement('input', ['value' => 'Log in', 'class' => 'btn btn-primary btn-block']); $I->amGoingTo('fill an invalid user in order to see the errors'); // When $I->fillField('username', 'admin'); $I->fillField('password', '12345'); // And $I->click('Log in', 'input[type=submit]'); // Then $I->expectTo('see an error message'); $I->seeCurrentUrlEquals('/login'); $I->seeInField('username', 'admin'); $I->see('Invalid data', '.alert-danger'); $I->haveRecord('users', ['first_name' => 'System', 'last_name' => 'Administrator', 'username' => 'admin', 'password' => Hash::make('secret'), 'email' => '*****@*****.**', 'remember_token' => null]); $I->amGoingTo('full a valid user and see the result'); // When $I->fillField('password', 'secret'); // And $I->click('Log in', 'input[type=submit]'); // Then
/** * ------------------------------------ * Topic deletion * ------------------------------------ */ $I = new FunctionalTester($scenario); Route::enableFilters(); $I->wantTo('Delete a topic as a visitor, normal member and admin.'); $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-delete-button'); $I->amOnRoute('topics.delete', $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-delete-button'); $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('#topic-delete-button'); $I->click('#topic-delete-button'); $I->seeCurrentRouteIs('topics'); $I->dontSeeRecord('topics', ['id' => $topic->id]);
<?php /** * ------------------------------------ * Favorite a topic * ------------------------------------ */ $I = new FunctionalTester($scenario); Route::enableFilters(); $I->wantTo('Favorite a Topic as a visitor and a menber.'); $topic = $I->postATopic(['title' => 'My Awsome Topic.']); // --------------- As a visitor -------------- $I->am('as a Visitor'); $I->amOnRoute('topics.show', $topic->id); $I->click('#topic-favorite-button'); $I->seeCurrentUrlEquals('/login-required'); // --------------- As a member -------------- $user = $I->signIn(); $I->am('as a Member'); // -- favorite $I->amOnRoute('topics.show', $topic->id); $I->seeElement('#topic-favorite-button'); $I->click('#topic-favorite-button'); $I->see('My Awsome Topic.'); $I->seeRecord('favorites', ['topic_id' => $topic->id, 'user_id' => $user->id]); // -- cancel favorite $I->amOnRoute('topics.show', $topic->id); $I->seeElement('#topic-favorite-cancel-button'); $I->click('#topic-favorite-cancel-button'); $I->see('My Awsome Topic.'); $I->dontSeeRecord('favorites', ['topic_id' => $topic->id, 'user_id' => $user->id]);
<?php $I = new FunctionalTester($scenario); $I->resetEmails(); //setup $I->am('a user'); $I->wantTo('activate my phone number with expired code'); $I->amAuthenticatedWithCredentials(); $I->haveRecord('users_confirmations', ['type' => 'phone', 'confirmation_code' => '1234', 'user_id' => 1, 'created_at' => '2015-05-08 00:00:00', 'updated_at' => '2015-05-08 00:00:00']); //action //step 1 $code = $I->grabRecord('users_confirmations', ['user_id' => 1, 'type' => 'phone']); //step2 $I->amOnPage('/confirmation/phone'); $I->fillField(['name' => 'code'], $code->confirmation_code); $I->click('submit-confirmation-code'); //step5 $I->seeCurrentUrlEquals('/confirmation'); $I->seeElement('#submit-phone-code'); $I->dontSeeRecord('users_profiles', ['user_id' => 1, 'phone_confirmed' => 1]);
/** * ------------------------------------ * Mark a topic as exellent * ------------------------------------ */ $I = new FunctionalTester($scenario); Route::enableFilters(); $I->wantTo('Recomend a topic to the home page as a visitor, normal member and admin.'); $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-recomend-button'); $I->amOnRoute('topics.recomend', $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-recomend-button'); $I->amOnRoute('topics.recomend', $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-recomend-button'); $I->click('#topic-recomend-button'); // Succeed $I->seeElement('.ribbon-excellent'); $I->seeRecord('topics', ['id' => $topic->id, 'is_excellent' => true]);
<?php /** * ------------------------------------ * Upvote a reply * ------------------------------------ */ $I = new FunctionalTester($scenario); Route::enableFilters(); $I->wantTo('UP Vote a Reply as a visitor and a menber.'); $topic = $I->postATopic(['title' => 'My Awsome Topic.']); $reply = $I->have('Reply', ['topic_id' => $topic->id]); // --------------- As a visitor -------------- $I->am('as a Visitor'); $I->amOnRoute('topics.show', $topic->id); $I->click('#reply-up-vote-' . $reply->id); $I->seeCurrentUrlEquals('/login-required'); // --------------- As a member -------------- $user = $I->signIn(); $I->am('as a Member'); $I->amOnRoute('topics.show', $topic->id); $I->seeElement('#reply-up-vote-' . $reply->id); $I->click('#reply-up-vote-' . $reply->id); $I->see('My Awsome Topic.'); $I->seeRecord('replies', ['id' => $reply->id, 'vote_count' => 1]);
public function checkHomePageContainsDataSetInAdmin(FunctionalTester $I) { $I->am('Admin'); $I->wantTo('check on the home page that the data saved from the admin panel are shown'); $I->expectTo('see the saved data on the home page'); /*************************************************************************************************************** * settings **************************************************************************************************************/ // we create the admin role $admin_role = $this->_createAdminRole(); // we attach it to the logged user $admin_role->users()->attach($this->_user); // we create a slide $this->_createSlide(); /*************************************************************************************************************** * run test **************************************************************************************************************/ $I->amOnPage('/'); $I->seeCurrentRouteIs('home'); $I->see($this->_slide->title, 'h2'); $I->see($this->_slide->quote, '.quote'); $I->seeElement('//img[@src="' . url('img/slides/' . $this->_slide->picto) . '"]'); $I->seeElement('//div[@data-background-image="' . url('img/slides/' . $this->_slide->background_image) . '"]'); $I->see(json_decode(file_get_contents(storage_path('app/home/content.json')))->title, 'h2'); $I->see(json_decode(file_get_contents(storage_path('app/home/content.json')))->description); $I->seeElement('//a[@href="' . json_decode(file_get_contents(storage_path('app/home/content.json')))->video_link . '"]'); }
*/ $I = new FunctionalTester($scenario); Route::enableFilters(); $I->wantTo('Editing user profile as a Visitor and the Owner.'); $user = $I->have('User'); // --------------- As a visitor -------------- $I->am('as a Visitor'); $I->amOnRoute('users.show', $user->id); $I->dontSeeElement('#user-edit-button'); $I->amOnRoute('users.edit', $user->id); $I->seeCurrentRouteIs('login-required'); // --------------- As a member -------------- $user = $I->signIn(); $I->am('as the Owner'); $I->amOnRoute('users.show', $user->id); $I->seeElement('#user-edit-button'); $I->click('#user-edit-button'); $I->seeCurrentRouteIs('users.edit', $user->id); $I->fillField(['name' => 'city'], 'My city'); $I->fillField(['name' => 'company'], 'My company'); $I->fillField(['name' => 'twitter_account'], 'My twitter_account'); $I->fillField(['name' => 'personal_website'], 'My personal_website'); $I->fillField(['name' => 'signature'], 'My signature'); $I->fillField(['name' => 'introduction'], 'My introduction'); $I->click('#user-edit-submit'); $I->see('My city'); $I->see('My company'); $I->see('My twitter_account'); $I->see('My personal_website'); $I->see('My signature'); $I->see('My introduction');
<?php /** * ------------------------------------ * Attenting a topic * ------------------------------------ */ $I = new FunctionalTester($scenario); Route::enableFilters(); $I->wantTo('Attent a Topic discussion as a visitor and a menber.'); $topic = $I->postATopic(['title' => 'My Awsome Topic.']); // --------------- As a visitor -------------- $I->am('as a Visitor'); $I->amOnRoute('topics.show', $topic->id); $I->click('#topic-attent-button'); $I->seeCurrentUrlEquals('/login-required'); // --------------- As a member -------------- $user = $I->signIn(); $I->am('as a Member'); // -- attent $I->amOnRoute('topics.show', $topic->id); $I->seeElement('#topic-attent-button'); $I->click('#topic-attent-button'); $I->see('My Awsome Topic.'); $I->seeRecord('attentions', ['topic_id' => $topic->id, 'user_id' => $user->id]); // -- cancel attent $I->amOnRoute('topics.show', $topic->id); $I->seeElement('#topic-attent-cancel-button'); $I->click('#topic-attent-cancel-button'); $I->see('My Awsome Topic.'); $I->dontSeeRecord('attentions', ['topic_id' => $topic->id, 'user_id' => $user->id]);
<?php $I = new FunctionalTester($scenario); $I->am('a CMS admin'); $I->wantTo('filter the section list'); // When $I->haveSection(); // Created "Our company" section $sections = $I->haveSections(); // Random sections // And $I->amOnPage('admin/sections'); // Then $I->seeElement('input', ['name' => 'search']); // When $I->fillField('search', 'company'); $I->selectOption('published', '1'); // And $I->click('Filter sections'); // Then $I->seeCurrentUrlEquals('/admin/sections?search=company&published=1&menu='); $I->expect('not to see the our company record'); // Then $I->see('There are no sections, please create the first one'); $I->dontSee('Our company', 'td.name'); $I->seeInField('search', 'company'); // When $I->selectOption('published', '0'); $I->selectOption('menu', '0'); // And $I->click('Filter sections');
<?php /** * ------------------------------------ * Testing User index * ------------------------------------ */ $I = new FunctionalTester($scenario); $I->am('a Phphub member'); $I->wantTo('List all the user are registered for PHPHUB'); $user = $I->have('User', ['name' => 'SuperMeOriganal', 'created_at' => Carbon::now()->toDateTimeString()]); $I->seeRecord('users', ['id' => $user->id]); $I->amOnRoute('users.index'); $I->seeElement('.users-index-' . $user->id);
<?php /** * ------------------------------------ * Upvote a topic * ------------------------------------ */ $I = new FunctionalTester($scenario); Route::enableFilters(); $I->wantTo('UP Vote a Topic as a visitor and a menber.'); $topic = $I->postATopic(['title' => 'My Awsome Topic.']); // --------------- As a visitor -------------- $I->am('as a Visitor'); $I->amOnRoute('topics.show', $topic->id); $I->click('#up-vote'); $I->seeCurrentUrlEquals('/login-required'); // --------------- As a member -------------- $user = $I->signIn(); $I->am('as a Member'); $I->amOnRoute('topics.show', $topic->id); $I->seeElement('#up-vote'); $I->click('#up-vote'); $I->see('My Awsome Topic.'); $I->seeRecord('topics', ['id' => $topic->id, 'vote_count' => 1]);
<?php /** * ------------------------------------ * Topic editing function * ------------------------------------ */ $I = new FunctionalTester($scenario); Route::enableFilters(); $I->wantTo('Editing a topic as a Visitor, Member and Author.'); $topic = $I->postATopic(['title' => 'My Awsome Topic.']); // --------------- As a visitor -------------- $I->am('as a Visitor'); $I->amOnRoute('topics.show', $topic->id); $I->dontSeeElement('#topic-edit-button'); $I->amOnRoute('topics.edit', $topic->id); $I->seeCurrentUrlEquals('/login-required'); // --------------- As a member -------------- $user = $I->signIn(); $I->am('as the author'); $topic = $I->postATopic(['title' => 'My Awsome Topic.', 'user_id' => $user->id]); $I->amOnRoute('topics.show', $topic->id); $I->seeElement('#topic-edit-button'); $I->click('#topic-edit-button'); $I->selectOption('form select[name=node_id]', 'php'); $I->fillField(['name' => 'title'], 'My first post!'); $I->fillField(['name' => 'body'], 'My first post body.'); $I->click('#topic-create-submit'); $I->see('My first post!');
<?php $I = new FunctionalTester($scenario); $I->reloadFixtures(); $I->wantTo('perform batch actions on Messages'); $I->amOnPage('/message'); # batch actions checkboxes on messages list, action select box, submit button $I->seeElement('input[type="checkbox"].checkbox-select-all'); $I->seeElement('input[type="checkbox"].checkbox-select-all-item'); $I->seeElement('form#batch input[type="hidden"][name="action"]'); $I->seeElement('form#batch input[type="hidden"][name="action_type"]'); $I->see('Action for selected', 'form#batch button.dropdown-toggle'); $I->see('Action for all', 'form#batch button.dropdown-toggle'); $I->see('Set status New', 'div#batch-selected'); $I->see('Halt message', 'div#batch-selected'); $I->see('Cancel message', 'div#batch-selected'); $I->see('Reset GUIDs', 'div#batch-selected'); $I->see('Set status New', 'div#batch-all'); $I->see('Halt message', 'div#batch-all'); $I->see('Cancel message', 'div#batch-all'); $I->see('Reset GUIDs', 'div#batch-all'); # sending batch form with no action selected $I->submitForm('form[name="batch"]', []); $I->see('Please select batch action.', '.alert-danger'); # sending batch form with no action type selected $I->submitForm('form[name="batch"]', ['action' => 'new']); $I->see('Please select batch action type.', '.alert-danger'); # sending batch form with no Messages selected //$I->submitForm('form[name="batch"]', ['action' => 'ready', 'action_type' => 'selected']); //$I->see('Please select at least one Message.', '.alert-danger'); $I->see('New', 'table tr[class="status-new"] td');
$I->see('Messages'); $I->see('Search', 'div.panel form button.btn-info'); $I->see('Status overview'); $I->seeLink('ID'); $I->seeLink('Created'); $I->seeLink('Type'); $I->seeLink('Status'); $I->see('Action'); $I->seeLink('Details'); $I->see('1.502', 'table tfoot'); # buttons $I->seeLink('', '/message/set-status'); // for status buttons # buttons: item with "Ready" status $I->dontSeeElement('table#results tr.status-new a.btn-success span.glyphicon-check'); $I->seeElement('table#results tr.status-new a.btn-primary span.glyphicon-play'); $I->seeElement('table#results tr.status-new a.btn-warning span.glyphicon-pause'); $I->seeElement('table#results tr.status-new a.btn-danger span.glyphicon-remove'); $I->seeElement('table#results tr.status-new div.icon-button-placeholder-xs'); # buttons: item with "Halted" status $I->seeElement('table#results tr.status-halted a.btn-primary span.glyphicon-play'); $I->seeElement('table#results tr.status-halted a.btn-success span.glyphicon-check'); $I->dontSeeElement('table#results tr.status-halted a.btn-warning span.glyphicon-pause'); $I->seeElement('table#results tr.status-halted a.btn-danger span.glyphicon-remove'); $I->seeElement('table#results tr.status-halted div.icon-button-placeholder-xs'); // coloured statuses on list $I->see('New', 'td span[class="label label-default"]'); $I->see('Error', 'td span[class="label label-danger"]'); $I->see('In progress', 'td span[class="label label-primary"]'); $I->see('Halted', 'td span[class="label label-warning"]'); $I->see('New', 'td span[class="label label-default"]');
<?php $I = new FunctionalTester($scenario); // Prep $sentry = $I->grabService('sentry'); $user = $sentry->findUserByLogin('*****@*****.**'); $group = $sentry->findGroupByName('Users'); // Test $I->amActingAs('*****@*****.**'); $I->wantTo('edit a group name'); $I->amOnPage('/groups/' . $group->id . '/edit'); $I->seeElement('input', ['class' => 'form-control', 'name' => 'name']); $I->fillField('name', 'Prozorovs'); $I->click('Save Changes'); $I->seeRecord('groups', ['name' => 'Prozorovs', 'id' => $group->id]);
<?php $I = new FunctionalTester($scenario); $I->resetEmails(); //setup $I->am('a user'); $I->wantTo('activate my email adress with expired code'); $I->amAuthenticatedWithCredentials(); $I->canSeeAuthentication(); $I->haveRecord('users_confirmations', ['type' => 'mail', 'confirmation_code' => 'KGcClDwrpbZn2XwHJbBTcqf28GrY5O', 'user_id' => 1, 'created_at' => '2015-05-08 00:00:00', 'updated_at' => '2015-05-08 00:00:00']); //step4 $code = $I->grabRecord('users_confirmations', ['user_id' => 1, 'type' => 'mail']); $I->amOnPage('/confirmation/mail/' . $code->confirmation_code); $I->seeElement('#submit-mail-code'); $I->dontSeeRecord('users_profiles', ['user_id' => 1, 'mail_confirmed' => 1]);
<?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 removeAttachment(FunctionalTester $I) { $I->am('Manager User'); $I->wantTo('remove an attachment from a project issue comments'); $fileName = 'upload1.txt'; $manager = $I->createUser(1, 3); $I->amLoggedAs($manager); $issue = $I->createIssue(1, $manager); $project = $issue->project; $I->amOnAction('Project\\IssueController@getIndex', ['project' => $project, 'issue' => $issue]); $uploadToken = $I->grabValueFrom('//form/input[@name="upload_token"]'); $uri = $I->getApplication()->url->action('Project\\IssueController@postUploadAttachment', ['project' => $project]); $I->submitFormWithFileToUri('.new-comment form', $uri, ['upload' => $fileName], ['comment' => 'Comment 1']); $attachment = $issue->comments->first()->attachments->first(); $I->amOnAction('Project\\IssueController@getDownloadAttachment', ['project' => $project, 'issue' => $issue, 'attachment' => $attachment]); $I->seeResponseCodeIs(200); $I->amOnAction('Project\\IssueController@getIndex', ['project' => $project, 'issue' => $issue]); $I->seeElement('.attachments a', ['title' => $fileName]); $uri = $I->getApplication()->url->action('Project\\IssueController@postRemoveAttachment', ['project' => $project]); $I->sendAjaxPostRequest($uri, ['_token' => csrf_token(), 'upload_token' => $uploadToken, 'filename' => $fileName]); $I->amOnAction('Project\\IssueController@getIndex', ['project' => $project, 'issue' => $issue]); $I->dontSeeElement('.attachments a', ['title' => $fileName]); $I->amOnAction('Project\\IssueController@getDisplayAttachment', ['project' => $project, 'issue' => $issue, 'attachment' => $attachment]); $I->seeResponseCodeIs(404); }