diff --git a/resources/views/backups/index.blade.php b/resources/views/backups/index.blade.php
index 8976fdc..32d931e 100644
--- a/resources/views/backups/index.blade.php
+++ b/resources/views/backups/index.blade.php
@@ -24,13 +24,13 @@
| {{ $key + 1 }} |
{{ $backup->getFilename() }} |
- {{ formatSizeUnits($backup->getSize()) }} |
+ {{ format_size_units($backup->getSize()) }} |
{{ date('Y-m-d H:i:s', $backup->getMTime()) }} |
+ title="{{ __('backup.restore') }}">
{{ $invoice->created_at->format('Y-m-d') }} |
{{ $invoice->project->nameLink() }} |
{{ $invoice->project->customer->nameLink() }} |
- {{ formatRp($invoice->amount) }} |
+ {{ format_money($invoice->amount) }} |
{!! html_link_to_route(
'invoices.show', '', [$invoice->number],
@@ -49,7 +49,7 @@
|
| {{ trans('app.total') }} |
- {{ formatRp($invoices->sum('amount')) }} |
+ {{ format_money($invoices->sum('amount')) }} |
|
diff --git a/resources/views/customers/payments.blade.php b/resources/views/customers/payments.blade.php
index 38364f8..66a584d 100755
--- a/resources/views/customers/payments.blade.php
+++ b/resources/views/customers/payments.blade.php
@@ -42,7 +42,7 @@
| {{ __('app.total') }} |
- {{ formatRp($payments->sum('amount')) }} |
+ {{ format_money($payments->sum('amount')) }} |
|
diff --git a/resources/views/customers/projects.blade.php b/resources/views/customers/projects.blade.php
index c426a79..c7eaa7b 100755
--- a/resources/views/customers/projects.blade.php
+++ b/resources/views/customers/projects.blade.php
@@ -21,7 +21,7 @@
{{ $project->nameLink() }} |
{{ $project->start_date }} |
{{ $project->work_duration }} |
-
{{ formatRp($project->project_value) }} |
+
{{ format_money($project->project_value) }} |
{{ $project->present()->status }} |
{!! html_link_to_route('projects.show', '', [$project->id], ['icon' => 'search', 'class' => 'btn btn-info btn-xs', 'title' => trans('app.show')]) !!}
diff --git a/resources/views/customers/subscriptions.blade.php b/resources/views/customers/subscriptions.blade.php
index b07c629..f7cefd0 100755
--- a/resources/views/customers/subscriptions.blade.php
+++ b/resources/views/customers/subscriptions.blade.php
@@ -20,13 +20,13 @@
@forelse($subscriptions as $key => $subscription)
|
| {{ 1 + $key }} |
- {{ $subscription->nameLink() }} |
+ {{ $subscription->name_link }} |
{!! $subscription->type_label !!} |
{{ $subscription->customer->name }} |
- {{ dateId($subscription->due_date) }} {!! $subscription->nearOfDueDateSign() !!}
+ {{ date_id($subscription->due_date) }} {!! $subscription->nearOfDueDateSign() !!}
|
- {{ formatRp($subscription->price) }} |
+ {{ format_money($subscription->price) }} |
{{ $subscription->vendor->name }} |
{{ $subscription->status() }} |
diff --git a/resources/views/invoice-drafts/partials/draft-confirm.blade.php b/resources/views/invoice-drafts/partials/draft-confirm.blade.php
index a8fbef3..eaef2f7 100644
--- a/resources/views/invoice-drafts/partials/draft-confirm.blade.php
+++ b/resources/views/invoice-drafts/partials/draft-confirm.blade.php
@@ -18,7 +18,7 @@
| {{ trans('invoice.due_date') }} | {{ $draft->dueDate }} |
| {{ trans('invoice.total') }} |
- {{ formatRp($draft->getTotal()) }} |
+ {{ format_money($draft->getTotal()) }} |
| {{ trans('invoice.notes') }} | {{ $draft->notes }} |
@@ -48,7 +48,7 @@
| {{ $key + 1 }} |
{!! nl2br($item->description) !!} |
- {{ formatRp($item->amount) }} |
+ {{ format_money($item->amount) }} |
@empty
@endforelse
@@ -56,7 +56,7 @@
| {{ trans('invoice.total') }} : |
- {{ formatRp($draft->getTotal()) }} |
+ {{ format_money($draft->getTotal()) }} |
diff --git a/resources/views/invoice-drafts/partials/draft-item-list.blade.php b/resources/views/invoice-drafts/partials/draft-item-list.blade.php
index 65f8217..eadf7f5 100644
--- a/resources/views/invoice-drafts/partials/draft-item-list.blade.php
+++ b/resources/views/invoice-drafts/partials/draft-item-list.blade.php
@@ -51,7 +51,7 @@
@endforeach
| {{ trans('invoice.amount') }} : |
- {{ formatRp($draft->getTotal()) }} |
+ {{ format_money($draft->getTotal()) }} |
|
diff --git a/resources/views/invoices/index.blade.php b/resources/views/invoices/index.blade.php
index b6c6f95..7a48368 100755
--- a/resources/views/invoices/index.blade.php
+++ b/resources/views/invoices/index.blade.php
@@ -34,7 +34,7 @@
| {{ $invoice->created_at->format('Y-m-d') }} |
{{ $invoice->project->nameLink() }} |
{{ $invoice->project->customer->nameLink() }} |
- {{ formatRp($invoice->amount) }} |
+ {{ format_money($invoice->amount) }} |
{!! html_link_to_route(
'invoices.show', '', [$invoice->number],
@@ -61,7 +61,7 @@
|
| {{ trans('app.total') }} |
- {{ formatRp($invoices->sum('amount')) }} |
+ {{ format_money($invoices->sum('amount')) }} |
|
diff --git a/resources/views/invoices/partials/detail.blade.php b/resources/views/invoices/partials/detail.blade.php
index eed4668..d613565 100644
--- a/resources/views/invoices/partials/detail.blade.php
+++ b/resources/views/invoices/partials/detail.blade.php
@@ -7,6 +7,6 @@
| {{ trans('invoice.customer') }} | {{ $invoice->project->customer->nameLink() }} |
| {{ trans('invoice.items_count') }} | {{ $invoice->items_count }} |
| {{ trans('invoice.creator') }} | {{ $invoice->creator->name }} |
|---|
-
| {{ trans('invoice.amount') }} | {{ formatRp($invoice->amount) }} |
|---|
+
| {{ trans('invoice.amount') }} | {{ format_money($invoice->amount) }} |
|---|
diff --git a/resources/views/invoices/partials/item-list.blade.php b/resources/views/invoices/partials/item-list.blade.php
index 7834873..5f3d09d 100644
--- a/resources/views/invoices/partials/item-list.blade.php
+++ b/resources/views/invoices/partials/item-list.blade.php
@@ -77,7 +77,7 @@
| {{ trans('invoice.amount') }} : |
- {{ formatRp(collect($invoice->items)->sum('amount')) }} |
+ {{ format_money(collect($invoice->items)->sum('amount')) }} |
|
diff --git a/resources/views/invoices/pdf.blade.php b/resources/views/invoices/pdf.blade.php
index c830812..a97f9dd 100755
--- a/resources/views/invoices/pdf.blade.php
+++ b/resources/views/invoices/pdf.blade.php
@@ -39,7 +39,7 @@
|
- {!! appLogoImage(['style' => 'width:100%']) !!}
+ {!! app_logo_image(['style' => 'width:100%']) !!}
|
@@ -61,7 +61,7 @@
{{ __('invoice.invoice') }}
{{ __('invoice.number') }} : INV-{{ $invoice->number }}
- {{ __('app.date') }} : {{ dateId($invoice->date) }}
+ {{ __('app.date') }} : {{ date_id($invoice->date) }}
|
|
@@ -87,7 +87,7 @@
@if ($invoice->due_date)
{{ __('invoice.due_date') }}
- {{ dateId($invoice->due_date) }}
+ {{ date_id($invoice->due_date) }}
@endif
@if ($taxId = Option::get('agency_tax_id'))
{{ __('agency.tax_id') }}
@@ -114,7 +114,7 @@
|
| {{ 1 + $key }} |
{!! nl2br($item['description']) !!} |
- {{ formatRp($item['amount']) }} |
+ {{ format_money($item['amount']) }} |
@php
$subtotal += $item['amount'];
@@ -123,19 +123,19 @@
@if ($invoice->discount)
| {{ __('invoice.subtotal') }} : |
- {{ formatRp($subtotal) }} |
+ {{ format_money($subtotal) }} |
|
{{ __('invoice.discount') }}
{{ $invoice->discount_notes ? '('.$invoice->discount_notes.')': '' }} :
|
- - {{ formatRp($invoice->discount) }} |
+ - {{ format_money($invoice->discount) }} |
@endif
| {{ __('app.total') }} |
- {{ formatRp($invoice->amount) }} |
+ {{ format_money($invoice->amount) }} |
@@ -176,7 +176,7 @@
{{ Option::get('agency_city') ? Option::get('agency_city').', ' : '' }}
- {{ dateId($invoice->date) }}
+ {{ date_id($invoice->date) }}
{{ Option::get('agency_name') }}
|
diff --git a/resources/views/invoices/show.blade.php b/resources/views/invoices/show.blade.php
index d0737b5..f96b3fc 100644
--- a/resources/views/invoices/show.blade.php
+++ b/resources/views/invoices/show.blade.php
@@ -39,7 +39,7 @@
| {{ $key + 1 }} |
{!! nl2br($item['description']) !!} |
- {{ formatRp($item['amount']) }} |
+ {{ format_money($item['amount']) }} |
@php
$subtotal += $item['amount'];
@@ -50,19 +50,19 @@
@if ($invoice->discount)
| {{ __('invoice.subtotal') }} : |
- {{ formatRp($subtotal) }} |
+ {{ format_money($subtotal) }} |
|
{{ __('invoice.discount') }}
{{ $invoice->discount_notes ? '('.$invoice->discount_notes.')': '' }} :
|
- - {{ formatRp($invoice->discount) }} |
+ - {{ format_money($invoice->discount) }} |
@endif
| {{ trans('app.total') }} : |
- {{ formatRp($invoice->amount) }} |
+ {{ format_money($invoice->amount) }} |
diff --git a/resources/views/jobs/partials/job-show.blade.php b/resources/views/jobs/partials/job-show.blade.php
index 36b993c..8f983a7 100644
--- a/resources/views/jobs/partials/job-show.blade.php
+++ b/resources/views/jobs/partials/job-show.blade.php
@@ -5,9 +5,9 @@
| {{ __('job.name') }} | {{ $job->name }} |
| {{ __('job.type') }} | {{ $job->type() }} |
|---|
@can('see-pricings', $job)
-
| {{ __('job.price') }} | {{ formatRp($job->price) }} |
|---|
+
| {{ __('job.price') }} | {{ format_money($job->price) }} |
|---|
@endcan
-
| {{ __('job.progress') }} | {{ formatDecimal($job->progress) }}% |
|---|
+
| {{ __('job.progress') }} | {{ format_decimal($job->progress) }}% |
| {{ __('job.worker') }} | {{ $job->worker->name }} |
| {{ __('time.updated_at') }} | {{ $job->updated_at }} |
| {{ __('job.description') }} | {!! nl2br($job->description) !!} |
|---|
diff --git a/resources/views/jobs/partials/job-tasks.blade.php b/resources/views/jobs/partials/job-tasks.blade.php
index ea906d0..20fe1d1 100644
--- a/resources/views/jobs/partials/job-tasks.blade.php
+++ b/resources/views/jobs/partials/job-tasks.blade.php
@@ -66,7 +66,7 @@
| {{ __('app.total') }} |
- {{ formatDecimal($job->tasks->avg('progress')) }} % |
+ {{ format_decimal($job->tasks->avg('progress')) }} % |
@if (request('action') == 'sort_tasks')
{{ link_to_route('jobs.show', __('app.done'), [$job], ['class' => 'btn btn-default btn-xs pull-right']) }}
diff --git a/resources/views/jobs/unfinished.blade.php b/resources/views/jobs/unfinished.blade.php
index 74dfcae..8d31f01 100755
--- a/resources/views/jobs/unfinished.blade.php
+++ b/resources/views/jobs/unfinished.blade.php
@@ -46,9 +46,9 @@
@endif
| {{ $job->tasks_count = $job->tasks->count() }} |
- {{ formatDecimal($job->progress) }} % |
+ {{ format_decimal($job->progress) }} % |
@can('see-pricings', $job)
- {{ formatRp($job->price) }} |
+ {{ format_money($job->price) }} |
@endcan
{{ $job->worker->name }} |
@@ -63,9 +63,9 @@
|
| {{ __('app.total') }} |
{{ $jobs->sum('tasks_count') }} |
- {{ formatDecimal($jobs->avg('progress')) }} % |
+ {{ format_decimal($jobs->avg('progress')) }} % |
@can('see-pricings', new App\Entities\Projects\Job)
- {{ formatRp($jobs->sum('price')) }} |
+ {{ format_money($jobs->sum('price')) }} |
@endcan
|
diff --git a/resources/views/layouts/partials/sidebar.blade.php b/resources/views/layouts/partials/sidebar.blade.php
index c41001c..bd27221 100755
--- a/resources/views/layouts/partials/sidebar.blade.php
+++ b/resources/views/layouts/partials/sidebar.blade.php
@@ -10,7 +10,7 @@
diff --git a/resources/views/reports/payments/year_to_year.blade.php b/resources/views/reports/payments/year_to_year.blade.php
new file mode 100755
index 0000000..2c075af
--- /dev/null
+++ b/resources/views/reports/payments/year_to_year.blade.php
@@ -0,0 +1,98 @@
+@extends('layouts.app')
+
+@section('title', __('report.year_to_year'))
+
+@section('content')
+
+ - {{ __('report.year_to_year') }}
+
+
+
+
{{ __('report.sales_graph') }}
+
+
{{ Option::get('money_sign', 'Rp') }}
+
+
{{ __('time.month') }}
+
+
+
+
+
{{ __('report.detail') }}
+
+
+
+ | {{ __('time.month') }} |
+ {{ __('payment.payment') }} |
+ {{ __('payment.cash_in') }} |
+ {{ __('payment.cash_out') }} |
+ {{ __('report.profit') }} |
+ {{ __('app.action') }} |
+
+
+ @php $chartData = []; @endphp
+ @foreach(get_years() as $year)
+ @php
+ $any = isset($reports[$year]);
+ @endphp
+
+ | {{ $year }} |
+ {{ $any ? $reports[$year]->count : 0 }} |
+ {{ format_money($any ? $reports[$year]->cashin : 0) }} |
+ {{ format_money($any ? $reports[$year]->cashout : 0) }} |
+ {{ format_money($profit = $any ? $reports[$year]->profit : 0) }} |
+
+ {{ link_to_route(
+ 'reports.payments.yearly',
+ __('report.view_yearly'),
+ ['month' => $year, 'year' => $year],
+ [
+ 'class' => 'btn btn-info btn-xs',
+ 'title' => __('report.yearly', ['year' => $year]),
+ ]
+ ) }}
+ |
+
+ @php
+ $chartData[] = ['year' => $year, 'value' => $profit];
+ @endphp
+ @endforeach
+
+
+
+ | {{ trans('app.total') }} |
+ {{ $reports->sum('count') }} |
+ {{ format_money($reports->sum('cashin')) }} |
+ {{ format_money($reports->sum('cashout')) }} |
+ {{ format_money($reports->sum('profit')) }} |
+ |
+
+
+
+
+
+@endsection
+
+@section('ext_css')
+ {{ Html::style(url('assets/css/plugins/morris.css')) }}
+@endsection
+
+@section('ext_js')
+ {{ Html::script(url('assets/js/plugins/morris/raphael.min.js')) }}
+ {{ Html::script(url('assets/js/plugins/morris/morris.min.js')) }}
+@endsection
+
+@section('script')
+
+@endsection
diff --git a/resources/views/reports/payments/yearly.blade.php b/resources/views/reports/payments/yearly.blade.php
index 2728cc9..b0c8de3 100755
--- a/resources/views/reports/payments/yearly.blade.php
+++ b/resources/views/reports/payments/yearly.blade.php
@@ -12,6 +12,7 @@
{{ Form::select('year', $years, $year, ['class' => 'form-control']) }}
{{ Form::submit(__('report.view_report'), ['class' => 'btn btn-info btn-sm']) }}
{{ link_to_route('reports.payments.yearly', __('report.this_year'), [], ['class' => 'btn btn-default btn-sm']) }}
+{{ link_to_route('reports.payments.year_to_year', __('report.view_year_to_year'), [], ['class' => 'btn btn-success btn-sm']) }}
{{ Form::close() }}
@@ -37,16 +38,16 @@
@php $chartData = []; @endphp
- @foreach(getMonths() as $monthNumber => $monthName)
+ @foreach(get_months() as $monthNumber => $monthName)
@php
$any = isset($reports[$monthNumber]);
@endphp
- | {{ monthId($monthNumber) }} |
+ {{ month_id($monthNumber) }} |
{{ $any ? $reports[$monthNumber]->count : 0 }} |
- {{ formatRp($any ? $reports[$monthNumber]->cashin : 0) }} |
- {{ formatRp($any ? $reports[$monthNumber]->cashout : 0) }} |
- {{ formatRp($profit = $any ? $reports[$monthNumber]->profit : 0) }} |
+ {{ format_money($any ? $reports[$monthNumber]->cashin : 0) }} |
+ {{ format_money($any ? $reports[$monthNumber]->cashout : 0) }} |
+ {{ format_money($profit = $any ? $reports[$monthNumber]->profit : 0) }} |
{{ link_to_route(
'reports.payments.monthly',
@@ -54,14 +55,14 @@
['month' => $monthNumber, 'year' => $year],
[
'class' => 'btn btn-info btn-xs',
- 'title' => __('report.monthly', ['year_month' => monthId($monthNumber)]),
- 'title' => __('report.monthly', ['year_month' => monthId($monthNumber).' '.$year]),
+ 'title' => __('report.monthly', ['year_month' => month_id($monthNumber)]),
+ 'title' => __('report.monthly', ['year_month' => month_id($monthNumber).' '.$year]),
]
) }}
|
@php
- $chartData[] = ['month' => monthId($monthNumber), 'value' => $profit];
+ $chartData[] = ['month' => month_id($monthNumber), 'value' => $profit];
@endphp
@endforeach
@@ -69,9 +70,9 @@
| {{ trans('app.total') }} |
{{ $reports->sum('count') }} |
- {{ formatRp($reports->sum('cashin')) }} |
- {{ formatRp($reports->sum('cashout')) }} |
- {{ formatRp($reports->sum('profit')) }} |
+ {{ format_money($reports->sum('cashin')) }} |
+ {{ format_money($reports->sum('cashout')) }} |
+ {{ format_money($reports->sum('profit')) }} |
|
diff --git a/resources/views/subscriptions/index.blade.php b/resources/views/subscriptions/index.blade.php
index e93be92..49c9c09 100755
--- a/resources/views/subscriptions/index.blade.php
+++ b/resources/views/subscriptions/index.blade.php
@@ -30,13 +30,13 @@
@forelse($subscriptions as $key => $subscription)
| {{ $subscriptions->firstItem() + $key }} |
- {{ $subscription->nameLink() }} |
+ {{ $subscription->name_link }} |
{!! $subscription->type_label !!} |
{{ $subscription->customer->name }} |
- {{ dateId($subscription->due_date) }} {!! $subscription->nearOfDueDateSign() !!}
+ {{ date_id($subscription->due_date) }} {!! $subscription->nearOfDueDateSign() !!}
|
- {{ formatRp($subscription->price) }} |
+ {{ format_money($subscription->price) }} |
{{ $subscription->vendor->name }} |
{{ $subscription->status() }} |
diff --git a/resources/views/subscriptions/partials/breadcrumb.blade.php b/resources/views/subscriptions/partials/breadcrumb.blade.php
index 02ed975..5d18636 100644
--- a/resources/views/subscriptions/partials/breadcrumb.blade.php
+++ b/resources/views/subscriptions/partials/breadcrumb.blade.php
@@ -1,5 +1,5 @@
- {{ link_to_route('subscriptions.index',trans('subscription.list')) }}
- - {{ $subscription->nameLink() }}
+ - {{ $subscription->name_link }}
- {{ isset($title) ? $title : trans('subscription.detail') }}
diff --git a/resources/views/subscriptions/partials/subscription-show.blade.php b/resources/views/subscriptions/partials/subscription-show.blade.php
index 8234b9c..7d4f422 100644
--- a/resources/views/subscriptions/partials/subscription-show.blade.php
+++ b/resources/views/subscriptions/partials/subscription-show.blade.php
@@ -1,10 +1,10 @@
| {{ trans('subscription.name') }} | {{ $subscription->name }} |
- | {{ trans('subscription.price') }} | {{ formatRp($subscription->price) }} |
+ | {{ trans('subscription.price') }} | {{ format_money($subscription->price) }} |
| {{ trans('subscription.type') }} | {{ $subscription->type }} |
- | {{ trans('subscription.start_date') }} | {{ dateId($subscription->start_date) }} |
- | {{ trans('subscription.due_date') }} | {{ dateId($subscription->due_date) }} |
+ | {{ trans('subscription.start_date') }} | {{ date_id($subscription->start_date) }} |
+ | {{ trans('subscription.due_date') }} | {{ date_id($subscription->due_date) }} |
| {{ trans('subscription.customer') }} | {{ $subscription->customer->nameLink() }} |
| {{ trans('subscription.project') }} |
diff --git a/resources/views/users/agency/edit.blade.php b/resources/views/users/agency/edit.blade.php
index 5b430b2..77bbdd1 100644
--- a/resources/views/users/agency/edit.blade.php
+++ b/resources/views/users/agency/edit.blade.php
@@ -31,7 +31,7 @@
{{ Form::open(['route' => 'users.agency.logo-upload', 'method' => 'patch', 'files' => true]) }}
-
{!! appLogoImage(['style' => 'margin:20px auto']) !!}
+
{!! app_logo_image(['style' => 'margin:20px auto']) !!}
{!! FormField::file('logo', [
'label' => __('agency.logo_change'),
'info' => ['text' => __('agency.logo_upload_info'), 'class' => 'warning'],
diff --git a/resources/views/users/agency/show.blade.php b/resources/views/users/agency/show.blade.php
index 9507913..b74473a 100644
--- a/resources/views/users/agency/show.blade.php
+++ b/resources/views/users/agency/show.blade.php
@@ -6,7 +6,7 @@
-
{!! appLogoImage() !!}
+
{!! app_logo_image() !!}
{{ Option::get('agency_name') }}
{{ Option::get('agency_tagline') }}
diff --git a/resources/views/users/jobs.blade.php b/resources/views/users/jobs.blade.php
index 6a2f113..682875d 100755
--- a/resources/views/users/jobs.blade.php
+++ b/resources/views/users/jobs.blade.php
@@ -33,8 +33,8 @@
@endif
{{ $job->tasks_count = $job->tasks->count() }} |
-
{{ formatDecimal($job->progress = $job->progress) }} % |
-
{{ formatRp($job->price) }} |
+
{{ format_decimal($job->progress = $job->progress) }} % |
+
{{ format_money($job->price) }} |
{!! html_link_to_route('jobs.show', '', [$job], [
'icon' => 'search',
diff --git a/resources/views/users/projects.blade.php b/resources/views/users/projects.blade.php
index 34e1075..9c625d2 100755
--- a/resources/views/users/projects.blade.php
+++ b/resources/views/users/projects.blade.php
@@ -30,7 +30,7 @@
| {{ $project->nameLink() }} |
{{ $project->start_date }} |
{{ $project->work_duration }} |
-
{{ formatRp($project->project_value) }} |
+
{{ format_money($project->project_value) }} |
{{ $project->present()->status }} |
{{ $project->customer->name }} |
diff --git a/resources/views/vendors/show.blade.php b/resources/views/vendors/show.blade.php
index 953dc32..1f0db62 100755
--- a/resources/views/vendors/show.blade.php
+++ b/resources/views/vendors/show.blade.php
@@ -44,7 +44,7 @@
| {{ 1 + $key }} |
{{ $payment->project->name }} |
{{ $payment->date }} |
-
{{ formatRp($payment->amount) }} |
+
{{ format_money($payment->amount) }} |
{{ $payment->description }} |
@endforeach
@@ -52,7 +52,7 @@
| {{ __('app.total') }} |
- {{ formatRp($vendor->payments->sum('amount')) }} |
+ {{ format_money($vendor->payments->sum('amount')) }} |
|
diff --git a/routes/api.php b/routes/api.php
index df7f5ca..0b188cf 100644
--- a/routes/api.php
+++ b/routes/api.php
@@ -10,4 +10,14 @@ Route::group(['prefix' => 'v1', 'namespace' => 'Api', 'as' => 'api.', 'middlewar
Route::patch('events/update', ['as' => 'events.update', 'uses' => 'EventsController@update']);
Route::patch('events/reschedule', ['as' => 'events.reschedule', 'uses' => 'EventsController@reschedule']);
Route::delete('events/delete', ['as' => 'events.destroy', 'uses' => 'EventsController@destroy']);
+
+ /*
+ * Customer Route
+ */
+ Route::post('customers', 'CustomerController@index')->name('customers.index');
+
+ /*
+ * Vendor Route
+ */
+ Route::post('vendors', 'VendorController@index')->name('vendors.index');
});
diff --git a/routes/web/calendar.php b/routes/web/calendar.php
index de6229b..b3b60d1 100644
--- a/routes/web/calendar.php
+++ b/routes/web/calendar.php
@@ -1,18 +1,8 @@
['web', 'auth'], 'namespace' => 'Api'], function () {
+Route::group(['middleware' => ['web', 'auth'], 'namespace' => 'Users'], function () {
/*
- * Savety Calendar
+ * User Calendar Route
*/
- Route::get('my-calendar', ['as' => 'users.calendar', 'uses' => function () {
- $user = auth()->user();
-
- if ($user->hasRole('admin') == false) {
- $projects = $user->projects()->orderBy('projects.name')->pluck('projects.name', 'projects.id');
- } else {
- $projects = App\Entities\Projects\Project::orderBy('name')->pluck('name', 'id');
- }
-
- return view('users.calendar', compact('projects'));
- }]);
+ Route::get('my-calendar', 'CalendarController@index')->name('users.calendar');
});
diff --git a/routes/web/projects.php b/routes/web/projects.php
index c51d41e..e31823c 100644
--- a/routes/web/projects.php
+++ b/routes/web/projects.php
@@ -46,6 +46,17 @@ Route::group(['middleware' => ['auth'], 'namespace' => 'Projects'], function ()
Route::delete('projects/{project}/comments/{comment}', 'CommentsController@destroy')->name('projects.comments.destroy');
/*
+ * Project Issues Routes
+ */
+ Route::get('projects/{project}/issues', 'IssueController@index')->name('projects.issues.index');
+ Route::get('projects/{project}/issues/create', 'IssueController@create')->name('projects.issues.create');
+ Route::post('projects/{project}/issues', 'IssueController@store')->name('projects.issues.store');
+ Route::get('projects/{project}/issues/{issue}', 'IssueController@show')->name('projects.issues.show');
+ Route::get('projects/{project}/issues/{issue}/edit', 'IssueController@edit')->name('projects.issues.edit');
+ Route::patch('projects/{project}/issues/{issue}', 'IssueController@update')->name('projects.issues.update');
+ Route::delete('projects/{project}/issues/{issue}', 'IssueController@destroy')->name('projects.issues.destroy');
+
+ /*
* Tasks Routes
*/
Route::get('jobs/{job}/tasks/create', ['as' => 'tasks.create', 'uses' => 'TasksController@create']);
@@ -61,6 +72,7 @@ Route::group(['middleware' => ['auth'], 'namespace' => 'Projects'], function ()
Route::post('files/{fileable}', ['as' => 'files.upload', 'uses' => 'FilesController@create']);
Route::get('files/{file}', ['as' => 'files.download', 'uses' => 'FilesController@show']);
Route::patch('files/{file}', ['as' => 'files.update', 'uses' => 'FilesController@update']);
+ Route::delete('files/{file}', ['as' => 'files.destroy', 'uses' => 'FilesController@destroy']);
});
Route::group(['middleware' => ['auth']], function () {
@@ -88,3 +100,15 @@ Route::group(['middleware' => ['auth']], function () {
Route::patch('jobs/{job}/comments/{comment}', 'Jobs\CommentsController@update')->name('jobs.comments.update');
Route::delete('jobs/{job}/comments/{comment}', 'Jobs\CommentsController@destroy')->name('jobs.comments.destroy');
});
+
+/*
+ * Issue Options Routes
+ */
+Route::patch('issues/{issue}/options', 'Issues\OptionController@update')->name('issues.options.update');
+
+/*
+ * Issue Comments Routes
+ */
+Route::post('issues/{issue}/comments', 'Issues\CommentController@store')->name('issues.comments.store');
+Route::patch('issues/{issue}/comments/{comment}', 'Issues\CommentController@update')->name('issues.comments.update');
+Route::delete('issues/{issue}/comments/{comment}', 'Issues\CommentController@destroy')->name('issues.comments.destroy');
diff --git a/routes/web/reports.php b/routes/web/reports.php
index 2d4d867..8c37e6b 100644
--- a/routes/web/reports.php
+++ b/routes/web/reports.php
@@ -4,40 +4,17 @@ Route::group(['middleware' => ['web', 'role:admin'], 'prefix' => 'reports'], fun
/*
* Reports Routes
*/
- Route::get('payments', ['as' => 'reports.payments.index', 'uses' => 'ReportsController@monthly']);
- Route::get('payments/daily', ['as' => 'reports.payments.daily', 'uses' => 'ReportsController@daily']);
- 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('payments', 'ReportsController@monthly')->name('reports.payments.index');
+ Route::get('payments/daily', 'ReportsController@daily')->name('reports.payments.daily');
+ Route::get('payments/monthly', 'ReportsController@monthly')->name('reports.payments.monthly');
+ Route::get('payments/yearly', 'ReportsController@yearly')->name('reports.payments.yearly');
+ Route::get('payments/year_to_year', 'ReportsController@yearToYear')->name('reports.payments.year_to_year');
+ Route::get('current-credits', 'ReportsController@currentCredits')->name('reports.current-credits');
- 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.';
- }]);
+ /*
+ * Log Files Routes
+ */
+ Route::get('log-files', 'Reports\LogFileController@index')->name('log-files.index');
+ Route::get('log-files/{fileName}', 'Reports\LogFileController@show')->name('log-files.show');
+ Route::get('log-files/{fileName}/download', 'Reports\LogFileController@download')->name('log-files.download');
});
diff --git a/tests/Feature/AgencyProfileTest.php b/tests/Feature/AgencyProfileTest.php
index df87083..ac7cd88 100644
--- a/tests/Feature/AgencyProfileTest.php
+++ b/tests/Feature/AgencyProfileTest.php
@@ -3,7 +3,7 @@
namespace Tests\Feature\Users;
use Tests\TestCase;
-use Illuminate\Foundation\Testing\DatabaseMigrations;
+use Illuminate\Foundation\Testing\RefreshDatabase;
/**
* Agency Profile Feature Test.
@@ -12,7 +12,7 @@ use Illuminate\Foundation\Testing\DatabaseMigrations;
*/
class AgencyProfileTest extends TestCase
{
- use DatabaseMigrations;
+ use RefreshDatabase;
/** @test */
public function admin_user_can_visit_agency_page()
diff --git a/tests/Feature/Api/ApiEventsTest.php b/tests/Feature/Api/ApiEventsTest.php
index 2c20f10..8dc0adf 100644
--- a/tests/Feature/Api/ApiEventsTest.php
+++ b/tests/Feature/Api/ApiEventsTest.php
@@ -6,7 +6,7 @@ use Tests\TestCase;
use App\Entities\Users\User;
use App\Entities\Users\Event;
use App\Entities\Projects\Project;
-use Illuminate\Foundation\Testing\DatabaseMigrations;
+use Illuminate\Foundation\Testing\RefreshDatabase;
/**
* Manage Events API Feature Test.
@@ -15,7 +15,7 @@ use Illuminate\Foundation\Testing\DatabaseMigrations;
*/
class ApiEventsTest extends TestCase
{
- use DatabaseMigrations;
+ use RefreshDatabase;
/** @test */
public function it_can_get_all_existing_events()
diff --git a/tests/Feature/Api/ApiManageProjectsTest.php b/tests/Feature/Api/ApiManageProjectsTest.php
index baac1a2..a19f013 100644
--- a/tests/Feature/Api/ApiManageProjectsTest.php
+++ b/tests/Feature/Api/ApiManageProjectsTest.php
@@ -4,7 +4,7 @@ namespace Tests\Feature\Api;
use Tests\TestCase;
use App\Entities\Projects\Project;
-use Illuminate\Foundation\Testing\DatabaseMigrations;
+use Illuminate\Foundation\Testing\RefreshDatabase;
/**
* Manage Projects API Feature Test.
@@ -13,7 +13,7 @@ use Illuminate\Foundation\Testing\DatabaseMigrations;
*/
class ApiManageProjectsTest extends TestCase
{
- use DatabaseMigrations;
+ use RefreshDatabase;
/** @test */
public function user_can_get_project_lists()
diff --git a/tests/Feature/Api/FetchPartnerListTest.php b/tests/Feature/Api/FetchPartnerListTest.php
new file mode 100644
index 0000000..44a08cd
--- /dev/null
+++ b/tests/Feature/Api/FetchPartnerListTest.php
@@ -0,0 +1,43 @@
+createUser('admin');
+ $customer = factory(Customer::class)->create();
+
+ $this->postJson(route('api.customers.index'), [], [
+ 'Authorization' => 'Bearer '.$user->api_token,
+ ]);
+
+ $this->seeJson([
+ $customer->id => $customer->name,
+ ]);
+ }
+
+ /** @test */
+ public function user_can_fetch_vendor_listing()
+ {
+ $user = $this->createUser('admin');
+ $vendor = factory(Vendor::class)->create();
+
+ $this->postJson(route('api.vendors.index'), [], [
+ 'Authorization' => 'Bearer '.$user->api_token,
+ ]);
+
+ $this->seeJson([
+ $vendor->id => $vendor->name,
+ ]);
+ }
+}
diff --git a/tests/Feature/Api/Projects/ReorderJobListTest.php b/tests/Feature/Api/Projects/ReorderJobListTest.php
index 0645922..aed6a35 100644
--- a/tests/Feature/Api/Projects/ReorderJobListTest.php
+++ b/tests/Feature/Api/Projects/ReorderJobListTest.php
@@ -5,11 +5,11 @@ namespace Tests\Feature\Api\Projects;
use Tests\TestCase;
use App\Entities\Projects\Job;
use App\Entities\Projects\Project;
-use Illuminate\Foundation\Testing\DatabaseMigrations;
+use Illuminate\Foundation\Testing\RefreshDatabase;
class ReorderJobListTest extends TestCase
{
- use DatabaseMigrations;
+ use RefreshDatabase;
/** @test */
public function admin_can_reorder_job_position()
diff --git a/tests/Feature/Api/Projects/ReorderTaskListTest.php b/tests/Feature/Api/Projects/ReorderTaskListTest.php
index 70a2cef..df1df39 100644
--- a/tests/Feature/Api/Projects/ReorderTaskListTest.php
+++ b/tests/Feature/Api/Projects/ReorderTaskListTest.php
@@ -5,11 +5,11 @@ namespace Tests\Feature\Api\Projects;
use Tests\TestCase;
use App\Entities\Projects\Task;
use App\Entities\Projects\Project;
-use Illuminate\Foundation\Testing\DatabaseMigrations;
+use Illuminate\Foundation\Testing\RefreshDatabase;
class ReorderTaskListTest extends TestCase
{
- use DatabaseMigrations;
+ use RefreshDatabase;
/** @test */
public function admin_can_reorder_task_position()
diff --git a/tests/Feature/Auth/ChangePasswordTest.php b/tests/Feature/Auth/ChangePasswordTest.php
index b57416f..8cee67f 100644
--- a/tests/Feature/Auth/ChangePasswordTest.php
+++ b/tests/Feature/Auth/ChangePasswordTest.php
@@ -3,11 +3,11 @@
namespace Tests\Feature\Auth;
use Tests\TestCase;
-use Illuminate\Foundation\Testing\DatabaseMigrations;
+use Illuminate\Foundation\Testing\RefreshDatabase;
class ChangePasswordTest extends TestCase
{
- use DatabaseMigrations;
+ use RefreshDatabase;
/** @test */
public function member_can_change_password()
diff --git a/tests/Feature/Auth/LoginTest.php b/tests/Feature/Auth/LoginTest.php
index 531ea53..a96c141 100644
--- a/tests/Feature/Auth/LoginTest.php
+++ b/tests/Feature/Auth/LoginTest.php
@@ -4,11 +4,11 @@ namespace Tests\Feature\Auth;
use Tests\TestCase;
use App\Entities\Users\User;
-use Illuminate\Foundation\Testing\DatabaseMigrations;
+use Illuminate\Foundation\Testing\RefreshDatabase;
class LoginTest extends TestCase
{
- use DatabaseMigrations;
+ use RefreshDatabase;
/** @test */
public function user_can_login_and_logout()
diff --git a/tests/Feature/Auth/ResetPasswordTest.php b/tests/Feature/Auth/ResetPasswordTest.php
index 9d43bca..65f86b0 100644
--- a/tests/Feature/Auth/ResetPasswordTest.php
+++ b/tests/Feature/Auth/ResetPasswordTest.php
@@ -5,11 +5,11 @@ namespace Tests\Feature\Auth;
use Notification;
use Tests\TestCase;
use App\Entities\Users\User;
-use Illuminate\Foundation\Testing\DatabaseMigrations;
+use Illuminate\Foundation\Testing\RefreshDatabase;
class ResetPasswordTest extends TestCase
{
- use DatabaseMigrations;
+ use RefreshDatabase;
/** @test */
public function user_can_reset_password_by_their_email()
diff --git a/tests/Feature/InstallationTest.php b/tests/Feature/InstallationTest.php
index 496ea21..4d1f711 100644
--- a/tests/Feature/InstallationTest.php
+++ b/tests/Feature/InstallationTest.php
@@ -4,7 +4,7 @@ namespace Tests\Feature;
use Tests\TestCase;
use App\Entities\Users\User;
-use Illuminate\Foundation\Testing\DatabaseMigrations;
+use Illuminate\Foundation\Testing\RefreshDatabase;
/**
* Installation Feature Test.
@@ -13,7 +13,7 @@ use Illuminate\Foundation\Testing\DatabaseMigrations;
*/
class InstallationTest extends TestCase
{
- use DatabaseMigrations;
+ use RefreshDatabase;
/** @test */
public function user_cannot_visit_install_page_if_user_already_exists_in_database()
diff --git a/tests/Feature/Invoices/InvoiceDuplicateTest.php b/tests/Feature/Invoices/InvoiceDuplicateTest.php
index 509ac12..742e9f0 100644
--- a/tests/Feature/Invoices/InvoiceDuplicateTest.php
+++ b/tests/Feature/Invoices/InvoiceDuplicateTest.php
@@ -4,7 +4,7 @@ namespace Tests\Feature\Invoices;
use Tests\TestCase;
use App\Entities\Invoices\Invoice;
-use Illuminate\Foundation\Testing\DatabaseMigrations;
+use Illuminate\Foundation\Testing\RefreshDatabase;
use App\Services\InvoiceDrafts\InvoiceDraftCollection;
/**
@@ -14,7 +14,7 @@ use App\Services\InvoiceDrafts\InvoiceDraftCollection;
*/
class InvoiceDuplicateTest extends TestCase
{
- use DatabaseMigrations;
+ use RefreshDatabase;
/** @test */
public function user_can_create_invoice_draft_by_duplicate_existing_invoice()
diff --git a/tests/Feature/Invoices/InvoiceEntryTest.php b/tests/Feature/Invoices/InvoiceEntryTest.php
index b635e7b..deff901 100644
--- a/tests/Feature/Invoices/InvoiceEntryTest.php
+++ b/tests/Feature/Invoices/InvoiceEntryTest.php
@@ -7,7 +7,7 @@ use App\Entities\Projects\Project;
use App\Entities\Partners\Customer;
use App\Services\InvoiceDrafts\Item;
use App\Services\InvoiceDrafts\InvoiceDraft;
-use Illuminate\Foundation\Testing\DatabaseMigrations;
+use Illuminate\Foundation\Testing\RefreshDatabase;
use App\Services\InvoiceDrafts\InvoiceDraftCollection;
/**
@@ -17,7 +17,7 @@ use App\Services\InvoiceDrafts\InvoiceDraftCollection;
*/
class InvoiceEntryTest extends TestCase
{
- use DatabaseMigrations;
+ use RefreshDatabase;
/** @test */
public function user_can_visit_invoice_drafts_page()
@@ -87,7 +87,7 @@ class InvoiceEntryTest extends TestCase
$this->seePageIs(route('invoice-drafts.show', $draft->draftKey));
$this->assertEquals(5000, $draft->getTotal());
- $this->see(formatRp(5000));
+ $this->see(format_money(5000));
}
/** @test */
@@ -137,7 +137,7 @@ class InvoiceEntryTest extends TestCase
$this->assertEquals(200, $draft->getTotal());
- $this->see(formatRp($draft->getTotal()));
+ $this->see(format_money($draft->getTotal()));
}
/** @test */
@@ -174,7 +174,7 @@ class InvoiceEntryTest extends TestCase
$this->see($project->name);
$this->see($project->customer->name);
$this->see($draft->notes);
- $this->see(formatRp(3000));
+ $this->see(format_money(3000));
$this->seeElement('input', ['id' => 'save-invoice-draft']);
}
diff --git a/tests/Feature/Invoices/ManageInvoicesTest.php b/tests/Feature/Invoices/ManageInvoicesTest.php
index ff74ab1..47e1756 100644
--- a/tests/Feature/Invoices/ManageInvoicesTest.php
+++ b/tests/Feature/Invoices/ManageInvoicesTest.php
@@ -4,7 +4,7 @@ namespace Tests\Feature\Invoices;
use Tests\TestCase;
use App\Entities\Invoices\Invoice;
-use Illuminate\Foundation\Testing\DatabaseMigrations;
+use Illuminate\Foundation\Testing\RefreshDatabase;
/**
* Manage Invoices Feature Test.
@@ -13,7 +13,7 @@ use Illuminate\Foundation\Testing\DatabaseMigrations;
*/
class ManageInvoicesTest extends TestCase
{
- use DatabaseMigrations;
+ use RefreshDatabase;
/** @test */
public function user_can_browse_invoice_list_page()
diff --git a/tests/Feature/ManageJobsTest.php b/tests/Feature/ManageJobsTest.php
index c9972d9..55569bd 100644
--- a/tests/Feature/ManageJobsTest.php
+++ b/tests/Feature/ManageJobsTest.php
@@ -8,7 +8,7 @@ use App\Entities\Projects\Job;
use App\Entities\Projects\Task;
use App\Entities\Projects\Project;
use App\Entities\Partners\Customer;
-use Illuminate\Foundation\Testing\DatabaseMigrations;
+use Illuminate\Foundation\Testing\RefreshDatabase;
/**
* Manage Project Feature Test.
@@ -17,7 +17,7 @@ use Illuminate\Foundation\Testing\DatabaseMigrations;
*/
class ManageJobsTest extends TestCase
{
- use DatabaseMigrations;
+ use RefreshDatabase;
/** @test */
public function admin_can_entry_job()
@@ -142,7 +142,7 @@ class ManageJobsTest extends TestCase
$this->seePageIs(route('jobs.show', $project->id));
$this->see(trans('job.detail'));
$this->see($job->name);
- $this->see(formatRp($job->price));
+ $this->see(format_money($job->price));
$this->see($job->worker->name);
}
diff --git a/tests/Feature/ManageProjectsTest.php b/tests/Feature/ManageProjectsTest.php
index 379d9f5..e4a1649 100644
--- a/tests/Feature/ManageProjectsTest.php
+++ b/tests/Feature/ManageProjectsTest.php
@@ -8,11 +8,11 @@ use App\Entities\Projects\Task;
use App\Entities\Payments\Payment;
use App\Entities\Projects\Project;
use App\Entities\Partners\Customer;
-use Illuminate\Foundation\Testing\DatabaseMigrations;
+use Illuminate\Foundation\Testing\RefreshDatabase;
class ManageProjectsTest extends TestCase
{
- use DatabaseMigrations;
+ use RefreshDatabase;
/** @test */
public function admin_can_input_new_project_with_existing_customer()
diff --git a/tests/Feature/ManageSubscriptionsTest.php b/tests/Feature/ManageSubscriptionsTest.php
index 96e4683..8b624cd 100644
--- a/tests/Feature/ManageSubscriptionsTest.php
+++ b/tests/Feature/ManageSubscriptionsTest.php
@@ -6,11 +6,11 @@ use Tests\TestCase;
use App\Entities\Partners\Vendor;
use App\Entities\Projects\Project;
use App\Entities\Subscriptions\Subscription;
-use Illuminate\Foundation\Testing\DatabaseMigrations;
+use Illuminate\Foundation\Testing\RefreshDatabase;
class ManageSubscriptionsTest extends TestCase
{
- use DatabaseMigrations;
+ use RefreshDatabase;
/** @test */
public function admin_can_entry_subscription()
@@ -111,8 +111,8 @@ class ManageSubscriptionsTest extends TestCase
$this->visit(route('subscriptions.show', $subscription->id));
$this->see($subscription->name);
- $this->see(formatRp($subscription->price));
- $this->see(dateId($subscription->start_date));
- $this->see(dateId($subscription->due_date));
+ $this->see(format_money($subscription->price));
+ $this->see(date_id($subscription->start_date));
+ $this->see(date_id($subscription->due_date));
}
}
diff --git a/tests/Feature/ManageTasksTest.php b/tests/Feature/ManageTasksTest.php
index 8831084..7b55f5a 100644
--- a/tests/Feature/ManageTasksTest.php
+++ b/tests/Feature/ManageTasksTest.php
@@ -5,11 +5,11 @@ namespace Tests\Feature;
use Tests\TestCase;
use App\Entities\Projects\Job;
use App\Entities\Projects\Task;
-use Illuminate\Foundation\Testing\DatabaseMigrations;
+use Illuminate\Foundation\Testing\RefreshDatabase;
class ManageTasksTest extends TestCase
{
- use DatabaseMigrations;
+ use RefreshDatabase;
/** @test */
public function admin_can_entry_task()
diff --git a/tests/Feature/Partners/ManageCustomersTest.php b/tests/Feature/Partners/ManageCustomersTest.php
index 8013d34..b2c36f7 100644
--- a/tests/Feature/Partners/ManageCustomersTest.php
+++ b/tests/Feature/Partners/ManageCustomersTest.php
@@ -4,11 +4,11 @@ namespace Tests\Feature;
use Tests\TestCase;
use App\Entities\Partners\Customer;
-use Illuminate\Foundation\Testing\DatabaseMigrations;
+use Illuminate\Foundation\Testing\RefreshDatabase;
class ManageCustomersTest extends TestCase
{
- use DatabaseMigrations;
+ use RefreshDatabase;
/** @test */
public function user_can_see_customer_list_in_customer_index_page()
diff --git a/tests/Feature/Partners/ManageVendorsTest.php b/tests/Feature/Partners/ManageVendorsTest.php
index c3dacce..b2258ea 100644
--- a/tests/Feature/Partners/ManageVendorsTest.php
+++ b/tests/Feature/Partners/ManageVendorsTest.php
@@ -4,11 +4,11 @@ namespace Tests\Feature\Partners;
use Tests\TestCase;
use App\Entities\Partners\Vendor;
-use Illuminate\Foundation\Testing\DatabaseMigrations;
+use Illuminate\Foundation\Testing\RefreshDatabase;
class ManageVendorsTest extends TestCase
{
- use DatabaseMigrations;
+ use RefreshDatabase;
/** @test */
public function user_can_see_vendor_list_in_vendor_index_page()
diff --git a/tests/Feature/Payments/ManagePaymentsTest.php b/tests/Feature/Payments/ManagePaymentsTest.php
index 9d0133b..4ea77f5 100644
--- a/tests/Feature/Payments/ManagePaymentsTest.php
+++ b/tests/Feature/Payments/ManagePaymentsTest.php
@@ -7,7 +7,7 @@ use App\Entities\Partners\Vendor;
use App\Entities\Payments\Payment;
use App\Entities\Projects\Project;
use App\Entities\Partners\Customer;
-use Illuminate\Foundation\Testing\DatabaseMigrations;
+use Illuminate\Foundation\Testing\RefreshDatabase;
/**
* Manage Payments Feature Test.
@@ -16,7 +16,7 @@ use Illuminate\Foundation\Testing\DatabaseMigrations;
*/
class ManagePaymentsTest extends TestCase
{
- use DatabaseMigrations;
+ use RefreshDatabase;
/** @test */
public function admin_can_entry_project_an_income_payment()
@@ -166,7 +166,7 @@ class ManagePaymentsTest extends TestCase
'partner_type' => Vendor::class,
'partner_id' => $vendor->id,
]);
- $customer = factory(Customer::class)->create();
+ $customer = $payment->project->customer;
$this->visit(route('payments.edit', $payment->id));
$this->seePageIs(route('payments.edit', $payment->id));
@@ -216,7 +216,7 @@ class ManagePaymentsTest extends TestCase
$this->seePageIs(route('payments.show', $payment->id));
$this->see(trans('payment.detail'));
$this->see($payment->date);
- $this->see(formatRp($payment->amount));
+ $this->see(format_money($payment->amount));
$this->see($payment->description);
$this->see($payment->partner->name);
}
diff --git a/tests/Feature/Payments/ManageProjectFeesTest.php b/tests/Feature/Payments/ManageProjectFeesTest.php
index 0a859b3..dc935c4 100644
--- a/tests/Feature/Payments/ManageProjectFeesTest.php
+++ b/tests/Feature/Payments/ManageProjectFeesTest.php
@@ -6,11 +6,11 @@ use Tests\TestCase;
use App\Entities\Users\User;
use App\Entities\Payments\Payment;
use App\Entities\Projects\Project;
-use Illuminate\Foundation\Testing\DatabaseMigrations;
+use Illuminate\Foundation\Testing\RefreshDatabase;
class ManageProjectFeesTest extends TestCase
{
- use DatabaseMigrations;
+ use RefreshDatabase;
/** @test */
public function admin_can_entry_project_fee_payment()
diff --git a/tests/Feature/Payments/PaymentSearchTest.php b/tests/Feature/Payments/PaymentSearchTest.php
index d273226..cf7bec0 100644
--- a/tests/Feature/Payments/PaymentSearchTest.php
+++ b/tests/Feature/Payments/PaymentSearchTest.php
@@ -5,11 +5,11 @@ namespace Tests\Feature\Payments;
use Tests\TestCase;
use App\Entities\Payments\Payment;
use App\Entities\Projects\Project;
-use Illuminate\Foundation\Testing\DatabaseMigrations;
+use Illuminate\Foundation\Testing\RefreshDatabase;
class PaymentSearchTest extends TestCase
{
- use DatabaseMigrations;
+ use RefreshDatabase;
/** @test */
public function user_can_find_payment_by_project_name()
diff --git a/tests/Feature/Projects/IssueCommentsTest.php b/tests/Feature/Projects/IssueCommentsTest.php
new file mode 100644
index 0000000..a85c290
--- /dev/null
+++ b/tests/Feature/Projects/IssueCommentsTest.php
@@ -0,0 +1,106 @@
+adminUserSigningIn();
+ $issue = factory(Issue::class)->create();
+ $comment = factory(Comment::class)->create([
+ 'commentable_type' => 'issues',
+ 'commentable_id' => $issue->id,
+ 'body' => 'This is issue comment.',
+ ]);
+
+ $this->visitRoute('projects.issues.show', [$issue->project, $issue]);
+
+ $this->seeText('This is issue comment.');
+ }
+
+ /** @test */
+ public function admin_can_add_comment_to_an_issue()
+ {
+ $admin = $this->adminUserSigningIn();
+ $issue = factory(Issue::class)->create();
+
+ $this->visitRoute('projects.issues.show', [$issue->project, $issue]);
+
+ $this->submitForm(__('comment.create'), [
+ 'body' => 'First comment.',
+ ]);
+
+ $this->seePageIs(route('projects.issues.show', [$issue->project, $issue]));
+ $this->see(__('comment.created'));
+
+ $this->seeInDatabase('comments', [
+ 'commentable_type' => 'issues',
+ 'commentable_id' => $issue->id,
+ 'body' => 'First comment.',
+ 'creator_id' => $admin->id,
+ ]);
+ }
+
+ /** @test */
+ public function user_can_edit_an_issue_comment()
+ {
+ $this->adminUserSigningIn();
+ $issue = factory(Issue::class)->create();
+ $comment = factory(Comment::class)->create([
+ 'commentable_type' => 'issues',
+ 'commentable_id' => $issue->id,
+ 'body' => 'This is issue comment.',
+ ]);
+
+ $this->visitRoute('projects.issues.show', [$issue->project, $issue]);
+ $this->seeElement('a', ['id' => 'edit-comment-'.$comment->id]);
+ $this->click('edit-comment-'.$comment->id);
+ $this->seeRouteIs('projects.issues.show', [$issue->project, $issue, 'action' => 'comment-edit', 'comment_id' => $comment->id]);
+
+ $this->submitForm(__('comment.update'), [
+ 'body' => 'Edited comment.',
+ ]);
+
+ $this->seePageIs(route('projects.issues.show', [$issue->project, $issue]));
+ $this->see(__('comment.updated'));
+
+ $this->seeInDatabase('comments', [
+ 'id' => $comment->id,
+ 'commentable_type' => 'issues',
+ 'commentable_id' => $issue->id,
+ 'body' => 'Edited comment.',
+ ]);
+ }
+
+ /** @test */
+ public function user_can_delete_an_issue_comment()
+ {
+ $this->adminUserSigningIn();
+ $issue = factory(Issue::class)->create();
+ $comment = factory(Comment::class)->create([
+ 'commentable_type' => 'issues',
+ 'commentable_id' => $issue->id,
+ 'body' => 'This is issue comment.',
+ ]);
+
+ $this->visitRoute('projects.issues.show', [$issue->project, $issue]);
+ $this->seeElement('button', ['id' => 'delete-comment-'.$comment->id]);
+ $this->press('delete-comment-'.$comment->id);
+
+ $this->seePageIs(route('projects.issues.show', [$issue->project, $issue]));
+ $this->see(__('comment.deleted'));
+
+ $this->dontSeeInDatabase('comments', [
+ 'id' => $comment->id,
+ ]);
+ }
+}
diff --git a/tests/Feature/Projects/JobCommentsTest.php b/tests/Feature/Projects/JobCommentsTest.php
index 186ff85..6dcba5a 100644
--- a/tests/Feature/Projects/JobCommentsTest.php
+++ b/tests/Feature/Projects/JobCommentsTest.php
@@ -5,11 +5,11 @@ namespace Tests\Feature\Projects;
use Tests\TestCase;
use App\Entities\Projects\Job;
use App\Entities\Projects\Comment;
-use Illuminate\Foundation\Testing\DatabaseMigrations;
+use Illuminate\Foundation\Testing\RefreshDatabase;
class JobCommentsTest extends TestCase
{
- use DatabaseMigrations;
+ use RefreshDatabase;
/** @test */
public function user_can_view_job_comments()
diff --git a/tests/Feature/Projects/ProjectCommentsTest.php b/tests/Feature/Projects/ProjectCommentsTest.php
index 9826f4b..6e7e211 100644
--- a/tests/Feature/Projects/ProjectCommentsTest.php
+++ b/tests/Feature/Projects/ProjectCommentsTest.php
@@ -5,11 +5,11 @@ namespace Tests\Feature\Projects;
use Tests\TestCase;
use App\Entities\Projects\Comment;
use App\Entities\Projects\Project;
-use Illuminate\Foundation\Testing\DatabaseMigrations;
+use Illuminate\Foundation\Testing\RefreshDatabase;
class ProjectCommentsTest extends TestCase
{
- use DatabaseMigrations;
+ use RefreshDatabase;
/** @test */
public function user_can_view_project_comments()
diff --git a/tests/Feature/Projects/ProjectIssuesTest.php b/tests/Feature/Projects/ProjectIssuesTest.php
new file mode 100644
index 0000000..9d27f9f
--- /dev/null
+++ b/tests/Feature/Projects/ProjectIssuesTest.php
@@ -0,0 +1,219 @@
+adminUserSigningIn();
+ $project = factory(Project::class)->create();
+ $issue = factory(Issue::class)->create([
+ 'project_id' => $project->id,
+ 'title' => 'The issue title.',
+ 'body' => 'This is a project issue body.',
+ ]);
+
+ $this->visitRoute('projects.issues.index', $project);
+ $this->seeRouteIs('projects.issues.index', $project);
+
+ $this->seeText('The issue title.');
+ }
+
+ /** @test */
+ public function admin_can_add_issue_to_a_project()
+ {
+ $admin = $this->adminUserSigningIn();
+ $project = factory(Project::class)->create();
+
+ $this->visitRoute('projects.issues.create', $project);
+
+ $this->submitForm(__('issue.create'), [
+ 'title' => 'First Issue.',
+ 'body' => 'First Issue description.',
+ 'priority_id' => 1,
+ 'pic_id' => $admin->id,
+ ]);
+
+ $this->seePageIs(route('projects.issues.index', $project));
+ $this->see(__('issue.created'));
+
+ $this->seeInDatabase('issues', [
+ 'project_id' => $project->id,
+ 'title' => 'First Issue.',
+ 'body' => 'First Issue description.',
+ 'priority_id' => 1,
+ 'pic_id' => $admin->id,
+ 'creator_id' => $admin->id,
+ ]);
+ }
+
+ /** @test */
+ public function user_can_view_an_issue_detail()
+ {
+ $this->adminUserSigningIn();
+ $project = factory(Project::class)->create();
+ $issue = factory(Issue::class)->create([
+ 'project_id' => $project->id,
+ 'title' => 'The issue title.',
+ 'body' => 'This is a project issue body.',
+ ]);
+
+ $this->visitRoute('projects.issues.show', [$project, $issue]);
+ $this->seeText($issue->title);
+ $this->seeText($issue->body);
+ }
+
+ /** @test */
+ public function user_can_edit_issue()
+ {
+ $this->adminUserSigningIn();
+ $project = factory(Project::class)->create();
+ $issue = factory(Issue::class)->create([
+ 'project_id' => $project->id,
+ 'title' => 'The issue title.',
+ 'body' => 'This is a project issue body.',
+ ]);
+
+ $this->visitRoute('projects.issues.show', [$project, $issue]);
+ $this->seeElement('a', ['id' => 'edit-issue-'.$issue->id]);
+ $this->click('edit-issue-'.$issue->id);
+ $this->seeRouteIs('projects.issues.edit', [$project, $issue]);
+
+ $this->submitForm(__('issue.update'), [
+ 'title' => 'First Issue.',
+ 'body' => 'This is a project issue body.',
+ ]);
+
+ $this->seePageIs(route('projects.issues.show', [$project, $issue]));
+ $this->see(__('issue.updated'));
+
+ $this->seeInDatabase('issues', [
+ 'id' => $issue->id,
+ 'project_id' => $project->id,
+ 'title' => 'First Issue.',
+ 'body' => 'This is a project issue body.',
+ ]);
+ }
+
+ /** @test */
+ public function user_can_delete_issue()
+ {
+ $this->adminUserSigningIn();
+ $project = factory(Project::class)->create();
+ $issue = factory(Issue::class)->create([
+ 'project_id' => $project->id,
+ ]);
+
+ $this->visitRoute('projects.issues.edit', [$project, $issue]);
+ $this->seeElement('a', ['id' => 'delete-issue-'.$issue->id]);
+
+ $this->click('delete-issue-'.$issue->id);
+
+ $this->seePageIs(route('projects.issues.edit', [$project, $issue, 'action' => 'delete']));
+ $this->seeElement('button', ['id' => 'delete-issue-'.$issue->id]);
+
+ $this->press('delete-issue-'.$issue->id);
+
+ $this->seePageIs(route('projects.issues.index', $project));
+ $this->seeText(__('issue.deleted'));
+
+ $this->dontSeeInDatabase('issues', [
+ 'id' => $issue->id,
+ ]);
+ }
+
+ /** @test */
+ public function user_can_assign_someone_to_an_issue_as_pic()
+ {
+ $this->adminUserSigningIn();
+ $worker = $this->createUser('worker');
+ $issue = factory(Issue::class)->create();
+
+ $this->visitRoute('projects.issues.show', [$issue->project, $issue]);
+ $this->submitForm(__('issue.update'), [
+ 'pic_id' => $worker->id,
+ ]);
+ $this->seeRouteIs('projects.issues.show', [$issue->project, $issue]);
+ $this->seeText(__('issue.updated'));
+
+ $this->seeInDatabase('issues', [
+ 'id' => $issue->id,
+ 'pic_id' => $worker->id,
+ ]);
+ }
+
+ /** @test */
+ public function user_can_remove_pic_assignment()
+ {
+ $this->adminUserSigningIn();
+ $worker = $this->createUser('worker');
+ $issue = factory(Issue::class)->create(['pic_id' => $worker->id]);
+
+ $this->visitRoute('projects.issues.show', [$issue->project, $issue]);
+ $this->submitForm(__('issue.update'), [
+ 'pic_id' => null,
+ ]);
+ $this->seeRouteIs('projects.issues.show', [$issue->project, $issue]);
+ $this->seeText(__('issue.updated'));
+
+ $this->seeInDatabase('issues', [
+ 'id' => $issue->id,
+ 'pic_id' => null,
+ ]);
+ }
+
+ /** @test */
+ public function user_can_change_issue_status()
+ {
+ $this->adminUserSigningIn();
+ $worker = $this->createUser('worker');
+ $issue = factory(Issue::class)->create();
+
+ $this->visitRoute('projects.issues.show', [$issue->project, $issue]);
+ $this->submitForm(__('issue.update'), [
+ 'status_id' => 2, // resolved
+ 'pic_id' => $worker->id,
+ ]);
+ $this->seeRouteIs('projects.issues.show', [$issue->project, $issue]);
+ $this->seeText(__('issue.updated'));
+
+ $this->seeInDatabase('issues', [
+ 'id' => $issue->id,
+ 'pic_id' => $worker->id,
+ 'status_id' => 2, // resolved
+ ]);
+ }
+
+ /** @test */
+ public function user_can_change_issue_priority()
+ {
+ $this->adminUserSigningIn();
+ $worker = $this->createUser('worker');
+ $issue = factory(Issue::class)->create();
+
+ $this->visitRoute('projects.issues.show', [$issue->project, $issue]);
+ $this->submitForm(__('issue.update'), [
+ 'priority_id' => 2, // major
+ 'status_id' => 2, // resolved
+ 'pic_id' => $worker->id,
+ ]);
+ $this->seeRouteIs('projects.issues.show', [$issue->project, $issue]);
+ $this->seeText(__('issue.updated'));
+
+ $this->seeInDatabase('issues', [
+ 'id' => $issue->id,
+ 'pic_id' => $worker->id,
+ 'priority_id' => 2, // major
+ 'status_id' => 2, // resolved
+ ]);
+ }
+}
diff --git a/tests/Feature/Projects/UploadFilesTest.php b/tests/Feature/Projects/UploadFilesTest.php
index 60556cf..03e114e 100644
--- a/tests/Feature/Projects/UploadFilesTest.php
+++ b/tests/Feature/Projects/UploadFilesTest.php
@@ -6,16 +6,16 @@ use Storage;
use Tests\TestCase;
use Illuminate\Http\UploadedFile;
use App\Entities\Projects\Project;
-use Illuminate\Foundation\Testing\DatabaseMigrations;
+use Illuminate\Foundation\Testing\RefreshDatabase;
class UploadFilesTest extends TestCase
{
- use DatabaseMigrations;
+ use RefreshDatabase;
/** @test */
public function user_can_upload_document_to_a_project()
{
- Storage::fake('avatar');
+ Storage::fake(config('filesystem.default'));
$user = $this->adminUserSigningIn();
$project = factory(Project::class)->create();
$this->visit(route('projects.files', $project->id));
@@ -38,13 +38,13 @@ class UploadFilesTest extends TestCase
]);
$file = $project->files->first();
- Storage::disk('avatar')->assertExists('public/files/'.$file->filename);
+ Storage::assertExists('public/files/'.$file->filename);
}
/** @test */
public function user_can_edit_document_file_on_a_project()
{
- Storage::fake('avatar');
+ Storage::fake(config('filesystem.default'));
$user = $this->adminUserSigningIn();
$project = factory(Project::class)->create();
@@ -75,6 +75,37 @@ class UploadFilesTest extends TestCase
'description' => 'Edit Deskripsi file yang diuplod.',
]);
- Storage::disk('avatar')->assertExists('public/files/'.$file->filename);
+ Storage::assertExists('public/files/'.$file->filename);
+ }
+
+ /** @test */
+ public function user_can_delete_document_file_on_a_project()
+ {
+ Storage::fake(config('filesystem.default'));
+ $user = $this->adminUserSigningIn();
+ $project = factory(Project::class)->create();
+
+ $this->visit(route('projects.files', $project));
+
+ $this->attach(UploadedFile::fake()->image('avatar.jpg'), 'file');
+ $this->type('Judul file', 'title');
+ $this->type('Deskripsi file yang diuplod.', 'description');
+ $this->press(__('file.upload'));
+
+ $this->assertCount(1, $project->files);
+
+ $file = $project->files->first();
+ Storage::assertExists('public/files/'.$file->filename);
+
+ $this->visit(route('projects.files', $project));
+ $this->click('delete-file-'.$file->id);
+ $this->seePageIs(route('projects.files', [$project, 'action' => 'delete', 'id' => $file->id]));
+
+ $this->press(__('app.delete_confirm_button'));
+
+ $this->seePageIs(route('projects.files', $project));
+ $this->seeText(__('file.deleted'));
+ $this->dontSeeInDatabase('files', ['id' => $file->id]);
+ Storage::assertMissing('public/files/'.$file->filename);
}
}
diff --git a/tests/Feature/References/ManageBankAccountsTest.php b/tests/Feature/References/ManageBankAccountsTest.php
index 8ac5d46..aa569b9 100644
--- a/tests/Feature/References/ManageBankAccountsTest.php
+++ b/tests/Feature/References/ManageBankAccountsTest.php
@@ -5,7 +5,7 @@ namespace Tests\Feature\References;
use Tests\TestCase;
use App\Entities\Options\Option;
use App\Entities\Invoices\BankAccount;
-use Illuminate\Foundation\Testing\DatabaseMigrations;
+use Illuminate\Foundation\Testing\RefreshDatabase;
/**
* Manage Bank Account Feature Test.
@@ -14,7 +14,7 @@ use Illuminate\Foundation\Testing\DatabaseMigrations;
*/
class ManageBankAccountsTest extends TestCase
{
- use DatabaseMigrations;
+ use RefreshDatabase;
/** @test */
public function user_can_see_bank_account_list_in_bank_account_index_page()
diff --git a/tests/Feature/References/SiteOptionsTest.php b/tests/Feature/References/SiteOptionsTest.php
index 8c34e14..2589fe7 100644
--- a/tests/Feature/References/SiteOptionsTest.php
+++ b/tests/Feature/References/SiteOptionsTest.php
@@ -3,7 +3,7 @@
namespace Tests\Feature\Users;
use Tests\TestCase;
-use Illuminate\Foundation\Testing\DatabaseMigrations;
+use Illuminate\Foundation\Testing\RefreshDatabase;
/**
* Site Options Feature Test.
@@ -12,7 +12,7 @@ use Illuminate\Foundation\Testing\DatabaseMigrations;
*/
class SiteOptionsTest extends TestCase
{
- use DatabaseMigrations;
+ use RefreshDatabase;
/** @test */
public function admin_user_can_visit_site_options_page()
diff --git a/tests/Feature/Users/ManageUsersTest.php b/tests/Feature/Users/ManageUsersTest.php
index 57d3d39..e54dd13 100644
--- a/tests/Feature/Users/ManageUsersTest.php
+++ b/tests/Feature/Users/ManageUsersTest.php
@@ -4,7 +4,7 @@ namespace Tests\Feature\Users;
use Tests\TestCase;
use App\Entities\Users\User;
-use Illuminate\Foundation\Testing\DatabaseMigrations;
+use Illuminate\Foundation\Testing\RefreshDatabase;
/**
* Manage Users Feature Test.
@@ -13,7 +13,7 @@ use Illuminate\Foundation\Testing\DatabaseMigrations;
*/
class ManageUsersTest extends TestCase
{
- use DatabaseMigrations;
+ use RefreshDatabase;
/** @test */
public function user_can_see_user_list_from_dashboard_tab()
diff --git a/tests/Feature/Users/UserProfileTest.php b/tests/Feature/Users/UserProfileTest.php
index fef6f3c..79cd63c 100644
--- a/tests/Feature/Users/UserProfileTest.php
+++ b/tests/Feature/Users/UserProfileTest.php
@@ -3,7 +3,7 @@
namespace Tests\Feature\Users;
use Tests\TestCase;
-use Illuminate\Foundation\Testing\DatabaseMigrations;
+use Illuminate\Foundation\Testing\RefreshDatabase;
/**
* User Profile Feature Test.
@@ -12,7 +12,7 @@ use Illuminate\Foundation\Testing\DatabaseMigrations;
*/
class UserProfileTest extends TestCase
{
- use DatabaseMigrations;
+ use RefreshDatabase;
/** @test */
public function a_user_can_visit_their_profile_page()
diff --git a/tests/TestCase.php b/tests/TestCase.php
index 8ad9de8..e6f1e4b 100644
--- a/tests/TestCase.php
+++ b/tests/TestCase.php
@@ -33,7 +33,7 @@ abstract class TestCase extends BaseTestCase
return $user;
}
- protected function assertFileExistsThenDelete($filePath, $message = null)
+ protected function assertFileExistsThenDelete($filePath, $message = '')
{
$this->assertTrue(file_exists($filePath), $message);
diff --git a/tests/Unit/Helpers/AppLogoImageTest.php b/tests/Unit/Helpers/AppLogoImageTest.php
index 14d508e..23b02fa 100644
--- a/tests/Unit/Helpers/AppLogoImageTest.php
+++ b/tests/Unit/Helpers/AppLogoImageTest.php
@@ -3,11 +3,11 @@
namespace Tests\Unit\Helpers;
use Tests\TestCase;
-use Illuminate\Foundation\Testing\DatabaseMigrations;
+use Illuminate\Foundation\Testing\RefreshDatabase;
class AppLogoImageTest extends TestCase
{
- use DatabaseMigrations;
+ use RefreshDatabase;
/** @test */
public function app_logo_path_function_returns_correct_logo_image_path_based_on_agency_logo_path_setting()
@@ -17,13 +17,13 @@ class AppLogoImageTest extends TestCase
'value' => 'icon_user_1.png',
]);
- $this->assertEquals(asset('assets/imgs/icon_user_1.png'), appLogoPath());
+ $this->assertEquals(asset('assets/imgs/icon_user_1.png'), app_logo_path());
}
/** @test */
public function app_logo_path_function_returns_default_logo_image_path_if_no_image_logo_path_setting()
{
- $this->assertEquals(asset('assets/imgs/default-logo.png'), appLogoPath());
+ $this->assertEquals(asset('assets/imgs/default-logo.png'), app_logo_path());
}
/** @test */
@@ -33,7 +33,7 @@ class AppLogoImageTest extends TestCase
$logoString .= ' src="'.asset('assets/imgs/default-logo.png').'"';
$logoString .= ' alt="Logo Laravel">';
- $this->assertEquals($logoString, appLogoImage());
+ $this->assertEquals($logoString, app_logo_image());
}
/** @test */
@@ -48,7 +48,7 @@ class AppLogoImageTest extends TestCase
$logoString .= ' src="'.asset('assets/imgs/icon_user_1.png').'"';
$logoString .= ' alt="Logo Laravel">';
- $this->assertEquals($logoString, appLogoImage());
+ $this->assertEquals($logoString, app_logo_image());
}
/** @test */
@@ -69,7 +69,7 @@ class AppLogoImageTest extends TestCase
'class' => '123',
'style' => 'display: inline',
];
- $this->assertEquals($logoString, appLogoImage($overrides));
+ $this->assertEquals($logoString, app_logo_image($overrides));
}
/** @test */
@@ -84,6 +84,6 @@ class AppLogoImageTest extends TestCase
$logoString .= ' src="'.asset('assets/imgs/default-logo.png').'"';
$logoString .= ' alt="Logo Laravel">';
- $this->assertEquals($logoString, appLogoImage());
+ $this->assertEquals($logoString, app_logo_image());
}
}
diff --git a/tests/Unit/Helpers/DateDifferenceTest.php b/tests/Unit/Helpers/DateDifferenceTest.php
index 6984536..3a9625e 100644
--- a/tests/Unit/Helpers/DateDifferenceTest.php
+++ b/tests/Unit/Helpers/DateDifferenceTest.php
@@ -14,31 +14,31 @@ class DateDifferenceTest extends TestCase
/** @test */
public function date_difference_function_exists()
{
- $this->assertTrue(function_exists('dateDifference'));
+ $this->assertTrue(function_exists('date_difference'));
}
/** @test */
public function date_difference_returns_days_count_by_default()
{
- $this->assertEquals(9, dateDifference('2018-04-01', '2018-04-10'));
+ $this->assertEquals(9, date_difference('2018-04-01', '2018-04-10'));
}
/** @test */
public function date_difference_can_returns_formatted_string()
{
- $this->assertEquals('9 days', dateDifference('2018-04-01', '2018-04-10', '%a days'));
+ $this->assertEquals('9 days', date_difference('2018-04-01', '2018-04-10', '%a days'));
}
/** @test */
public function date_difference_returns_proper_months_and_days_format()
{
// TODO: Need to fix, this should returns 1 months 9 days
- $this->assertEquals('1 month 12 days', dateDifference('2018-03-01', '2018-04-10', '%m month %d days'));
+ $this->assertEquals('1 month 12 days', date_difference('2018-03-01', '2018-04-10', '%m month %d days'));
}
/** @test */
public function date_difference_returns_proper_years_months_and_days_format()
{
- $this->assertEquals('1 year 1 month 12 days', dateDifference('2017-03-01', '2018-04-10', '%y year %m month %d days'));
+ $this->assertEquals('1 year 1 month 12 days', date_difference('2017-03-01', '2018-04-10', '%y year %m month %d days'));
}
}
diff --git a/tests/Unit/Helpers/MoneyFormatTest.php b/tests/Unit/Helpers/MoneyFormatTest.php
index fc0384c..5a976f4 100644
--- a/tests/Unit/Helpers/MoneyFormatTest.php
+++ b/tests/Unit/Helpers/MoneyFormatTest.php
@@ -3,7 +3,7 @@
namespace Tests\Unit\Helpers;
use Tests\TestCase;
-use Illuminate\Foundation\Testing\DatabaseMigrations;
+use Illuminate\Foundation\Testing\RefreshDatabase;
/**
* Money Format Helper Unit Test.
@@ -12,14 +12,14 @@ use Illuminate\Foundation\Testing\DatabaseMigrations;
*/
class MoneyFormatTest extends TestCase
{
- use DatabaseMigrations;
+ use RefreshDatabase;
/** @test */
public function format_money_returns_string_with_default_money_sign()
{
- $this->assertEquals('Rp. 1.000', formatRp(1000));
- $this->assertEquals('Rp. 0', formatRp(0));
- $this->assertEquals('- Rp. 1.000', formatRp(-1000));
+ $this->assertEquals('Rp. 1.000', format_money(1000));
+ $this->assertEquals('Rp. 0', format_money(0));
+ $this->assertEquals('- Rp. 1.000', format_money(-1000));
}
/** @test */
@@ -30,8 +30,8 @@ class MoneyFormatTest extends TestCase
'value' => 'USD',
]);
- $this->assertEquals('USD 1.000', formatRp(1000));
- $this->assertEquals('USD 0', formatRp(0));
- $this->assertEquals('- USD 1.000', formatRp(-1000));
+ $this->assertEquals('USD 1.000', format_money(1000));
+ $this->assertEquals('USD 0', format_money(0));
+ $this->assertEquals('- USD 1.000', format_money(-1000));
}
}
diff --git a/tests/Unit/Http/Middlewares/RoleTest.php b/tests/Unit/Http/Middlewares/RoleTest.php
index 78078b5..6e57174 100644
--- a/tests/Unit/Http/Middlewares/RoleTest.php
+++ b/tests/Unit/Http/Middlewares/RoleTest.php
@@ -4,7 +4,7 @@ namespace Tests\Unit\Http\Middlewares;
use Tests\TestCase;
use App\Http\Middleware\Role;
-use Illuminate\Foundation\Testing\DatabaseMigrations;
+use Illuminate\Foundation\Testing\RefreshDatabase;
/**
* Role middleware test.
@@ -13,7 +13,7 @@ use Illuminate\Foundation\Testing\DatabaseMigrations;
*/
class RoleTest extends TestCase
{
- use DatabaseMigrations;
+ use RefreshDatabase;
/**
* Call the given middleware.
diff --git a/tests/Unit/Models/BankAccountTest.php b/tests/Unit/Models/BankAccountTest.php
index 47b0c96..69a6f22 100644
--- a/tests/Unit/Models/BankAccountTest.php
+++ b/tests/Unit/Models/BankAccountTest.php
@@ -4,11 +4,11 @@ namespace Tests\Unit\Models;
use Tests\TestCase;
use App\Entities\Invoices\BankAccount;
-use Illuminate\Foundation\Testing\DatabaseMigrations;
+use Illuminate\Foundation\Testing\RefreshDatabase;
class BankAccountTest extends TestCase
{
- use DatabaseMigrations;
+ use RefreshDatabase;
/** @test */
public function a_bank_account_has_status_attribute()
diff --git a/tests/Unit/Models/CommentTest.php b/tests/Unit/Models/CommentTest.php
index 5673997..6b86e57 100644
--- a/tests/Unit/Models/CommentTest.php
+++ b/tests/Unit/Models/CommentTest.php
@@ -5,11 +5,11 @@ namespace Tests\Unit\Models;
use Tests\TestCase;
use App\Entities\Users\User;
use App\Entities\Projects\Comment;
-use Illuminate\Foundation\Testing\DatabaseMigrations;
+use Illuminate\Foundation\Testing\RefreshDatabase;
class CommentTest extends TestCase
{
- use DatabaseMigrations;
+ use RefreshDatabase;
/** @test */
public function a_comment_has_belongs_to_creator_relation()
diff --git a/tests/Unit/Models/CustomerTest.php b/tests/Unit/Models/CustomerTest.php
index 3784653..0ec62fb 100644
--- a/tests/Unit/Models/CustomerTest.php
+++ b/tests/Unit/Models/CustomerTest.php
@@ -9,11 +9,11 @@ use App\Entities\Projects\Project;
use Illuminate\Support\Collection;
use App\Entities\Partners\Customer;
use App\Entities\Subscriptions\Subscription;
-use Illuminate\Foundation\Testing\DatabaseMigrations;
+use Illuminate\Foundation\Testing\RefreshDatabase;
class CustomerTest extends TestCase
{
- use DatabaseMigrations;
+ use RefreshDatabase;
/** @test */
public function a_customer_has_many_projects()
diff --git a/tests/Unit/Models/InvoiceTest.php b/tests/Unit/Models/InvoiceTest.php
index 8a456f3..434a028 100644
--- a/tests/Unit/Models/InvoiceTest.php
+++ b/tests/Unit/Models/InvoiceTest.php
@@ -6,7 +6,7 @@ use Tests\TestCase;
use App\Entities\Users\User;
use App\Entities\Invoices\Invoice;
use App\Entities\Projects\Project;
-use Illuminate\Foundation\Testing\DatabaseMigrations;
+use Illuminate\Foundation\Testing\RefreshDatabase;
/**
* Invoice Model Test.
@@ -15,7 +15,7 @@ use Illuminate\Foundation\Testing\DatabaseMigrations;
*/
class InvoiceTest extends TestCase
{
- use DatabaseMigrations;
+ use RefreshDatabase;
/** @test */
public function it_has_project_relation()
diff --git a/tests/Unit/Models/IssueTest.php b/tests/Unit/Models/IssueTest.php
new file mode 100644
index 0000000..a43ed72
--- /dev/null
+++ b/tests/Unit/Models/IssueTest.php
@@ -0,0 +1,99 @@
+make();
+
+ $this->assertInstanceOf(Project::class, $issue->project);
+ $this->assertEquals($issue->project_id, $issue->project->id);
+ }
+
+ /** @test */
+ public function an_issue_has_belongs_to_pic_relation()
+ {
+ $pic = $this->createUser('worker');
+ $issue = factory(Issue::class)->make(['pic_id' => $pic->id]);
+
+ $this->assertInstanceOf(User::class, $issue->pic);
+ $this->assertEquals($issue->pic_id, $issue->pic->id);
+ }
+
+ /** @test */
+ public function issue_pic_name_has_default_value()
+ {
+ $issue = factory(Issue::class)->make(['pic_id' => null]);
+
+ $this->assertEquals(__('issue.no_pic'), $issue->pic->name);
+ }
+
+ /** @test */
+ public function an_issue_has_belongs_to_creator_relation()
+ {
+ $issue = factory(Issue::class)->make();
+
+ $this->assertInstanceOf(User::class, $issue->creator);
+ $this->assertEquals($issue->creator_id, $issue->creator->id);
+ }
+
+ /** @test */
+ public function an_issue_has_status_attribute()
+ {
+ $issue = factory(Issue::class)->make();
+
+ $this->assertEquals(__('issue.open'), $issue->status);
+ }
+
+ /** @test */
+ public function an_issue_has_status_label_attribute()
+ {
+ $issue = factory(Issue::class)->make();
+
+ $this->assertEquals(''.$issue->status.'', $issue->status_label);
+ }
+
+ /** @test */
+ public function an_issue_has_priority_attribute()
+ {
+ $issue = factory(Issue::class)->make();
+
+ $this->assertEquals(__('issue.minor'), $issue->priority);
+ }
+
+ /** @test */
+ public function an_issue_has_priority_label_attribute()
+ {
+ $issue = factory(Issue::class)->make();
+ $colorClass = Priority::getColorById($issue->priority_id);
+
+ $this->assertEquals(''.$issue->priority.'', $issue->priority_label);
+ }
+
+ /** @test */
+ public function an_issue_has_many_comments_relation()
+ {
+ $issue = factory(Issue::class)->create();
+ $comment = factory(Comment::class)->create([
+ 'commentable_type' => 'issues',
+ 'commentable_id' => $issue->id,
+ ]);
+
+ $this->assertInstanceOf(Collection::class, $issue->comments);
+ $this->assertInstanceOf(Comment::class, $issue->comments->first());
+ }
+}
diff --git a/tests/Unit/Models/JobTest.php b/tests/Unit/Models/JobTest.php
index c92fc37..e049d77 100644
--- a/tests/Unit/Models/JobTest.php
+++ b/tests/Unit/Models/JobTest.php
@@ -8,7 +8,7 @@ use App\Entities\Projects\Task;
use App\Entities\Projects\Comment;
use App\Entities\Projects\Project;
use Illuminate\Support\Collection;
-use Illuminate\Foundation\Testing\DatabaseMigrations;
+use Illuminate\Foundation\Testing\RefreshDatabase;
/**
* Job Model Unit Test.
@@ -17,7 +17,7 @@ use Illuminate\Foundation\Testing\DatabaseMigrations;
*/
class JobTest extends TestCase
{
- use DatabaseMigrations;
+ use RefreshDatabase;
/** @test */
public function a_job_has_name_link_method()
@@ -55,6 +55,19 @@ class JobTest extends TestCase
}
/** @test */
+ public function job_deletion_also_deletes_related_tasks()
+ {
+ $job = factory(Job::class)->create();
+ $task = factory(Task::class)->create(['job_id' => $job->id]);
+
+ $job->delete();
+
+ $this->dontSeeInDatabase('tasks', [
+ 'job_id' => $job->id,
+ ]);
+ }
+
+ /** @test */
public function a_job_has_progress_attribute()
{
$job = factory(Job::class)->create();
@@ -97,4 +110,21 @@ class JobTest extends TestCase
$this->assertInstanceOf(Collection::class, $job->comments);
$this->assertInstanceOf(Comment::class, $job->comments->first());
}
+
+ /** @test */
+ public function job_deletion_also_deletes_related_comments()
+ {
+ $job = factory(Job::class)->create();
+ $comment = factory(Comment::class)->create([
+ 'commentable_type' => 'jobs',
+ 'commentable_id' => $job->id,
+ ]);
+
+ $job->delete();
+
+ $this->dontSeeInDatabase('comments', [
+ 'commentable_type' => 'jobs',
+ 'commentable_id' => $job->id,
+ ]);
+ }
}
diff --git a/tests/Unit/Models/PaymentTest.php b/tests/Unit/Models/PaymentTest.php
index f1df1ee..e334850 100644
--- a/tests/Unit/Models/PaymentTest.php
+++ b/tests/Unit/Models/PaymentTest.php
@@ -7,11 +7,11 @@ use App\Entities\Users\User;
use App\Entities\Partners\Vendor;
use App\Entities\Payments\Payment;
use App\Entities\Partners\Customer;
-use Illuminate\Foundation\Testing\DatabaseMigrations;
+use Illuminate\Foundation\Testing\RefreshDatabase;
class PaymentTest extends TestCase
{
- use DatabaseMigrations;
+ use RefreshDatabase;
/** @test */
public function it_can_have_partner_relation_on_customer_model_for_income_payment()
diff --git a/tests/Unit/Models/ProjectTest.php b/tests/Unit/Models/ProjectTest.php
index 24c5264..5164333 100644
--- a/tests/Unit/Models/ProjectTest.php
+++ b/tests/Unit/Models/ProjectTest.php
@@ -4,18 +4,21 @@ namespace Tests\Unit\Models;
use Tests\TestCase;
use App\Entities\Projects\Job;
+use App\Entities\Projects\File;
use App\Entities\Projects\Task;
+use App\Entities\Projects\Issue;
+use App\Entities\Invoices\Invoice;
use App\Entities\Payments\Payment;
use App\Entities\Projects\Comment;
use App\Entities\Projects\Project;
use Illuminate\Support\Collection;
use App\Entities\Partners\Customer;
use App\Entities\Subscriptions\Subscription;
-use Illuminate\Foundation\Testing\DatabaseMigrations;
+use Illuminate\Foundation\Testing\RefreshDatabase;
class ProjectTest extends TestCase
{
- use DatabaseMigrations;
+ use RefreshDatabase;
/** @test */
public function a_project_has_name_link_method()
@@ -41,6 +44,19 @@ class ProjectTest extends TestCase
}
/** @test */
+ public function project_deletion_also_deletes_related_jobs()
+ {
+ $project = factory(Project::class)->create();
+ $job = factory(Job::class)->create(['project_id' => $project->id]);
+
+ $project->delete();
+
+ $this->dontSeeInDatabase('jobs', [
+ 'project_id' => $project->id,
+ ]);
+ }
+
+ /** @test */
public function a_project_has_many_main_jobs()
{
$project = factory(Project::class)->create();
@@ -69,15 +85,43 @@ class ProjectTest extends TestCase
}
/** @test */
- public function a_project_has_many_payments()
+ public function project_deletion_also_deletes_related_job_tasks()
+ {
+ $project = factory(Project::class)->create();
+ $job = factory(Job::class)->create(['project_id' => $project->id, 'type_id' => 2]);
+ $tasks = factory(Task::class, 2)->create(['job_id' => $job->id]);
+
+ $project->delete();
+
+ $this->dontSeeInDatabase('tasks', [
+ 'job_id' => $job->id,
+ ]);
+ }
+
+ /** @test */
+ public function a_project_has_many_payments_relation()
{
$project = factory(Project::class)->create();
$payment = factory(Payment::class)->create(['project_id' => $project->id]);
+
$this->assertInstanceOf(Collection::class, $project->payments);
$this->assertInstanceOf(Payment::class, $project->payments->first());
}
/** @test */
+ public function project_deletion_also_deletes_related_payments()
+ {
+ $project = factory(Project::class)->create();
+ $payment = factory(Payment::class)->create(['project_id' => $project->id]);
+
+ $project->delete();
+
+ $this->dontSeeInDatabase('payments', [
+ 'project_id' => $project->id,
+ ]);
+ }
+
+ /** @test */
public function a_project_has_many_subscriptions()
{
$project = factory(Project::class)->create();
@@ -87,6 +131,19 @@ class ProjectTest extends TestCase
}
/** @test */
+ public function project_deletion_also_deletes_related_subscriptions()
+ {
+ $project = factory(Project::class)->create();
+ $subscription = factory(Subscription::class)->create(['project_id' => $project->id]);
+
+ $project->delete();
+
+ $this->dontSeeInDatabase('subscriptions', [
+ 'project_id' => $project->id,
+ ]);
+ }
+
+ /** @test */
public function a_project_belongs_to_a_customer()
{
$customer = factory(Customer::class)->create();
@@ -168,10 +225,30 @@ class ProjectTest extends TestCase
public function a_project_has_many_files()
{
$project = factory(Project::class)->create();
+
$this->assertInstanceOf(Collection::class, $project->files);
}
/** @test */
+ public function project_deletion_also_deletes_related_files()
+ {
+ $project = factory(Project::class)->create();
+ $file = File::create([
+ 'fileable_id' => $project->id,
+ 'fileable_type' => 'projects',
+ 'filename' => 'filename.jpg',
+ 'title' => 'filename.jpg',
+ ]);
+
+ $project->delete();
+
+ $this->dontSeeInDatabase('files', [
+ 'fileable_id' => $project->id,
+ 'fileable_type' => 'projects',
+ ]);
+ }
+
+ /** @test */
public function a_project_has_collectible_earnings_method()
{
// Collectible earnings is total of (price * avg task progress of each job)
@@ -214,6 +291,23 @@ class ProjectTest extends TestCase
}
/** @test */
+ public function project_deletion_also_deletes_related_comments()
+ {
+ $project = factory(Project::class)->create();
+ $comment = factory(Comment::class)->create([
+ 'commentable_type' => 'projects',
+ 'commentable_id' => $project->id,
+ ]);
+
+ $project->delete();
+
+ $this->dontSeeInDatabase('comments', [
+ 'commentable_type' => 'projects',
+ 'commentable_id' => $project->id,
+ ]);
+ }
+
+ /** @test */
public function project_has_work_duration_attribute()
{
$project = factory(Project::class)->create([
@@ -234,4 +328,37 @@ class ProjectTest extends TestCase
$this->assertEquals('2 Year(s) 3 Month(s)', $project->work_duration);
}
+
+ /** @test */
+ public function a_project_has_many_invoices_relation()
+ {
+ $project = factory(Project::class)->create();
+ $invoice = factory(Invoice::class)->create(['project_id' => $project->id]);
+
+ $this->assertInstanceOf(Collection::class, $project->invoices);
+ $this->assertInstanceOf(Invoice::class, $project->invoices->first());
+ }
+
+ /** @test */
+ public function project_deletion_also_deletes_related_invoices()
+ {
+ $project = factory(Project::class)->create();
+ $invoice = factory(Invoice::class)->create(['project_id' => $project->id]);
+
+ $project->delete();
+
+ $this->dontSeeInDatabase('invoices', [
+ 'project_id' => $project->id,
+ ]);
+ }
+
+ /** @test */
+ public function a_project_has_many_issues_relation()
+ {
+ $project = factory(Project::class)->create();
+ $issue = factory(Issue::class)->create(['project_id' => $project->id]);
+
+ $this->assertInstanceOf(Collection::class, $project->issues);
+ $this->assertInstanceOf(Issue::class, $project->issues->first());
+ }
}
diff --git a/tests/Unit/Models/SubscriptionTest.php b/tests/Unit/Models/SubscriptionTest.php
index af0f041..7e6ee5d 100644
--- a/tests/Unit/Models/SubscriptionTest.php
+++ b/tests/Unit/Models/SubscriptionTest.php
@@ -3,30 +3,30 @@
namespace Tests\Unit\Models;
use Carbon\Carbon;
-use Tests\TestCase as TestCase;
+use Tests\TestCase;
use App\Entities\Partners\Vendor;
use App\Entities\Projects\Project;
use App\Entities\Partners\Customer;
use App\Entities\Subscriptions\Type;
use App\Entities\Subscriptions\Subscription;
-use Illuminate\Foundation\Testing\DatabaseMigrations;
+use Illuminate\Foundation\Testing\RefreshDatabase;
class SubscriptionTest extends TestCase
{
- use DatabaseMigrations;
+ use RefreshDatabase;
/** @test */
- public function it_has_name_link_method()
+ public function it_has_name_link_attribute()
{
$subscription = factory(Subscription::class)->create();
$this->assertEquals(
- link_to_route('subscriptions.show', $subscription->name, [$subscription->id], [
+ link_to_route('subscriptions.show', $subscription->name, $subscription, [
'title' => trans(
'app.show_detail_title',
['name' => $subscription->name, 'type' => trans('subscription.subscription')]
),
- ]), $subscription->nameLink()
+ ]), $subscription->name_link
);
}
@@ -69,8 +69,8 @@ class SubscriptionTest extends TestCase
$next3Months = Carbon::now()->addMonths(2)->format('Y-m-d');
$subscription = factory(Subscription::class)->make(['due_date' => $next3Months]);
- $dueDateDescription = trans('subscription.start_date').' : '.dateId($subscription->start_date)."\n";
- $dueDateDescription .= trans('subscription.due_date').' : '.dateId($subscription->due_date);
+ $dueDateDescription = trans('subscription.start_date').' : '.date_id($subscription->start_date)."\n";
+ $dueDateDescription .= trans('subscription.due_date').' : '.date_id($subscription->due_date);
$this->assertEquals($dueDateDescription, $subscription->dueDateDescription());
}
diff --git a/tests/Unit/Models/UserTest.php b/tests/Unit/Models/UserTest.php
index caaafad..b3060f9 100644
--- a/tests/Unit/Models/UserTest.php
+++ b/tests/Unit/Models/UserTest.php
@@ -8,7 +8,7 @@ use App\Entities\Projects\Job;
use App\Entities\Payments\Payment;
use App\Entities\Projects\Project;
use Illuminate\Support\Collection;
-use Illuminate\Foundation\Testing\DatabaseMigrations;
+use Illuminate\Foundation\Testing\RefreshDatabase;
/**
* User Model Unit Test.
@@ -17,7 +17,7 @@ use Illuminate\Foundation\Testing\DatabaseMigrations;
*/
class UserTest extends TestCase
{
- use DatabaseMigrations;
+ use RefreshDatabase;
/** @test */
public function user_has_name_link_method()
diff --git a/tests/Unit/Models/VendorTest.php b/tests/Unit/Models/VendorTest.php
index 59ed5a9..5208d80 100644
--- a/tests/Unit/Models/VendorTest.php
+++ b/tests/Unit/Models/VendorTest.php
@@ -6,11 +6,11 @@ use Tests\TestCase;
use App\Entities\Partners\Vendor;
use App\Entities\Payments\Payment;
use Illuminate\Support\Collection;
-use Illuminate\Foundation\Testing\DatabaseMigrations;
+use Illuminate\Foundation\Testing\RefreshDatabase;
class VendorTest extends TestCase
{
- use DatabaseMigrations;
+ use RefreshDatabase;
/** @test */
public function a_vendor_has_name()
diff --git a/tests/Unit/Policies/CommentPolicyTest.php b/tests/Unit/Policies/CommentPolicyTest.php
index 51cf568..f20ea56 100644
--- a/tests/Unit/Policies/CommentPolicyTest.php
+++ b/tests/Unit/Policies/CommentPolicyTest.php
@@ -4,11 +4,11 @@ namespace Tests\Unit\Policies;
use Tests\TestCase;
use App\Entities\Projects\Comment;
-use Illuminate\Foundation\Testing\DatabaseMigrations;
+use Illuminate\Foundation\Testing\RefreshDatabase;
class CommentPolicyTest extends TestCase
{
- use DatabaseMigrations;
+ use RefreshDatabase;
/** @test */
public function admin_can_edit_any_comments()
diff --git a/tests/Unit/Policies/CustomerPolicyTest.php b/tests/Unit/Policies/CustomerPolicyTest.php
index af9093f..e757e44 100644
--- a/tests/Unit/Policies/CustomerPolicyTest.php
+++ b/tests/Unit/Policies/CustomerPolicyTest.php
@@ -4,7 +4,7 @@ namespace Tests\Unit\Policies;
use Tests\TestCase;
use App\Entities\Partners\Customer;
-use Illuminate\Foundation\Testing\DatabaseMigrations;
+use Illuminate\Foundation\Testing\RefreshDatabase;
/**
* Customer Policy Test.
@@ -13,7 +13,7 @@ use Illuminate\Foundation\Testing\DatabaseMigrations;
*/
class CustomerPolicyTest extends TestCase
{
- use DatabaseMigrations;
+ use RefreshDatabase;
/** @test */
public function only_admin_can_create_customer()
diff --git a/tests/Unit/Policies/IssuePolicyTest.php b/tests/Unit/Policies/IssuePolicyTest.php
new file mode 100644
index 0000000..a5b1016
--- /dev/null
+++ b/tests/Unit/Policies/IssuePolicyTest.php
@@ -0,0 +1,34 @@
+
+ */
+class IssuePolicyTest extends TestCase
+{
+ use RefreshDatabase;
+
+ /** @test */
+ public function admin_can_create_issue()
+ {
+ $admin = $this->createUser('admin');
+
+ $this->assertTrue($admin->can('create', new Issue()));
+ }
+
+ /** @test */
+ public function admin_can_add_comment_to_an_issue()
+ {
+ $admin = $this->createUser('admin');
+ $issue = factory(Issue::class)->create();
+
+ $this->assertTrue($admin->can('comment-on', $issue));
+ }
+}
diff --git a/tests/Unit/Policies/JobPolicyTest.php b/tests/Unit/Policies/JobPolicyTest.php
index ac17b13..5f7b776 100644
--- a/tests/Unit/Policies/JobPolicyTest.php
+++ b/tests/Unit/Policies/JobPolicyTest.php
@@ -4,11 +4,11 @@ namespace Tests\Unit\Policies;
use Tests\TestCase;
use App\Entities\Projects\Job;
-use Illuminate\Foundation\Testing\DatabaseMigrations;
+use Illuminate\Foundation\Testing\RefreshDatabase;
class JobPolicyTest extends TestCase
{
- use DatabaseMigrations;
+ use RefreshDatabase;
/** @test */
public function an_admin_can_create_job_on_a_project()
diff --git a/tests/Unit/Policies/PaymentPolicyTest.php b/tests/Unit/Policies/PaymentPolicyTest.php
index dea049e..e683ec5 100644
--- a/tests/Unit/Policies/PaymentPolicyTest.php
+++ b/tests/Unit/Policies/PaymentPolicyTest.php
@@ -4,7 +4,7 @@ namespace Tests\Unit\Policies;
use Tests\TestCase;
use App\Entities\Payments\Payment;
-use Illuminate\Foundation\Testing\DatabaseMigrations;
+use Illuminate\Foundation\Testing\RefreshDatabase;
/**
* Payment Policy Test.
@@ -13,7 +13,7 @@ use Illuminate\Foundation\Testing\DatabaseMigrations;
*/
class PaymentPolicyTest extends TestCase
{
- use DatabaseMigrations;
+ use RefreshDatabase;
/** @test */
public function only_admin_can_create_payment()
diff --git a/tests/Unit/Policies/ProjectPolicyTest.php b/tests/Unit/Policies/ProjectPolicyTest.php
index ac24478..36f32ad 100644
--- a/tests/Unit/Policies/ProjectPolicyTest.php
+++ b/tests/Unit/Policies/ProjectPolicyTest.php
@@ -5,11 +5,11 @@ namespace Tests\Unit\Policies;
use Tests\TestCase;
use App\Entities\Projects\Job;
use App\Entities\Projects\Project;
-use Illuminate\Foundation\Testing\DatabaseMigrations;
+use Illuminate\Foundation\Testing\RefreshDatabase;
class ProjectPolicyTest extends TestCase
{
- use DatabaseMigrations;
+ use RefreshDatabase;
/** @test */
public function only_admin_can_create_project()
diff --git a/tests/Unit/Policies/TaskPolicyTest.php b/tests/Unit/Policies/TaskPolicyTest.php
index f4ff8b3..d46f9e0 100644
--- a/tests/Unit/Policies/TaskPolicyTest.php
+++ b/tests/Unit/Policies/TaskPolicyTest.php
@@ -5,11 +5,11 @@ namespace Tests\Unit\Policies;
use Tests\TestCase;
use App\Entities\Projects\Job;
use App\Entities\Projects\Task;
-use Illuminate\Foundation\Testing\DatabaseMigrations;
+use Illuminate\Foundation\Testing\RefreshDatabase;
class TaskPolicyTest extends TestCase
{
- use DatabaseMigrations;
+ use RefreshDatabase;
/** @test */
public function only_admin_can_create_task_on_a_job()
diff --git a/tests/Unit/Policies/UserPolicyTest.php b/tests/Unit/Policies/UserPolicyTest.php
index d9aa5aa..b72963e 100644
--- a/tests/Unit/Policies/UserPolicyTest.php
+++ b/tests/Unit/Policies/UserPolicyTest.php
@@ -6,11 +6,11 @@ use Tests\TestCase;
use App\Entities\Users\User;
use App\Entities\Projects\Job;
use App\Entities\Payments\Payment;
-use Illuminate\Foundation\Testing\DatabaseMigrations;
+use Illuminate\Foundation\Testing\RefreshDatabase;
class UserPolicyTest extends TestCase
{
- use DatabaseMigrations;
+ use RefreshDatabase;
/** @test */
public function admin_can_create_user()
diff --git a/tests/Unit/Policies/VendorPolicyTest.php b/tests/Unit/Policies/VendorPolicyTest.php
index 35274f8..cbc2ae9 100644
--- a/tests/Unit/Policies/VendorPolicyTest.php
+++ b/tests/Unit/Policies/VendorPolicyTest.php
@@ -5,7 +5,7 @@ namespace Tests\Unit\Policies;
use Tests\TestCase;
use App\Entities\Partners\Vendor;
use App\Entities\Payments\Payment;
-use Illuminate\Foundation\Testing\DatabaseMigrations;
+use Illuminate\Foundation\Testing\RefreshDatabase;
/**
* Vendor Policy Test.
@@ -14,7 +14,7 @@ use Illuminate\Foundation\Testing\DatabaseMigrations;
*/
class VendorPolicyTest extends TestCase
{
- use DatabaseMigrations;
+ use RefreshDatabase;
/** @test */
public function only_admin_can_create_vendor()
diff --git a/tests/Unit/Queries/AdminDashboardQueryTest.php b/tests/Unit/Queries/AdminDashboardQueryTest.php
index 4b79024..5ffac58 100644
--- a/tests/Unit/Queries/AdminDashboardQueryTest.php
+++ b/tests/Unit/Queries/AdminDashboardQueryTest.php
@@ -10,11 +10,11 @@ use App\Entities\Payments\Payment;
use App\Entities\Projects\Project;
use App\Queries\AdminDashboardQuery;
use App\Entities\Subscriptions\Subscription;
-use Illuminate\Foundation\Testing\DatabaseMigrations;
+use Illuminate\Foundation\Testing\RefreshDatabase;
class AdminDashboardQueryTest extends TestCase
{
- use DatabaseMigrations;
+ use RefreshDatabase;
/** @test */
public function retrieve_total_earnings_on_the_year()
diff --git a/tests/Unit/Services/SiteOptionTest.php b/tests/Unit/Services/SiteOptionTest.php
index 122d439..566e8ff 100644
--- a/tests/Unit/Services/SiteOptionTest.php
+++ b/tests/Unit/Services/SiteOptionTest.php
@@ -4,11 +4,11 @@ namespace Tests\Unit\Services;
use Option;
use Tests\TestCase;
-use Illuminate\Foundation\Testing\DatabaseMigrations;
+use Illuminate\Foundation\Testing\RefreshDatabase;
class SiteOptionTest extends TestCase
{
- use DatabaseMigrations;
+ use RefreshDatabase;
/** @test */
public function option_can_be_set()