Browse Source

Update 2016-12-20.22.23

Add vendor_id to subscriptions table
Add Event is_allday to user_events table
Add logfiles viewer for admin
pull/1/head
Nafies Luthfi 9 years ago
parent
commit
f0386a84bf
  1. 5
      app/Entities/BaseRepository.php
  2. 5
      app/Entities/Payments/Payment.php
  3. 5
      app/Entities/Subscriptions/Subscription.php
  4. 2
      app/Http/Controllers/Api/EventsController.php
  5. 6
      app/Http/Controllers/SubscriptionsController.php
  6. 2
      app/Http/Middleware/Authenticate.php
  7. 2
      app/Http/Middleware/RoleMiddleware.php
  8. 1
      config/app.php
  9. 15
      database/factories/ModelFactory.php
  10. 1
      resources/lang/id/subscription.php
  11. 2
      resources/views/auth/login.blade.php
  12. 2
      resources/views/layouts/guest.blade.php
  13. 4
      resources/views/payments/index.blade.php
  14. 8
      resources/views/projects/features-export-html.blade.php
  15. 2
      resources/views/projects/payments.blade.php
  16. 53
      resources/views/reports/log-files.blade.php
  17. 1
      resources/views/subscriptions/create.blade.php
  18. 1
      resources/views/subscriptions/edit.blade.php
  19. 9
      resources/views/subscriptions/index.blade.php
  20. 197
      resources/views/users/calendar-vue.blade.php
  21. 32
      resources/views/users/calendar.blade.php
  22. 2
      routes/web/account.php
  23. 13
      routes/web/calendar.php
  24. 28
      routes/web/reports.php
  25. 1
      tests/api/ApiEventsTest.php
  26. 8
      tests/auth/MemberChangePasswordTest.php
  27. 24
      tests/auth/MemberRegistrationAndLoginTest.php
  28. 7
      tests/auth/MemberResetPasswordTest.php
  29. 16
      tests/functional/ManageSubscriptionsTest.php

5
app/Entities/BaseRepository.php

@ -21,6 +21,11 @@ abstract class BaseRepository extends EloquentRepository {
return User::orderBy('name')->hasRoles(['worker'])->pluck('name','id');
}
public function getVendorsList()
{
return User::orderBy('name')->hasRoles(['vendor'])->pluck('name','id');
}
public function getProjectsList()
{
return Project::orderBy('name')->pluck('name','id');

5
app/Entities/Payments/Payment.php

@ -24,4 +24,9 @@ class Payment extends Model {
{
return $this->belongsTo(User::class, 'customer_id');
}
public function type()
{
return paymentTypes($this->type_id);
}
}

5
app/Entities/Subscriptions/Subscription.php

@ -25,6 +25,11 @@ class Subscription extends Model {
return $this->belongsTo(User::class,'customer_id');
}
public function vendor()
{
return $this->belongsTo(User::class,'vendor_id');
}
public function status()
{
return $this->status_id ? 'Aktif' : 'Non Aktif';

2
app/Http/Controllers/Api/EventsController.php

@ -89,6 +89,7 @@ class EventsController extends Controller
'id' => 'required|numeric|exists:user_events,id',
'title' => 'required|string|max:60',
'body' => 'string|max:255',
'is_allday' => '',
]);
$event = Event::findOrFail($request->get('id'));
@ -96,6 +97,7 @@ class EventsController extends Controller
$event->title = $request->get('title');
$event->body = $request->get('body');
$event->is_allday = !!$request->get('is_allday');
$event->save();

6
app/Http/Controllers/SubscriptionsController.php

@ -29,7 +29,8 @@ class SubscriptionsController extends Controller {
{
$projects = $this->repo->getProjectsList();
$customers = $this->repo->getCustomersList();
return view('subscriptions.create', compact('projects','customers'));
$vendors = $this->repo->getVendorsList();
return view('subscriptions.create', compact('projects','customers','vendors'));
}
public function store(CreateRequest $req)
@ -50,7 +51,8 @@ class SubscriptionsController extends Controller {
$subscription = $this->repo->requireById($subscriptionId);
$projects = $this->repo->getProjectsList();
$customers = $this->repo->getCustomersList();
return view('subscriptions.edit',compact('subscription','projects','customers'));
$vendors = $this->repo->getVendorsList();
return view('subscriptions.edit',compact('subscription','projects','customers','vendors'));
}
public function update(UpdateRequest $req, $subscriptionId)

2
app/Http/Middleware/Authenticate.php

@ -21,7 +21,7 @@ class Authenticate
if ($request->ajax() || $request->wantsJson()) {
return response('Unauthorized.', 401);
} else {
return redirect()->guest('auth/login');
return redirect()->guest('login');
}
}

2
app/Http/Middleware/RoleMiddleware.php

@ -18,7 +18,7 @@ class RoleMiddleware
$nameArray = explode('|', $names);
if (auth()->check() == false) {
return redirect()->guest('auth/login');
return redirect()->guest('login');
}
// Cek apakah grup user ada di dalam array $nameArray?

1
config/app.php

@ -109,6 +109,7 @@ return [
*/
'log' => env('APP_LOG', 'daily'),
'log_max_files' => 30,
/*
|--------------------------------------------------------------------------

15
database/factories/ModelFactory.php

@ -8,17 +8,6 @@ use App\Entities\Subscriptions\Subscription;
use App\Entities\Users\Event;
use App\Entities\Users\User;
/*
|--------------------------------------------------------------------------
| Model Factories
|--------------------------------------------------------------------------
|
| Here you may define all of your model factories. Model factories give
| you a convenient way to create models for testing and seeding your
| database. Just tell the factory how a default model should look.
|
*/
$factory->define(User::class, function (Faker\Generator $faker) {
return [
'name' => $faker->name,
@ -73,6 +62,9 @@ $factory->define(Subscription::class, function (Faker\Generator $faker) {
$customer = factory(User::class)->create();
$customer->assignRole('customer');
$customerId = $customer->id;
$vendor = factory(User::class)->create();
$vendor->assignRole('vendor');
$vendorId = $vendor->id;
$startDate = Carbon::parse($faker->dateTimeBetween('-1 year', '-1 month')->format('Y-m-d'));
return [
@ -87,6 +79,7 @@ $factory->define(Subscription::class, function (Faker\Generator $faker) {
'due_date' => $startDate->addYears(1)->format('Y-m-d'),
'remark' => $faker->paragraph,
'customer_id' => $customerId,
'vendor_id' => $vendorId,
];
});

1
resources/lang/id/subscription.php

@ -28,4 +28,5 @@ return [
'back_to_index' => 'Kembali ke daftar Langganan',
'customer' => 'Customer',
'project' => 'Project',
'vendor' => 'Vendor',
];

2
resources/views/auth/login.blade.php

@ -3,6 +3,7 @@
@section('title', trans('auth.login'))
@section('content')
@include('flash::message')
<div class="login-panel col-md-4 col-md-offset-4">
<div class="text-center">
<img src="{{ url('assets/imgs/logo.png') }}" alt="Logo {{ Option::get('app_owner') }}">
@ -10,7 +11,6 @@
<h3 class="text-center">{{ Option::get('app_name','Aplikasi Laravel') }}</h3>
<div class="panel panel-default">
<div class="panel-body">
@include('flash::message')
@include('auth.partials._errors')
{!! Form::open(['route'=>'auth.login']) !!}
<div class="form-group {!! $errors->has('username') ? 'has-error' : ''; !!}">

2
resources/views/layouts/guest.blade.php

@ -13,7 +13,7 @@
{{-- {!! Html::style('assets/css/bootstrap-theme.min.css') !!} --}}
{{-- {!! Html::style('assets/css/font-awesome.min.css') !!} --}}
{{-- {!! Html::style('assets/css/sb-admin-2.css') !!} --}}
{!! Html::style('assets/css/app.css') !!}
{!! Html::style('assets/css/app.s.css') !!}
@yield('ext_css')
</head>
<body>

4
resources/views/payments/index.blade.php

@ -29,9 +29,9 @@
@forelse($payments as $key => $payment)
<tr>
<td>{{ $payments->firstItem() + $key }}</td>
<td>{!! link_to_route('projects.payments', $payment->project->name, [$payment->project_id], ['title' => 'Lihat seluruh Pembayaran Project ini']) !!}</td>
<td>{!! link_to_route('projects.payments', $payment->project->name, [$payment->project_id], ['title' => 'Lihat seluruh Pembayaran Project ini']) !!} [{{ $payment->type() }}]</td>
<td class="text-center">{{ $payment->date }}</td>
<td class="text-right">{{ formatRp($payment->amount) }}</td>
<td class="text-right">{{ $payment->present()->amount }}</td>
<td>{{ $payment->description }}</td>
<td>{{ $payment->customer->name }}</td>
<td>

8
resources/views/projects/features-export-html.blade.php

@ -10,15 +10,15 @@
{{-- <meta http-equiv="X-UA-Compatible" content="IE=edge"> --}}
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>{{ $project->name }}</title>
{!! Html::style('assets/css/app.css') !!}
{!! Html::style('assets/css/app.s.css') !!}
</head>
<body>
<body style="font-family:'Liberation Serif'">
<div class="container">
<h1 class="page-header text-center">{{ trans('project.features') }} {{ $project->name }}</h1>
@foreach($features as $key => $feature)
<h2 class="feature-title">{{ $feature->name }}</h2>
<table class="table table-condensed table-bordered">
<table width="100%" class="table table-condensed table-bordered">
<tbody>
<tr style="background-color: #FFCC00"><th colspan="2">{{ trans('app.description') }}</th></tr>
<tr><td colspan="2">{!! nl2br($feature->description) !!}</td></tr>
@ -41,7 +41,7 @@
@endforeach
<h1 class="page-header text-center">Biaya Pembuatan</h1>
<table class="table table-condensed table-bordered">
<table width="100%" class="table table-condensed table-bordered">
<tbody>
<tr>
<th class="text-center">{{ trans('app.table_no') }}</th>

2
resources/views/projects/payments.blade.php

@ -37,7 +37,7 @@
<td class="text-center">{{ $payment->date }}</td>
<td class="text-right">{{ formatRp($payment->amount) }}</td>
<td>{{ $payment->customer->name }}</td>
<td>{{ $payment->description }}</td>
<td>{{ $payment->description }} [{{ $payment->type() }}]</td>
<td>{!! html_link_to_route('payments.show','',[$payment->id],['class' => 'btn btn-info btn-xs','icon' => 'search','title' => 'Lihat ' . trans('payment.show')]) !!}</td>
</tr>
@empty

53
resources/views/reports/log-files.blade.php

@ -0,0 +1,53 @@
@extends('layouts.app')
@section('title','Log Files')
@section('content')
<h3 class="page-header">
Log Files
</h3>
<div class="row">
<div class="col-md-8">
<div class="panel panel-default">
<table class="table table-condensed">
<thead>
<th>#</th>
<th>Nama File</th>
<th>Ukuran</th>
<th>Tanggal Jam</th>
<th>{{ trans('app.action') }}</th>
</thead>
<tbody>
@forelse($logFiles as $key => $logFile)
<tr>
<td>{{ $key + 1 }}</td>
<td>{{ $logFile->getFilename() }}</td>
<td>{{ formatSizeUnits($logFile->getSize()) }}</td>
<td>{{ date('Y-m-d H:i:s', $logFile->getMTime()) }}</td>
<td>
{!! html_link_to_route('log-files.download','',[$logFile->getFilename()],[
'class'=>'btn btn-default btn-xs',
'icon' => 'download',
'id' => 'download-' . $logFile->getFilename(),
'title' => 'Download file ' . $logFile->getFilename()
]) !!}
{!! html_link_to_route('log-files.show','',[$logFile->getFilename()],[
'class'=>'btn btn-default btn-xs',
'icon' => 'search',
'id' => 'view-' . $logFile->getFilename(),
'title' => 'View file ' . $logFile->getFilename(),
'target' => '_blank',
]) !!}
</td>
</tr>
@empty
<tr>
<td colspan="3">Belum ada file logFile</td>
</tr>
@endforelse
</tbody>
</table>
</div>
</div>
</div>
@endsection

1
resources/views/subscriptions/create.blade.php

@ -41,6 +41,7 @@
</div>
{!! FormField::select('customer_id', $customers,['label'=> trans('subscription.customer'),'value' => Request::get('customer_id')]) !!}
{!! FormField::select('project_id', $projects,['label'=> trans('subscription.project'),'value' => Request::get('project_id')]) !!}
{!! FormField::select('vendor_id', $vendors,['label'=> trans('subscription.vendor'),'value' => Request::get('vendor_id')]) !!}
{!! FormField::textarea('remark',['label'=> trans('subscription.remark')]) !!}
</div>

1
resources/views/subscriptions/edit.blade.php

@ -36,6 +36,7 @@
</div>
{!! FormField::select('customer_id', $customers,['label'=> trans('subscription.customer')]) !!}
{!! FormField::select('project_id', $projects,['label'=> trans('subscription.project')]) !!}
{!! FormField::select('vendor_id', $vendors,['label'=> trans('subscription.vendor')]) !!}
{!! FormField::radios('status_id', ['Non Active','Active'],['label'=> trans('app.status')]) !!}
{!! FormField::textarea('remark',['label'=> trans('subscription.remark')]) !!}
</div>

9
resources/views/subscriptions/index.blade.php

@ -20,7 +20,7 @@
<th>{{ trans('app.table_no') }}</th>
<th>{{ trans('subscription.domain_name') }}</th>
<th class="text-center">{{ trans('subscription.hosting_capacity') }}</th>
<th>{{ trans('subscription.start_date') }}</th>
<th>{{ trans('subscription.vendor') }}</th>
<th>{{ trans('subscription.due_date') }}</th>
<th class="text-right">{{ trans('subscription.extension_price') }}</th>
<th class="text-center">{{ trans('app.status') }}</th>
@ -32,8 +32,11 @@
<td>{{ $subscriptions->firstItem() + $key }}</td>
<td>{{ $subscription->domain_name }}</td>
<td class="text-center">{{ $subscription->hosting_capacity }}</td>
<td>{{ dateId($subscription->start_date) }}</td>
<td>{{ dateId($subscription->due_date) }}</td>
<td>{{ $subscription->vendor->name }}</td>
<td title="
{{ trans('subscription.start_date') }} : {{ dateId($subscription->start_date) }}
{{ trans('subscription.due_date') }} : {{ dateId($subscription->due_date) }}
">{{ dateId($subscription->due_date) }}</td>
<td class="text-right">{{ formatRp($subscription->domain_price + $subscription->hosting_price) }}</td>
<td class="text-center">{{ $subscription->status() }}</td>
<td>

197
resources/views/users/calendar-vue.blade.php

@ -0,0 +1,197 @@
@extends('layouts.app')
@section('title', 'Safety Calendar')
@section('content')
<div class="">
<div class="row">
<div class="col-md-12">
<div class="x_panel">
<div class="x_title"><h3>Safety Calendar <small>Click to add/edit events</small></h3></div>
<div class="x_content">
<div id='calendar'>
<div id="app" class="wrapper">
<calendar :events="events" :editable="true"></calendar>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
@endsection
@section('ext_css')
{!! Html::style(url('assets/css/plugins/fullcalendar.min.css')) !!}
@endsection
@section('ext_js')
{!! Html::script(url('assets/js/plugins/moment.min.js')) !!}
{!! Html::script(url('assets/js/plugins/fullcalendar.min.js')) !!}
{!! Html::script(url('assets/js/plugins/vue.min.js')) !!}
{!! Html::script(url('assets/js/plugins/vue-resource.min.js')) !!}
@endsection
@section('script')
<script>
Vue.component('calendar', {
template: '<div></div>',
props: {
events: {
type: Array,
required: true
},
editable: {
type: Boolean,
required: false,
default: false
},
droppable: {
type: Boolean,
required: false,
default: false
},
},
data: function()
{
return {
cal: null
}
},
ready: function()
{
var self = this;
self.cal = $(self.$el);
var args = {
lang: 'en',
header: {
left: 'prev,next today',
center: 'title',
right: 'month,agendaWeek,agendaDay'
},
height: "auto",
// allDaySlot: false,
slotEventOverlap: false,
timeFormat: 'HH:mm',
// events: self.events,
dayClick: function(date, data)
{
self.$dispatch('day::clicked', date, data);
},
eventClick: function(event)
{
self.$dispatch('event::clicked', event);
}
}
if (self.editable)
{
args.editable = true;
args.eventResize = function(event)
{
self.$dispatch('event::resized', event);
}
args.eventDrop = function(event)
{
self.$dispatch('event::dropped', event);
}
}
if (self.droppable)
{
args.droppable = true;
args.eventReceive = function(event)
{
self.$dispatch('event::received', event);
}
}
this.cal.fullCalendar(args);
}
})
new Vue({
el: '#calendar',
data: {
events: {
url: "{{ route('api.events.index') }}",
type: "GET",
error: function() {
alert('there was an error while fetching events!');
}
}
},
events: {
'day::clicked': function(date, data)
{
// var title = prompt('Event Title:', event.title, { buttons: { Ok: true, Cancel: false} });
console.log(data);
var title = event.title;
// var start = event.start.format("YYYY-MM-DD[T]HH:mm:SS");
var start = event.start;
// $.ajax({
// url: 'process.php',
// data: 'type=new&title='+title+'&startdate='+start+'&zone='+zone,
// type: 'POST',
// dataType: 'json',
// success: function(response){
// event.id = response.eventid;
// $('#calendar').fullCalendar('updateEvent',event);
// },
// error: function(e){
// console.log(e.responseText);
// }
// });
$('#calendar').fullCalendar('updateEvent',event);
// console.log(event);
console.log(date);
}
},
methods: {
fetchEvents: function() {
Vue.http.headers.common['Authorization'] = 'Bearer ' + "{{ auth()->user()->api_token }}";
// this.$http.get("{{ route('api.events.index') }}", function(data) {
// console.log(data);
// console.log([
// {
// title: 'Event1',
// start: '2016-11-10',
// },
// {
// title: 'Event2',
// start: '2016-11-07',
// }
// ]);
// this.$set('events', data);
// this.events = data;
// });
}
},
ready: function() {
this.fetchEvents();
}
})
</script>
@endsection

32
resources/views/users/calendar.blade.php

@ -94,7 +94,12 @@
<textarea class="form-control" style="height:55px;" id="descr2" name="descr2"></textarea>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label"></label>
<div class="col-sm-9">
<label for="is_allday2"><input id="is_allday2" type="checkbox" name="is_allday2"> All Day Event?</label>
</div>
</div>
</div>
</div>
<div class="modal-footer">
@ -134,16 +139,18 @@
var calendar = $('#calendar').fullCalendar({
header: {
left: 'prev,next today',
right: 'prev,next today',
center: 'title',
right: 'month,agendaWeek,agendaDay'
left: 'month,agendaWeek,agendaDay,listYear'
},
// defaultView: 'month',
height: 550,
selectable: true,
selectHelper: true,
droppable: false,
editable: false,
minTime: '06:00:00',
// eventLimit: true,
weekNumbers: true,
navLinks: true,
slotLabelFormat: 'HH:mm',
slotDuration: '01:00:00',
events: {
@ -153,11 +160,9 @@
alert('there was an error while fetching events!');
}
},
eventRender: function(calEvent, element) {
// element.find('.fc-content').prepend('<strong style="display:block">' + calEvent.user + '</strong>');
},
select: function(start, end, allDay) {
$('#fc_create').click();
// $('#fc_create').click();
$('#CalenderModalNew').modal('show');
started = start;
ended = end;
@ -199,7 +204,7 @@
calendar.fullCalendar('unselect');
$('.antoclose').click();
$('#CalenderModalNew').modal('hide');
return false;
});
@ -210,6 +215,7 @@
$('#user2').text(calEvent.user);
$('#title2').val(calEvent.title);
$('#descr2').val(calEvent.body);
$('#is_allday2').val(calEvent.allDay);
$('#CalenderModalEdit').modal();
}
else {
@ -243,17 +249,17 @@
}
$('#CalenderModalEdit').modal('hide');
$('#CalenderModalView').modal('hide');
});
$("#antoform2").off("submit").on("submit", function() {
calEvent.title = $("#title2").val();
calEvent.body = $("#descr2").val();
calEvent.is_allday = $("#is_allday2").is(':checked');
$.ajax({
url: "{{ route('api.events.update') }}",
method: "PATCH",
data: { id: calEvent.id, title: calEvent.title, body: calEvent.body },
data: { id: calEvent.id, title: calEvent.title, body: calEvent.body, is_allday: calEvent.is_allday },
success: function(response){
if(response.message == 'event.updated')
$('#calendar').fullCalendar('updateEvent',calEvent);
@ -308,6 +314,6 @@
}
});
})();
})();
</script>
@endsection

2
routes/web/account.php

@ -2,7 +2,7 @@
/**
* Account Routes
*/
Route::group(['prefix' => 'auth','middleware' => 'web','as'=>'auth.'], function() {
Route::group(['middleware' => 'web','as'=>'auth.'], function() {
Route::get('login', ['as'=>'login', 'uses' => 'AuthController@getLogin']);
Route::post('login', ['as'=>'login', 'uses' => 'AuthController@postLogin']);
Route::get('logout', ['as'=>'logout', 'uses' => 'AuthController@getLogout']);

13
routes/web/calendar.php

@ -7,15 +7,4 @@ Route::group(['middleware' => ['web','auth'], 'namespace' => 'Api'], function()
Route::get('my-calendar', ['as' => 'users.calendar', 'uses' => function() {
return view('users.calendar');
}]);
});
// Route::group(['middleware' => ['api','auth:api'], 'namespace' => 'Api'], function() {
// /**
// * Savety Calendar
// */
// Route::get('get-events', ['as' => 'api.events.index', 'uses' => 'EventsController@index']);
// Route::post('events', ['as' => 'api.events.store', 'uses' => 'EventsController@store']);
// Route::patch('events/update', ['as' => 'api.events.update', 'uses' => 'EventsController@update']);
// Route::patch('events/reschedule', ['as' => 'api.events.reschedule', 'uses' => 'EventsController@reschedule']);
// Route::delete('events/delete', ['as' => 'api.events.destroy', 'uses' => 'EventsController@destroy']);
// });
});

28
routes/web/reports.php

@ -9,4 +9,32 @@ Route::group(['middleware' => ['web','role:admin'],'prefix' => 'reports'], funct
Route::get('payments/monthly', ['as'=>'reports.payments.monthly', 'uses' => 'ReportsController@monthly']);
Route::get('payments/yearly', ['as'=>'reports.payments.yearly', 'uses' => 'ReportsController@yearly']);
Route::get('current-credits', ['as'=>'reports.current-credits', 'uses' => 'ReportsController@currentCredits']);
Route::get('log-files', ['as' => 'log-files.index', 'uses' => function() {
if (!file_exists(storage_path('logs')))
return [];
$logFiles = \File::allFiles(storage_path('logs'));
// Sort files by modified time DESC
usort($logFiles, function($a, $b) {
return -1 * strcmp($a->getMTime(), $b->getMTime());
});
return view('reports.log-files',compact('logFiles'));
}]);
Route::get('log-files/{filename}', ['as' => 'log-files.show', 'uses' => function($fileName) {
if (file_exists(storage_path('logs/' . $fileName)))
return response()->file(storage_path('logs/' . $fileName), ['content-type' => 'text/plain']);
return 'Invalid file name.';
}]);
Route::get('log-files/{filename}/download', ['as' => 'log-files.download', 'uses' => function($fileName) {
if (file_exists(storage_path('logs/' . $fileName)))
return response()->download(storage_path('logs/' . $fileName), env('APP_ENV') . '.' . $fileName);
return 'Invalid file name.';
}]);
});

1
tests/api/ApiEventsTest.php

@ -81,6 +81,7 @@ class ApiEventsTest extends TestCase
'id' => $event->id,
'title' => 'New Event Title',
'body' => 'New Event Body',
'is_allday' => 'true',
], [
'Authorization' => 'Bearer ' . $user->api_token
]);

8
tests/auth/MemberChangePasswordTest.php

@ -16,8 +16,8 @@ class MemberChangePasswordTest extends TestCase
$user->assignRole('customer');
$this->actingAs($user);
$this->visit('home');
$this->seePageIs('home');
$this->visit(route('home'));
$this->seePageIs(route('home'));
$this->click(trans('auth.change_password'));
$this->type('member1','old_password');
@ -34,10 +34,10 @@ class MemberChangePasswordTest extends TestCase
// Logout and login using new Password
$this->click('Keluar');
$this->seePageIs('auth/login');
$this->seePageIs(route('auth.login'));
$this->type($user->username,'username');
$this->type('rahasia','password');
$this->press('Login');
$this->seePageIs('home');
$this->seePageIs(route('home'));
}
}

24
tests/auth/MemberRegistrationAndLoginTest.php

@ -15,14 +15,14 @@ class MemberRegistrationAndLoginTest extends TestCase
$user = factory(User::class)->create(['email' => 'member@app.dev']);
$user->assignRole('customer');
$this->visit('/auth/register');
$this->visit(route('auth.register'));
$this->type('', 'name');
$this->type('', 'username');
$this->type('member@app.dev', 'email');
$this->type('', 'password');
$this->type('', 'password_confirmation');
$this->press('Buat Akun Baru');
$this->seePageIs('/auth/register');
$this->seePageIs(route('auth.register'));
$this->see('Nama harus diisi.');
$this->see('Username harus diisi.');
$this->see('Email ini sudah terdaftar.');
@ -35,7 +35,7 @@ class MemberRegistrationAndLoginTest extends TestCase
$this->type('password', 'password');
$this->type('password..', 'password_confirmation');
$this->press('Buat Akun Baru');
$this->seePageIs('/auth/register');
$this->seePageIs(route('auth.register'));
$this->see('Email tidak valid.');
$this->see('Konfirmasi password tidak sesuai.');
}
@ -43,50 +43,50 @@ class MemberRegistrationAndLoginTest extends TestCase
/** @test */
public function member_register_successfully()
{
$this->visit('/auth/register');
$this->visit(route('auth.register'));
$this->type('Nama Member', 'name');
$this->type('namamember', 'username');
$this->type('email@mail.com', 'email');
$this->type('password.111', 'password');
$this->type('password.111', 'password_confirmation');
$this->press('Buat Akun Baru');
$this->seePageIs('/home');
$this->seePageIs(route('home'));
$this->see('Selamat datang Nama Member.');
}
/** @test */
public function member_register_and_login_successfully()
{
$this->visit('/auth/register');
$this->visit(route('auth.register'));
$this->type('Nama Member', 'name');
$this->type('namamember', 'username');
$this->type('email@mail.com', 'email');
$this->type('password.111', 'password');
$this->type('password.111', 'password_confirmation');
$this->press('Buat Akun Baru');
$this->seePageIs('/home');
$this->seePageIs(route('home'));
$this->see('Selamat datang Nama Member.');
$this->click('Keluar');
$this->visit('/auth/login');
$this->visit(route('auth.login'));
$this->type('namamember','username');
$this->type('password.111','password');
$this->press('Login');
$this->seePageIs('/home');
$this->seePageIs(route('home'));
$this->see('Selamat datang kembali Nama Member.');
$this->click('Keluar');
$this->seePageIs('/auth/login');
$this->seePageIs(route('auth.login'));
$this->see('Anda telah logout.');
}
/** @test */
public function member_invalid_login()
{
$this->visit('/auth/login');
$this->visit(route('auth.login'));
$this->type('namamember','username');
$this->type('password.112','password');
$this->press('Login');
$this->seePageIs('/auth/login');
$this->seePageIs(route('auth.login'));
$this->see('Mohon maaf, anda tidak dapat login');
}
}

7
tests/auth/MemberResetPasswordTest.php

@ -48,8 +48,7 @@ class MemberResetPasswordTest extends TestCase
$this->type('rahasia','password_confirmation');
$this->press('Reset Password');
$this->seePageIs('home');
$this->seePageIs(route('home'));
$this->notSeeInDatabase('password_resets', [
'email' => $user->email
@ -57,11 +56,11 @@ class MemberResetPasswordTest extends TestCase
// Logout and login using new Password
$this->click('Keluar');
$this->seePageIs('auth/login');
$this->seePageIs(route('auth.login'));
$this->type($user->username,'username');
$this->type('rahasia','password');
$this->press('Login');
$this->seePageIs('home');
$this->seePageIs(route('home'));
}
}

16
tests/functional/ManageSubscriptionsTest.php

@ -23,6 +23,9 @@ class ManageSubscriptionsTest extends TestCase
$customer = factory(User::class)->create();
$customer->assignRole('customer');
$vendor = factory(User::class)->create();
$vendor->assignRole('vendor');
$this->visit('subscriptions');
$this->seePageIs('subscriptions');
$this->see(trans('subscription.subscriptions'));
@ -39,6 +42,7 @@ class ManageSubscriptionsTest extends TestCase
$this->type('2016-05-02','due_date');
$this->select($project->id, 'project_id');
$this->select($customer->id, 'customer_id');
$this->select($vendor->id, 'vendor_id');
$this->type('','remark');
$this->press(trans('subscription.create'));
@ -49,7 +53,9 @@ class ManageSubscriptionsTest extends TestCase
'domain_price' => 100000,
'status_id' => 1,
'start_date' => '2015-05-02',
'due_date' => '2016-05-02'
'due_date' => '2016-05-02',
'customer_id' => $customer->id,
'vendor_id' => $vendor->id,
]);
}
@ -65,6 +71,9 @@ class ManageSubscriptionsTest extends TestCase
$customer = factory(User::class)->create();
$customer->assignRole('customer');
$vendor = factory(User::class)->create();
$vendor->assignRole('vendor');
$subscription = factory(Subscription::class)->create(['customer_id' => $customer->id, 'project_id' => $project->id]);
$this->visit('subscriptions/' . $subscription->id . '/edit');
@ -76,6 +85,9 @@ class ManageSubscriptionsTest extends TestCase
$this->type(500000,'hosting_price');
$this->type('2015-05-02','start_date');
$this->type('2016-05-02','due_date');
$this->select($project->id, 'project_id');
$this->select($customer->id, 'customer_id');
$this->select($vendor->id, 'vendor_id');
$this->select(0,'status_id');
$this->press(trans('subscription.update'));
@ -90,6 +102,8 @@ class ManageSubscriptionsTest extends TestCase
'hosting_price' => '500000',
'start_date' => '2015-05-02',
'due_date' => '2016-05-02',
'customer_id' => $customer->id,
'vendor_id' => $vendor->id,
]);
}

Loading…
Cancel
Save