<?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]);
<?php /** * ------------------------------------ * Notify user being "@" * ------------------------------------ */ $I = new FunctionalTester($scenario); Route::enableFilters(); $I->wantTo('Notify a User when he/she is being AT on a newly Reply'); $SuperMan = $I->have('User', ['name' => 'SuperMan']); $user = $I->signIn(); $topic = $I->postATopic(['title' => 'My Awsome Topic.', 'user_id' => $user->id]); // another user leave a reply $randomUser = $I->signIn(); $I->amOnRoute('topics.show', $topic->id); $I->fillField(['name' => 'body'], 'The Awsome Reply. @SuperMan'); $I->click('#reply-create-submit'); $I->see('The Awsome Reply. <a href="' . route('users.show', $SuperMan->id) . '">@SuperMan</a>'); // sign in the author $user = $I->signIn($SuperMan); $I->seeRecord('users', ['id' => $user->id, 'notification_count' => 1]); $I->amOnRoute('notifications.index'); $I->see('My Awsome Topic.'); $I->see('The Awsome Reply. <a href="' . route('users.show', $SuperMan->id) . '">@SuperMan</a>'); $I->see($randomUser->name); $I->seeRecord('users', ['id' => $user->id, 'notification_count' => 0]);
<?php $I = new FunctionalTester($scenario); $I->am('a Larabook member'); $I->wantTo('Login to Larabook'); $I->signIn(); //signin logic in Functional Helper $I->seeInCurrentUrl('/statuses'); $I->see('Post a status');
<?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 /** * ------------------------------------ * Notify attented user * ------------------------------------ */ $I = new FunctionalTester($scenario); Route::enableFilters(); $I->wantTo('Notify A User when he/she attented a Topic'); $topic = $I->postATopic(['title' => 'My Awsome Topic.']); // attented a topic $user = $I->signIn(); $I->amOnRoute('topics.show', $topic->id); $I->click('#topic-attent-button'); // another user leave a reply $randomUser = $I->signIn(); $I->amOnRoute('topics.show', $topic->id); $I->fillField(['name' => 'body'], 'The Awsome Reply.'); $I->click('#reply-create-submit'); $I->see('The Awsome Reply.'); // the first user sign in again $user = $I->signIn($user); $I->seeRecord('users', ['id' => $user->id, 'notification_count' => 1]); $I->amOnRoute('notifications.index'); $I->see('My Awsome Topic.'); $I->see('The Awsome Reply.'); $I->see($randomUser->name); $I->seeRecord('users', ['id' => $user->id, 'notification_count' => 0]);