diff --git a/app/Http/Controllers/MembersController.php b/app/Http/Controllers/MembersController.php index 23a7a72fb1dfb078e95de2d8477a1e3021ad9267..9f769ad556ddf419d6242490edc6e3cad14e49a2 100644 --- a/app/Http/Controllers/MembersController.php +++ b/app/Http/Controllers/MembersController.php @@ -26,8 +26,19 @@ class MembersController extends Controller */ public function index() { + $isMember = Auth::guard('member')->user() != null; + $isAdmin = Auth::user() != null && Auth::user()->IsAdmin == 1; + + if(!($isMember || $isAdmin)) + return redirect('/'); + $members = Member::orderBy('nim','asc')->paginate(20); - return view('members.list')->with('members', $members); + if ($isAdmin) { + return view('members.list')->with('members', $members); + } else { + //return blabla; + } + } /** diff --git a/database/factories/AnswerFactory.php b/database/factories/AnswerFactory.php index 0ee1d2da5bae67bc456e2626324a94671327e14a..db109023d5b11168f90453f4b7407758e362363f 100644 --- a/database/factories/AnswerFactory.php +++ b/database/factories/AnswerFactory.php @@ -8,6 +8,7 @@ $factory->define(App\Answer::class, function (Faker $faker) { 'body' => 'Answer for Testing', 'is_admin' => 1, 'member_id' => -1, + 'user_id' => -1, 'is_pinned' => 0 ]; }); diff --git a/database/factories/QuestionFactory.php b/database/factories/QuestionFactory.php index b0142f9cbbdc6f8a76019d4756eac7e2b9858ade..d8a59315a81bfc94545a6f04d37e18f16676c1f4 100644 --- a/database/factories/QuestionFactory.php +++ b/database/factories/QuestionFactory.php @@ -7,6 +7,7 @@ $factory->define(App\Question::class, function (Faker $faker) { 'topic' => 'Question for Testing', 'body' => 'Is This Question One?', 'is_admin' => 1, - 'member_id' => -1 + 'member_id' => -1, + 'user_id' => -1 ]; }); diff --git a/public/storage/cover_images/logo_itb_1524577271.png b/public/storage/cover_images/logo_itb_1524577271.png new file mode 100644 index 0000000000000000000000000000000000000000..a5dda77c2665d926b0d6c04eaa7b471f17c9ce32 Binary files /dev/null and b/public/storage/cover_images/logo_itb_1524577271.png differ diff --git a/public/storage/cover_images/logo_itb_1524577585.png b/public/storage/cover_images/logo_itb_1524577585.png new file mode 100644 index 0000000000000000000000000000000000000000..a5dda77c2665d926b0d6c04eaa7b471f17c9ce32 Binary files /dev/null and b/public/storage/cover_images/logo_itb_1524577585.png differ diff --git a/public/storage/cover_images/logo_itb_1524577586.png b/public/storage/cover_images/logo_itb_1524577586.png new file mode 100644 index 0000000000000000000000000000000000000000..a5dda77c2665d926b0d6c04eaa7b471f17c9ce32 Binary files /dev/null and b/public/storage/cover_images/logo_itb_1524577586.png differ diff --git a/public/storage/cover_images/logo_itb_1524578516.png b/public/storage/cover_images/logo_itb_1524578516.png new file mode 100644 index 0000000000000000000000000000000000000000..a5dda77c2665d926b0d6c04eaa7b471f17c9ce32 Binary files /dev/null and b/public/storage/cover_images/logo_itb_1524578516.png differ diff --git a/public/storage/cover_images/logo_itb_1524578517.png b/public/storage/cover_images/logo_itb_1524578517.png new file mode 100644 index 0000000000000000000000000000000000000000..a5dda77c2665d926b0d6c04eaa7b471f17c9ce32 Binary files /dev/null and b/public/storage/cover_images/logo_itb_1524578517.png differ diff --git a/public/storage/cover_images/logo_itb_1524578607.png b/public/storage/cover_images/logo_itb_1524578607.png new file mode 100644 index 0000000000000000000000000000000000000000..a5dda77c2665d926b0d6c04eaa7b471f17c9ce32 Binary files /dev/null and b/public/storage/cover_images/logo_itb_1524578607.png differ diff --git a/public/storage/cover_images/logo_itb_1524578608.png b/public/storage/cover_images/logo_itb_1524578608.png new file mode 100644 index 0000000000000000000000000000000000000000..a5dda77c2665d926b0d6c04eaa7b471f17c9ce32 Binary files /dev/null and b/public/storage/cover_images/logo_itb_1524578608.png differ diff --git a/public/storage/cover_images/logo_itb_1524578692.png b/public/storage/cover_images/logo_itb_1524578692.png new file mode 100644 index 0000000000000000000000000000000000000000..a5dda77c2665d926b0d6c04eaa7b471f17c9ce32 Binary files /dev/null and b/public/storage/cover_images/logo_itb_1524578692.png differ diff --git a/public/storage/cover_images/logo_itb_1524578693.png b/public/storage/cover_images/logo_itb_1524578693.png new file mode 100644 index 0000000000000000000000000000000000000000..a5dda77c2665d926b0d6c04eaa7b471f17c9ce32 Binary files /dev/null and b/public/storage/cover_images/logo_itb_1524578693.png differ diff --git a/public/storage/cover_images/logo_itb_1524579442.png b/public/storage/cover_images/logo_itb_1524579442.png new file mode 100644 index 0000000000000000000000000000000000000000..a5dda77c2665d926b0d6c04eaa7b471f17c9ce32 Binary files /dev/null and b/public/storage/cover_images/logo_itb_1524579442.png differ diff --git a/public/storage/cover_images/logo_itb_1524579443.png b/public/storage/cover_images/logo_itb_1524579443.png new file mode 100644 index 0000000000000000000000000000000000000000..a5dda77c2665d926b0d6c04eaa7b471f17c9ce32 Binary files /dev/null and b/public/storage/cover_images/logo_itb_1524579443.png differ diff --git a/public/storage/cover_images/logo_itb_1524579652.png b/public/storage/cover_images/logo_itb_1524579652.png new file mode 100644 index 0000000000000000000000000000000000000000..a5dda77c2665d926b0d6c04eaa7b471f17c9ce32 Binary files /dev/null and b/public/storage/cover_images/logo_itb_1524579652.png differ diff --git a/public/storage/cover_images/logo_itb_1524579653.png b/public/storage/cover_images/logo_itb_1524579653.png new file mode 100644 index 0000000000000000000000000000000000000000..a5dda77c2665d926b0d6c04eaa7b471f17c9ce32 Binary files /dev/null and b/public/storage/cover_images/logo_itb_1524579653.png differ diff --git a/public/storage/cover_images/logo_itb_1524579723.png b/public/storage/cover_images/logo_itb_1524579723.png new file mode 100644 index 0000000000000000000000000000000000000000..a5dda77c2665d926b0d6c04eaa7b471f17c9ce32 Binary files /dev/null and b/public/storage/cover_images/logo_itb_1524579723.png differ diff --git a/public/storage/cover_images/logo_itb_1524579724.png b/public/storage/cover_images/logo_itb_1524579724.png new file mode 100644 index 0000000000000000000000000000000000000000..a5dda77c2665d926b0d6c04eaa7b471f17c9ce32 Binary files /dev/null and b/public/storage/cover_images/logo_itb_1524579724.png differ diff --git a/public/storage/cover_images/logo_itb_1524579757.png b/public/storage/cover_images/logo_itb_1524579757.png new file mode 100644 index 0000000000000000000000000000000000000000..a5dda77c2665d926b0d6c04eaa7b471f17c9ce32 Binary files /dev/null and b/public/storage/cover_images/logo_itb_1524579757.png differ diff --git a/public/storage/cover_images/logo_itb_1524579758.png b/public/storage/cover_images/logo_itb_1524579758.png new file mode 100644 index 0000000000000000000000000000000000000000..a5dda77c2665d926b0d6c04eaa7b471f17c9ce32 Binary files /dev/null and b/public/storage/cover_images/logo_itb_1524579758.png differ diff --git a/public/storage/cover_images/logo_itb_1524579834.png b/public/storage/cover_images/logo_itb_1524579834.png new file mode 100644 index 0000000000000000000000000000000000000000..a5dda77c2665d926b0d6c04eaa7b471f17c9ce32 Binary files /dev/null and b/public/storage/cover_images/logo_itb_1524579834.png differ diff --git a/public/storage/cover_images/logo_itb_1524579835.png b/public/storage/cover_images/logo_itb_1524579835.png new file mode 100644 index 0000000000000000000000000000000000000000..a5dda77c2665d926b0d6c04eaa7b471f17c9ce32 Binary files /dev/null and b/public/storage/cover_images/logo_itb_1524579835.png differ diff --git a/public/storage/cover_images/logo_itb_1524581618.png b/public/storage/cover_images/logo_itb_1524581618.png new file mode 100644 index 0000000000000000000000000000000000000000..a5dda77c2665d926b0d6c04eaa7b471f17c9ce32 Binary files /dev/null and b/public/storage/cover_images/logo_itb_1524581618.png differ diff --git a/public/storage/cover_images/logo_itb_1524581619.png b/public/storage/cover_images/logo_itb_1524581619.png new file mode 100644 index 0000000000000000000000000000000000000000..a5dda77c2665d926b0d6c04eaa7b471f17c9ce32 Binary files /dev/null and b/public/storage/cover_images/logo_itb_1524581619.png differ diff --git a/public/storage/cover_images/logo_itb_1524586499.png b/public/storage/cover_images/logo_itb_1524586499.png new file mode 100644 index 0000000000000000000000000000000000000000..a5dda77c2665d926b0d6c04eaa7b471f17c9ce32 Binary files /dev/null and b/public/storage/cover_images/logo_itb_1524586499.png differ diff --git a/public/storage/cover_images/logo_itb_1524586502.png b/public/storage/cover_images/logo_itb_1524586502.png new file mode 100644 index 0000000000000000000000000000000000000000..a5dda77c2665d926b0d6c04eaa7b471f17c9ce32 Binary files /dev/null and b/public/storage/cover_images/logo_itb_1524586502.png differ diff --git a/public/storage/profile_image/logo_itb_1524577275.png b/public/storage/profile_image/logo_itb_1524577275.png new file mode 100644 index 0000000000000000000000000000000000000000..a5dda77c2665d926b0d6c04eaa7b471f17c9ce32 Binary files /dev/null and b/public/storage/profile_image/logo_itb_1524577275.png differ diff --git a/public/storage/profile_image/logo_itb_1524577590.png b/public/storage/profile_image/logo_itb_1524577590.png new file mode 100644 index 0000000000000000000000000000000000000000..a5dda77c2665d926b0d6c04eaa7b471f17c9ce32 Binary files /dev/null and b/public/storage/profile_image/logo_itb_1524577590.png differ diff --git a/public/storage/profile_image/logo_itb_1524578521.png b/public/storage/profile_image/logo_itb_1524578521.png new file mode 100644 index 0000000000000000000000000000000000000000..a5dda77c2665d926b0d6c04eaa7b471f17c9ce32 Binary files /dev/null and b/public/storage/profile_image/logo_itb_1524578521.png differ diff --git a/public/storage/profile_image/logo_itb_1524578612.png b/public/storage/profile_image/logo_itb_1524578612.png new file mode 100644 index 0000000000000000000000000000000000000000..a5dda77c2665d926b0d6c04eaa7b471f17c9ce32 Binary files /dev/null and b/public/storage/profile_image/logo_itb_1524578612.png differ diff --git a/public/storage/profile_image/logo_itb_1524578697.png b/public/storage/profile_image/logo_itb_1524578697.png new file mode 100644 index 0000000000000000000000000000000000000000..a5dda77c2665d926b0d6c04eaa7b471f17c9ce32 Binary files /dev/null and b/public/storage/profile_image/logo_itb_1524578697.png differ diff --git a/public/storage/profile_image/logo_itb_1524579447.png b/public/storage/profile_image/logo_itb_1524579447.png new file mode 100644 index 0000000000000000000000000000000000000000..a5dda77c2665d926b0d6c04eaa7b471f17c9ce32 Binary files /dev/null and b/public/storage/profile_image/logo_itb_1524579447.png differ diff --git a/public/storage/profile_image/logo_itb_1524579658.png b/public/storage/profile_image/logo_itb_1524579658.png new file mode 100644 index 0000000000000000000000000000000000000000..a5dda77c2665d926b0d6c04eaa7b471f17c9ce32 Binary files /dev/null and b/public/storage/profile_image/logo_itb_1524579658.png differ diff --git a/public/storage/profile_image/logo_itb_1524579729.png b/public/storage/profile_image/logo_itb_1524579729.png new file mode 100644 index 0000000000000000000000000000000000000000..a5dda77c2665d926b0d6c04eaa7b471f17c9ce32 Binary files /dev/null and b/public/storage/profile_image/logo_itb_1524579729.png differ diff --git a/public/storage/profile_image/logo_itb_1524579762.png b/public/storage/profile_image/logo_itb_1524579762.png new file mode 100644 index 0000000000000000000000000000000000000000..a5dda77c2665d926b0d6c04eaa7b471f17c9ce32 Binary files /dev/null and b/public/storage/profile_image/logo_itb_1524579762.png differ diff --git a/public/storage/profile_image/logo_itb_1524579840.png b/public/storage/profile_image/logo_itb_1524579840.png new file mode 100644 index 0000000000000000000000000000000000000000..a5dda77c2665d926b0d6c04eaa7b471f17c9ce32 Binary files /dev/null and b/public/storage/profile_image/logo_itb_1524579840.png differ diff --git a/public/storage/profile_image/logo_itb_1524581097.png b/public/storage/profile_image/logo_itb_1524581097.png new file mode 100644 index 0000000000000000000000000000000000000000..a5dda77c2665d926b0d6c04eaa7b471f17c9ce32 Binary files /dev/null and b/public/storage/profile_image/logo_itb_1524581097.png differ diff --git a/public/storage/profile_image/logo_itb_1524581119.png b/public/storage/profile_image/logo_itb_1524581119.png new file mode 100644 index 0000000000000000000000000000000000000000..a5dda77c2665d926b0d6c04eaa7b471f17c9ce32 Binary files /dev/null and b/public/storage/profile_image/logo_itb_1524581119.png differ diff --git a/public/storage/profile_image/logo_itb_1524581277.png b/public/storage/profile_image/logo_itb_1524581277.png new file mode 100644 index 0000000000000000000000000000000000000000..a5dda77c2665d926b0d6c04eaa7b471f17c9ce32 Binary files /dev/null and b/public/storage/profile_image/logo_itb_1524581277.png differ diff --git a/public/storage/profile_image/logo_itb_1524581544.png b/public/storage/profile_image/logo_itb_1524581544.png new file mode 100644 index 0000000000000000000000000000000000000000..a5dda77c2665d926b0d6c04eaa7b471f17c9ce32 Binary files /dev/null and b/public/storage/profile_image/logo_itb_1524581544.png differ diff --git a/public/storage/profile_image/logo_itb_1524581575.png b/public/storage/profile_image/logo_itb_1524581575.png new file mode 100644 index 0000000000000000000000000000000000000000..a5dda77c2665d926b0d6c04eaa7b471f17c9ce32 Binary files /dev/null and b/public/storage/profile_image/logo_itb_1524581575.png differ diff --git a/public/storage/profile_image/logo_itb_1524581603.png b/public/storage/profile_image/logo_itb_1524581603.png new file mode 100644 index 0000000000000000000000000000000000000000..a5dda77c2665d926b0d6c04eaa7b471f17c9ce32 Binary files /dev/null and b/public/storage/profile_image/logo_itb_1524581603.png differ diff --git a/public/storage/profile_image/logo_itb_1524581623.png b/public/storage/profile_image/logo_itb_1524581623.png new file mode 100644 index 0000000000000000000000000000000000000000..a5dda77c2665d926b0d6c04eaa7b471f17c9ce32 Binary files /dev/null and b/public/storage/profile_image/logo_itb_1524581623.png differ diff --git a/public/storage/profile_image/logo_itb_1524581685.png b/public/storage/profile_image/logo_itb_1524581685.png new file mode 100644 index 0000000000000000000000000000000000000000..a5dda77c2665d926b0d6c04eaa7b471f17c9ce32 Binary files /dev/null and b/public/storage/profile_image/logo_itb_1524581685.png differ diff --git a/public/storage/profile_image/logo_itb_1524581784.png b/public/storage/profile_image/logo_itb_1524581784.png new file mode 100644 index 0000000000000000000000000000000000000000..a5dda77c2665d926b0d6c04eaa7b471f17c9ce32 Binary files /dev/null and b/public/storage/profile_image/logo_itb_1524581784.png differ diff --git a/public/storage/profile_image/logo_itb_1524581944.png b/public/storage/profile_image/logo_itb_1524581944.png new file mode 100644 index 0000000000000000000000000000000000000000..a5dda77c2665d926b0d6c04eaa7b471f17c9ce32 Binary files /dev/null and b/public/storage/profile_image/logo_itb_1524581944.png differ diff --git a/public/storage/profile_image/logo_itb_1524581981.png b/public/storage/profile_image/logo_itb_1524581981.png new file mode 100644 index 0000000000000000000000000000000000000000..a5dda77c2665d926b0d6c04eaa7b471f17c9ce32 Binary files /dev/null and b/public/storage/profile_image/logo_itb_1524581981.png differ diff --git a/public/storage/profile_image/logo_itb_1524582185.png b/public/storage/profile_image/logo_itb_1524582185.png new file mode 100644 index 0000000000000000000000000000000000000000..a5dda77c2665d926b0d6c04eaa7b471f17c9ce32 Binary files /dev/null and b/public/storage/profile_image/logo_itb_1524582185.png differ diff --git a/public/storage/profile_image/logo_itb_1524582187.png b/public/storage/profile_image/logo_itb_1524582187.png new file mode 100644 index 0000000000000000000000000000000000000000..a5dda77c2665d926b0d6c04eaa7b471f17c9ce32 Binary files /dev/null and b/public/storage/profile_image/logo_itb_1524582187.png differ diff --git a/public/storage/profile_image/logo_itb_1524582584.png b/public/storage/profile_image/logo_itb_1524582584.png new file mode 100644 index 0000000000000000000000000000000000000000..a5dda77c2665d926b0d6c04eaa7b471f17c9ce32 Binary files /dev/null and b/public/storage/profile_image/logo_itb_1524582584.png differ diff --git a/public/storage/profile_image/logo_itb_1524582586.png b/public/storage/profile_image/logo_itb_1524582586.png new file mode 100644 index 0000000000000000000000000000000000000000..a5dda77c2665d926b0d6c04eaa7b471f17c9ce32 Binary files /dev/null and b/public/storage/profile_image/logo_itb_1524582586.png differ diff --git a/public/storage/profile_image/logo_itb_1524582587.png b/public/storage/profile_image/logo_itb_1524582587.png new file mode 100644 index 0000000000000000000000000000000000000000..a5dda77c2665d926b0d6c04eaa7b471f17c9ce32 Binary files /dev/null and b/public/storage/profile_image/logo_itb_1524582587.png differ diff --git a/public/storage/profile_image/logo_itb_1524582629.png b/public/storage/profile_image/logo_itb_1524582629.png new file mode 100644 index 0000000000000000000000000000000000000000..a5dda77c2665d926b0d6c04eaa7b471f17c9ce32 Binary files /dev/null and b/public/storage/profile_image/logo_itb_1524582629.png differ diff --git a/public/storage/profile_image/logo_itb_1524582632.png b/public/storage/profile_image/logo_itb_1524582632.png new file mode 100644 index 0000000000000000000000000000000000000000..a5dda77c2665d926b0d6c04eaa7b471f17c9ce32 Binary files /dev/null and b/public/storage/profile_image/logo_itb_1524582632.png differ diff --git a/public/storage/profile_image/logo_itb_1524583323.png b/public/storage/profile_image/logo_itb_1524583323.png new file mode 100644 index 0000000000000000000000000000000000000000..a5dda77c2665d926b0d6c04eaa7b471f17c9ce32 Binary files /dev/null and b/public/storage/profile_image/logo_itb_1524583323.png differ diff --git a/public/storage/profile_image/logo_itb_1524583326.png b/public/storage/profile_image/logo_itb_1524583326.png new file mode 100644 index 0000000000000000000000000000000000000000..a5dda77c2665d926b0d6c04eaa7b471f17c9ce32 Binary files /dev/null and b/public/storage/profile_image/logo_itb_1524583326.png differ diff --git a/public/storage/profile_image/logo_itb_1524583414.png b/public/storage/profile_image/logo_itb_1524583414.png new file mode 100644 index 0000000000000000000000000000000000000000..a5dda77c2665d926b0d6c04eaa7b471f17c9ce32 Binary files /dev/null and b/public/storage/profile_image/logo_itb_1524583414.png differ diff --git a/public/storage/profile_image/logo_itb_1524583417.png b/public/storage/profile_image/logo_itb_1524583417.png new file mode 100644 index 0000000000000000000000000000000000000000..a5dda77c2665d926b0d6c04eaa7b471f17c9ce32 Binary files /dev/null and b/public/storage/profile_image/logo_itb_1524583417.png differ diff --git a/public/storage/profile_image/logo_itb_1524584069.png b/public/storage/profile_image/logo_itb_1524584069.png new file mode 100644 index 0000000000000000000000000000000000000000..a5dda77c2665d926b0d6c04eaa7b471f17c9ce32 Binary files /dev/null and b/public/storage/profile_image/logo_itb_1524584069.png differ diff --git a/public/storage/profile_image/logo_itb_1524584072.png b/public/storage/profile_image/logo_itb_1524584072.png new file mode 100644 index 0000000000000000000000000000000000000000..a5dda77c2665d926b0d6c04eaa7b471f17c9ce32 Binary files /dev/null and b/public/storage/profile_image/logo_itb_1524584072.png differ diff --git a/public/storage/profile_image/logo_itb_1524584598.png b/public/storage/profile_image/logo_itb_1524584598.png new file mode 100644 index 0000000000000000000000000000000000000000..a5dda77c2665d926b0d6c04eaa7b471f17c9ce32 Binary files /dev/null and b/public/storage/profile_image/logo_itb_1524584598.png differ diff --git a/public/storage/profile_image/logo_itb_1524584601.png b/public/storage/profile_image/logo_itb_1524584601.png new file mode 100644 index 0000000000000000000000000000000000000000..a5dda77c2665d926b0d6c04eaa7b471f17c9ce32 Binary files /dev/null and b/public/storage/profile_image/logo_itb_1524584601.png differ diff --git a/public/storage/profile_image/logo_itb_1524585056.png b/public/storage/profile_image/logo_itb_1524585056.png new file mode 100644 index 0000000000000000000000000000000000000000..a5dda77c2665d926b0d6c04eaa7b471f17c9ce32 Binary files /dev/null and b/public/storage/profile_image/logo_itb_1524585056.png differ diff --git a/public/storage/profile_image/logo_itb_1524585058.png b/public/storage/profile_image/logo_itb_1524585058.png new file mode 100644 index 0000000000000000000000000000000000000000..a5dda77c2665d926b0d6c04eaa7b471f17c9ce32 Binary files /dev/null and b/public/storage/profile_image/logo_itb_1524585058.png differ diff --git a/public/storage/profile_image/logo_itb_1524586506.png b/public/storage/profile_image/logo_itb_1524586506.png new file mode 100644 index 0000000000000000000000000000000000000000..a5dda77c2665d926b0d6c04eaa7b471f17c9ce32 Binary files /dev/null and b/public/storage/profile_image/logo_itb_1524586506.png differ diff --git a/public/storage/profile_image/logo_itb_1524586509.png b/public/storage/profile_image/logo_itb_1524586509.png new file mode 100644 index 0000000000000000000000000000000000000000..a5dda77c2665d926b0d6c04eaa7b471f17c9ce32 Binary files /dev/null and b/public/storage/profile_image/logo_itb_1524586509.png differ diff --git a/public/storage/profile_image/noimage.jpg b/public/storage/profile_image/noimage.jpg new file mode 100644 index 0000000000000000000000000000000000000000..bed17c901e5fcdca78e6d892fdcd7c07b4b4bdb4 Binary files /dev/null and b/public/storage/profile_image/noimage.jpg differ diff --git a/tests/Feature/ArticleTest.php b/tests/Feature/ArticleTest.php index 8f23c5b1a9f11f194f05465ac30fa930cad78d68..7e2c5f56b4221fce324d8f9808dad8bea4ec7d92 100644 --- a/tests/Feature/ArticleTest.php +++ b/tests/Feature/ArticleTest.php @@ -5,7 +5,7 @@ namespace Tests\Feature; use App\Post; use App\Member; use App\User; - +use \Auth; use Tests\TestCase; use Illuminate\Foundation\Testing\WithFaker; use Illuminate\Foundation\Testing\RefreshDatabase; @@ -273,4 +273,64 @@ class ArticleTest extends TestCase $user->delete(); } + + /** + * test edit article + * + * @return void + */ + public function testShowArticleforMember() + { + $member = factory(Member::class)->create(); + $user = factory(User::class)->create(); + + $post_first = factory(Post::class)->create([ + 'user_id' => $user->id, + 'title' => 'Post for Testing 1', + 'public' => 1, + 'draft' => 1 + ]); + + $post_second = factory(Post::class)->create([ + 'user_id' => $user->id, + 'title' => 'Post for Testing 2', + 'public' => 1, + 'draft' => 0 + ]); + + $post_third = factory(Post::class)->create([ + 'user_id' => $user->id, + 'title' => 'Post for Testing 3', + 'public' => 0, + 'draft' => 1 + ]); + + $post_fourth = factory(Post::class)->create([ + 'user_id' => $user->id, + 'title' => 'Post for Testing 4', + 'public' => 0, + 'draft' => 0 + ]); + + $response = $this->visit('article') + ->see('Post for Testing 2') + ->dontSee('Post for Testing 1') + ->dontSee('Post for Testing 3') + ->dontSee('Post for Testing 4'); + + Auth::guard('member')->login($member); + $response = $this->visit('/article') + ->dontSee('Post for Testing 1') + ->see('Post for Testing 2') + ->dontSee('Post for Testing 3') + ->see('Post for Testing 4'); + + $post_first->delete(); + $post_second->delete(); + $post_third->delete(); + $post_fourth->delete(); + + $user->delete(); + $member->delete(); + } } diff --git a/tests/Feature/ProfileTest.php b/tests/Feature/ProfileTest.php index 76f772ba48f4918d224770b6285ebd2bed540feb..f39502d1c612da547194ce1669eb939de385703d 100644 --- a/tests/Feature/ProfileTest.php +++ b/tests/Feature/ProfileTest.php @@ -4,6 +4,7 @@ namespace Tests\Feature; use App\Member; use App\User; +use \Auth; use Tests\TestCase; use Illuminate\Foundation\Testing\WithFaker; @@ -108,4 +109,183 @@ class ProfileTest extends TestCase $user->delete(); $member->delete(); } + + /** + * test see other member + * + * @return void + */ + public function testSeeOtherMember() + { + $member = factory(Member::class)->create(); + $member_dummy = factory(Member::class)->create(); + + Auth::guard('member')->login($member); + $response = $this->visit('members/' . $member_dummy->id) + ->dontSee('Edit Profile') + ->see($member_dummy->name) + ->see($member_dummy->phone_number) + ->see($member_dummy->company) + ->see($member_dummy->interest) + ->see($member_dummy->address); + + $member->delete(); + $member_dummy->delete(); + } + + /** + * test see other member + * + * @return void + */ + public function testSeeHimselfAsMember() + { + $member = factory(Member::class)->create(); + + Auth::guard('member')->login($member); + $response = $this->visit('members/' . $member->id) + ->see('Edit Profile') + ->see($member->name) + ->see($member->phone_number) + ->see($member->company) + ->see($member->interest) + ->see($member->address); + + $member->delete(); + } + + /** + * test see other member + * + * @return void + */ + public function testShowMemberAsGuest() + { + $member = factory(Member::class)->create(); + + $response = $this->visit('members/' . $member->id) + ->seePageIs('/'); + + $member->delete(); + } + + /** + * test edit profile + * + * @return void + */ + public function testEditProfileAsOtherMember() + { + $member = factory(Member::class)->create(); + $member_dummy = factory(Member::class)->create(); + + Auth::guard('member')->login($member); + $response = $this->visit('members/' . $member_dummy->id . '/edit') + ->seePageIs('/'); + + $member->delete(); + $member_dummy->delete(); + } + + /** + * test edit profile + * + * @return void + */ + public function testEditProfileAsGuest() + { + $member_dummy = factory(Member::class)->create(); + + $response = $this->visit('members/' . $member_dummy->id . '/edit') + ->seePageIs('/'); + + $member_dummy->delete(); + } + + /** + * test edit profile + * + * @return void + */ + public function testEditOwnProfile() + { + $member = factory(Member::class)->create(); + + Auth::guard('member')->login($member); + $response = $this->visit('members/' . $member->id . '/edit') + ->type('08123456789', 'phone_number') + ->type('ITB', 'company') + ->type('Programming', 'interest') + ->type('Address', 'address') + ->attach('storage/app/public/logo_itb.png', 'profile_image') + ->press('Submit') + ->seePageIs('members/' . $member->id); + + $member->delete(); + } + + /** + * test edit profile + * + * @return void + */ + public function testEditOwnProfileWithoutAddress() + { + $member = factory(Member::class)->create(); + + Auth::guard('member')->login($member); + $response = $this->visit('members/' . $member->id . '/edit') + ->type('08123456789', 'phone_number') + ->type('ITB', 'company') + ->type('Programming', 'interest') + ->type('', 'address') + ->attach('storage/app/public/logo_itb.png', 'profile_image') + ->press('Submit') + ->seePageIs('members/' . $member->id); + + $member->delete(); + } + + /** + * test edit profile + * + * @return void + */ + public function testEditOwnProfileWithoutCompanyInterest() + { + $member = factory(Member::class)->create(); + + Auth::guard('member')->login($member); + $response = $this->visit('members/' . $member->id . '/edit') + ->type('08123456789', 'phone_number') + ->type('', 'company') + ->type('', 'interest') + ->type('Bandung', 'address') + ->attach('storage/app/public/logo_itb.png', 'profile_image') + ->press('Submit') + ->seePageIs('members/' . $member->id . '/edit'); + + $member->delete(); + } + + /** + * test edit profile + * + * @return void + */ + public function testEditOwnProfileWithoutPhoto() + { + $member = factory(Member::class)->create(); + + Auth::guard('member')->login($member); + $response = $this->visit('members/' . $member->id . '/edit') + ->type('08123456789', 'phone_number') + ->type('ITB', 'company') + ->type('Programming', 'interest') + ->type('Bandung', 'address') + ->press('Submit') + ->seePageIs('members/' . $member->id); + + $member->delete(); + } } diff --git a/tests/Feature/QuestionAnswerTest.php b/tests/Feature/QuestionAnswerTest.php index ef1c706afef42ad414b68e2da6a48f01021ba80d..44034069164be38a375eeec44843008e3043b852 100644 --- a/tests/Feature/QuestionAnswerTest.php +++ b/tests/Feature/QuestionAnswerTest.php @@ -10,6 +10,7 @@ use App\Question; use App\User; use App\Member; use App\Answer; +use \Auth; class QuestionAnswerTest extends TestCase { @@ -115,15 +116,18 @@ class QuestionAnswerTest extends TestCase ->type('Question for Testing', 'topic') ->type('Is This Question One?', 'body') ->press('Add') - ->see('Question Added') - ->click('Question for Testing') + ->see('Question Added'); + + $dummy = Question::where('topic', 'Question for Testing')->first(); + $written_on = 'Written on ' . $dummy->created_at->format('d M Y'); + $response = $this->actingAs($user) + ->visit('admin/questions') + ->click($written_on) ->see('Written on') ->see('Last Editted on') ->see('by'); - $dummy = Question::where('topic', 'Question for Testing')->first(); $dummy->delete(); - $user->delete(); } @@ -373,4 +377,262 @@ class QuestionAnswerTest extends TestCase $question->delete(); $user->delete(); } + + /** + * test show question + * + * @return void + */ + public function testShowEditQuestion() + { + $member = factory(Member::class)->create(); + + $question = factory(question::class)->create([ + 'is_admin' => 0, + 'member_id' => $member->id + ]); + + Auth::guard('member')->login($member); + $response = $this->visit('/questions') + ->click($question->topic) + ->seePageIs('questions/' . $question->id) + ->click('Edit') + ->seePageIs('questions/' . $question->id . '/edit') + ->type($question->topic . ' Editted', 'topic') + ->type($question->body . ' Editted', 'body') + ->check('anon') + ->press('Submit') + ->seePageIs('questions/' . $question->id) + ->see($question->topic . ' Editted') + ->see($question->body . ' Editted'); + + $question->delete(); + $member->delete(); + } + + public function testAddQuestionAnon() + { + $member = factory(Member::class)->create(); + $question = factory(question::class)->make(); + + Auth::guard('member')->login($member); + $response = $this->visit('/questions/create') + ->type($question->body, 'body') + ->type($question->topic, 'topic') + ->check('anon') + ->press('Submit') + ->seePageIs('/questions') + ->see('by Anonymous'); + + $dummy = Question::where('body', $question->body)->first(); + $dummy->delete(); + $member->delete(); + } + + /** + * test show question + * + * @return void + */ + public function testShowEditQuestionOthers() + { + $member = factory(Member::class)->create(); + $member_dummy = factory(Member::class)->create(); + + $question = factory(question::class)->create([ + 'is_admin' => 0, + 'member_id' => $member_dummy->id + ]); + + Auth::guard('member')->login($member); + $response = $this->visit('questions') + ->click($question->topic) + ->seePageIs('questions/' . $question->id) + ->dontSee('Delete'); + + $response = $this->visit('questions/' . $question->id . '/edit') + ->seePageIs('/'); + + $question->delete(); + $member->delete(); + $member_dummy->delete(); + } + + /** + * test show question edit + * + * @return void + */ + public function testShowQuestionVoteAnswer() + { + $user = factory(User::class)->create(); + $member = factory(Member::class)->create(); + + $question = factory(question::class)->create([ + 'user_id' => $user->id + ]); + $answer = factory(answer::class)->create([ + 'is_admin' => 0, + 'member_id' => $member->id, + 'question_id' => $question->id + ]); + + Auth::guard('member')->login($member); + $response = $this->visit('questions') + ->click($question->topic) + ->seePageIs('questions/' . $question->id) + ->see($answer->body) + ->press('VOTE') + ->seePageIs('questions/' . $question->id) + ->see('VOTED') + ->see('1'); + + $answer->delete(); + $question->delete(); + $user->delete(); + $member->delete(); + } + + /** + * test show question vote + * + * @return void + */ + public function testShowQuestionVoteUnvote() + { + $user = factory(User::class)->create(); + $member = factory(Member::class)->create(); + + $question = factory(question::class)->create([ + 'user_id' => $user->id + ]); + $answer = factory(answer::class)->create([ + 'is_admin' => 0, + 'member_id' => $member->id, + 'question_id' => $question->id + ]); + + Auth::guard('member')->login($member); + $response = $this->visit('questions') + ->click($question->topic) + ->seePageIs('questions/' . $question->id) + ->see($answer->body) + ->press('VOTE') + ->seePageIs('questions/' . $question->id) + ->see('VOTED') + ->see('1') + ->press('VOTED') + ->seePageIs('questions/' . $question->id) + ->see('VOTE') + ->see('0'); + + $answer->delete(); + $question->delete(); + $user->delete(); + $member->delete(); + } + + /** + * test show question add answer + * + * @return void + */ + public function testShowQuestionAddAnswer() + { + $user = factory(User::class)->create(); + $member = factory(Member::class)->create(); + + $question = factory(question::class)->create([ + 'user_id' => $user->id + ]); + + $answer = factory(answer::class)->make(); + + Auth::guard('member')->login($member); + $response = $this->visit('questions') + ->click($question->topic) + ->seePageIs('questions/' . $question->id) + ->type($answer->body, 'body') + ->press('Submit') + ->seePageIs('questions/' . $question->id) + ->see($answer->body); + + $dummy = Answer::where('body', $answer->body)->first(); + $dummy->delete(); + $question->delete(); + $user->delete(); + $member->delete(); + } + + /** + * test show answer + * + * @return void + */ + public function testShowEditAnswer() + { + $user = factory(User::class)->create(); + $member = factory(Member::class)->create(); + + $question = factory(question::class)->create([ + 'user_id' => $user->id + ]); + $answer = factory(answer::class)->create([ + 'is_admin' => 0, + 'member_id' => $member->id, + 'question_id' => $question->id + ]); + + Auth::guard('member')->login($member); + $response = $this->visit('answers/' . $answer->id) + ->click('Edit') + ->seePageIs('answers/' . $answer->id . '/edit') + ->see($question->body) + ->type($answer->body . ' Editted', 'body') + ->press('Submit') + ->seePageIs('answers/' . $answer->id) + ->see($question->topic) + ->see($question->body) + ->see($answer->body . ' Editted'); + + $answer->delete(); + $question->delete(); + $user->delete(); + $member->delete(); + } + + /** + * test show question + * + * @return void + */ + public function testShowEditAnswerOthers() + { + $member = factory(Member::class)->create(); + $member_dummy = factory(Member::class)->create(); + + $question = factory(question::class)->create([ + 'member_id' => $member->id, + 'is_admin' => 0 + ]); + + $answer = factory(answer::class)->create([ + 'is_admin' => 0, + 'member_id' => $member_dummy->id, + 'question_id' => $question->id + ]); + + Auth::guard('member')->login($member); + $response = $this->visit('answers/' . $answer->id) + ->dontSee('Delete'); + + $response = $this->visit('answers/' . $answer->id . '/edit') + ->seePageIs('/'); + + $answer->delete(); + $question->delete(); + $member->delete(); + $member_dummy->delete(); + } + }