Improve variable name

This commit is contained in:
Marcus Moore 2024-01-17 11:54:37 -08:00
parent 4d8d069bbc
commit 82f4cc799b
No known key found for this signature in database
4 changed files with 113 additions and 78 deletions

View file

@ -39,7 +39,7 @@ class ReportTemplatesController extends Controller
return view('reports/custom', [
'customfields' => $customfields,
'report_templates' => $report_templates,
'reportTemplate' => $reportTemplate,
'template' => $reportTemplate,
]);
}
@ -47,7 +47,7 @@ class ReportTemplatesController extends Controller
{
return view('reports/custom', [
'customfields' => CustomField::get(),
'reportTemplate' => ReportTemplate::findOrFail($reportId),
'template' => ReportTemplate::findOrFail($reportId),
]);
}

View file

@ -404,7 +404,7 @@ class ReportsController extends Controller
return view('reports/custom', [
'customfields' => $customfields,
'report_templates' => $report_templates,
'reportTemplate' => $template,
'template' => $template,
]);
}

View file

@ -20,7 +20,7 @@
'method' => 'post',
'class' => 'form-horizontal',
'id' => 'custom-report-form',
'url' => request()->routeIs('report-templates.edit') ? route('report-templates.update', $reportTemplate) : '/reports/custom',
'url' => request()->routeIs('report-templates.edit') ? route('report-templates.update', $template) : '/reports/custom',
]) }}
{{csrf_field()}}
@ -29,9 +29,9 @@
<div class="box-header with-border">
<h2 class="box-title">
@if (request()->routeIs('report-templates.edit'))
Updating: {{ $reportTemplate->name }}
Updating: {{ $template->name }}
@elseif(request()->routeIs('report-templates.show'))
Saved Template: {{ $reportTemplate->name }}
Saved Template: {{ $template->name }}
@else
{{ trans('general.customize_report') }}
@endif
@ -39,7 +39,7 @@
@if (request()->routeIs('report-templates.show'))
<div class="box-tools pull-right">
<a
href="{{ route('report-templates.edit', $reportTemplate) }}"
href="{{ route('report-templates.edit', $template) }}"
class="btn btn-sm btn-warning"
data-tooltip="true"
title="Update"
@ -51,7 +51,7 @@
class="btn btn-sm btn-danger delete-asset"
data-toggle="modal"
data-title="{{ trans('general.delete') }}"
data-content="{{ trans('general.delete_confirm', ['item' => $reportTemplate->name]) }}"
data-content="{{ trans('general.delete_confirm', ['item' => $template->name]) }}"
data-target="#dataConfirmModal"
type="button"
>
@ -71,147 +71,147 @@
</label>
<label class="form-control">
{{ Form::checkbox('id', '1', $reportTemplate->checkmarkValue('id')) }}
{{ Form::checkbox('id', '1', $template->checkmarkValue('id')) }}
{{ trans('general.id') }}
</label>
<label class="form-control">
{{ Form::checkbox('company', '1', $reportTemplate->checkmarkValue('company')) }}
{{ Form::checkbox('company', '1', $template->checkmarkValue('company')) }}
{{ trans('general.company') }}
</label>
<label class="form-control">
{{ Form::checkbox('asset_tag', '1', $reportTemplate->checkmarkValue('asset_tag')) }}
{{ Form::checkbox('asset_tag', '1', $template->checkmarkValue('asset_tag')) }}
{{ trans('general.asset_tag') }}
</label>
<label class="form-control">
{{ Form::checkbox('asset_name', '1', $reportTemplate->checkmarkValue('asset_name')) }}
{{ Form::checkbox('asset_name', '1', $template->checkmarkValue('asset_name')) }}
{{ trans('admin/hardware/form.name') }}
</label>
<label class="form-control">
{{ Form::checkbox('manufacturer', '1', $reportTemplate->checkmarkValue('manufacturer')) }}
{{ Form::checkbox('manufacturer', '1', $template->checkmarkValue('manufacturer')) }}
{{ trans('general.manufacturer') }}
</label>
<label class="form-control">
{{ Form::checkbox('model', '1', $reportTemplate->checkmarkValue('model')) }}
{{ Form::checkbox('model', '1', $template->checkmarkValue('model')) }}
{{ trans('general.asset_models') }}
</label>
<label class="form-control">
{{ Form::checkbox('category', '1', $reportTemplate->checkmarkValue('category')) }}
{{ Form::checkbox('category', '1', $template->checkmarkValue('category')) }}
{{ trans('general.category') }}
</label>
<label class="form-control">
{{ Form::checkbox('serial', '1', $reportTemplate->checkmarkValue('serial')) }}
{{ Form::checkbox('serial', '1', $template->checkmarkValue('serial')) }}
{{ trans('admin/hardware/table.serial') }}
</label>
<label class="form-control">
{{ Form::checkbox('purchase_date', '1', $reportTemplate->checkmarkValue('purchase_date')) }}
{{ Form::checkbox('purchase_date', '1', $template->checkmarkValue('purchase_date')) }}
{{ trans('admin/licenses/table.purchase_date') }}
</label>
<label class="form-control">
{{ Form::checkbox('purchase_cost', '1', $reportTemplate->checkmarkValue('purchase_cost')) }}
{{ Form::checkbox('purchase_cost', '1', $template->checkmarkValue('purchase_cost')) }}
{{ trans('admin/hardware/form.cost') }}
</label>
<label class="form-control">
{{ Form::checkbox('eol', '1', $reportTemplate->checkmarkValue('eol')) }}
{{ Form::checkbox('eol', '1', $template->checkmarkValue('eol')) }}
{{ trans('admin/hardware/table.eol') }}
</label>
<label class="form-control">
{{ Form::checkbox('order', '1', $reportTemplate->checkmarkValue('order')) }}
{{ Form::checkbox('order', '1', $template->checkmarkValue('order')) }}
{{ trans('admin/hardware/form.order') }}
</label>
<label class="form-control">
{{ Form::checkbox('supplier', '1', $reportTemplate->checkmarkValue('supplier')) }}
{{ Form::checkbox('supplier', '1', $template->checkmarkValue('supplier')) }}
{{ trans('general.suppliers') }}
</label>
<label class="form-control">
{{ Form::checkbox('location', '1', $reportTemplate->checkmarkValue('location')) }}
{{ Form::checkbox('location', '1', $template->checkmarkValue('location')) }}
{{ trans('general.location') }}
</label>
<label class="form-control">
{{ Form::checkbox('location_address', '1', $reportTemplate->checkmarkValue('location_address')) }}
{{ Form::checkbox('location_address', '1', $template->checkmarkValue('location_address')) }}
- {{ trans('general.address') }}
</label>
<label class="form-control">
{{ Form::checkbox('rtd_location', '1', $reportTemplate->checkmarkValue('rtd_location')) }}
{{ Form::checkbox('rtd_location', '1', $template->checkmarkValue('rtd_location')) }}
{{ trans('admin/hardware/form.default_location') }}
</label>
<label class="form-control">
{{ Form::checkbox('rtd_location_address', '1', $reportTemplate->checkmarkValue('rtd_location_address')) }}
{{ Form::checkbox('rtd_location_address', '1', $template->checkmarkValue('rtd_location_address')) }}
- {{ trans('general.address') }}
</label>
<label class="form-control">
{{ Form::checkbox('status', '1', $reportTemplate->checkmarkValue('status')) }}
{{ Form::checkbox('status', '1', $template->checkmarkValue('status')) }}
{{ trans('general.status') }}
</label>
<label class="form-control">
{{ Form::checkbox('warranty', '1', $reportTemplate->checkmarkValue('warranty')) }}
{{ Form::checkbox('warranty', '1', $template->checkmarkValue('warranty')) }}
{{ trans('admin/hardware/form.warranty') }}
</label>
<label class="form-control">
{{ Form::checkbox('depreciation', '1', $reportTemplate->checkmarkValue('depreciation')) }}
{{ Form::checkbox('depreciation', '1', $template->checkmarkValue('depreciation')) }}
{{ trans('general.depreciation') }}
</label>
<label class="form-control">
{{ Form::checkbox('checkout_date', '1', $reportTemplate->checkmarkValue('checkout_date')) }}
{{ Form::checkbox('checkout_date', '1', $template->checkmarkValue('checkout_date')) }}
{{ trans('admin/hardware/table.checkout_date') }}
</label>
<label class="form-control">
{{ Form::checkbox('expected_checkin', '1', $reportTemplate->checkmarkValue('expected_checkin')) }}
{{ Form::checkbox('expected_checkin', '1', $template->checkmarkValue('expected_checkin')) }}
{{ trans('admin/hardware/form.expected_checkin') }}
</label>
<label class="form-control">
{{ Form::checkbox('created_at', '1', $reportTemplate->checkmarkValue('created_at')) }}
{{ Form::checkbox('created_at', '1', $template->checkmarkValue('created_at')) }}
{{ trans('general.created_at') }}
</label>
<label class="form-control">
{{ Form::checkbox('updated_at', '1', $reportTemplate->checkmarkValue('updated_at')) }}
{{ Form::checkbox('updated_at', '1', $template->checkmarkValue('updated_at')) }}
{{ trans('general.updated_at') }}
</label>
<label class="form-control">
{{ Form::checkbox('deleted_at', '1', $reportTemplate->checkmarkValue('deleted_at')) }}
{{ Form::checkbox('deleted_at', '1', $template->checkmarkValue('deleted_at')) }}
{{ trans('general.deleted') }}
</label>
<label class="form-control">
{{ Form::checkbox('last_audit_date', '1', $reportTemplate->checkmarkValue('last_audit_date')) }}
{{ Form::checkbox('last_audit_date', '1', $template->checkmarkValue('last_audit_date')) }}
{{ trans('general.last_audit') }}
</label>
<label class="form-control">
{{ Form::checkbox('next_audit_date', '1', $reportTemplate->checkmarkValue('next_audit_date')) }}
{{ Form::checkbox('next_audit_date', '1', $template->checkmarkValue('next_audit_date')) }}
{{ trans('general.next_audit_date') }}
</label>
<label class="form-control">
{{ Form::checkbox('notes', '1', $reportTemplate->checkmarkValue('notes')) }}
{{ Form::checkbox('notes', '1', $template->checkmarkValue('notes')) }}
{{ trans('general.notes') }}
</label>
<label class="form-control">
{{ Form::checkbox('url', '1', $reportTemplate->checkmarkValue('url')) }}
{{ Form::checkbox('url', '1', $template->checkmarkValue('url')) }}
- {{ trans('admin/manufacturers/table.url') }}
</label>
@ -221,32 +221,32 @@
<h2>{{ trans('general.checked_out_to') }} {{ trans('general.fields') }}:</h2>
<label class="form-control">
{{ Form::checkbox('assigned_to', '1', $reportTemplate->checkmarkValue('assigned_to')) }}
{{ Form::checkbox('assigned_to', '1', $template->checkmarkValue('assigned_to')) }}
{{ trans('admin/licenses/table.assigned_to') }}
</label>
<label class="form-control">
{{ Form::checkbox('username', '1', $reportTemplate->checkmarkValue('username')) }}
{{ Form::checkbox('username', '1', $template->checkmarkValue('username')) }}
{{ trans('admin/users/table.username') }}
</label>
<label class="form-control">
{{ Form::checkbox('employee_num', '1', $reportTemplate->checkmarkValue('employee_num')) }}
{{ Form::checkbox('employee_num', '1', $template->checkmarkValue('employee_num')) }}
{{ trans('general.employee_number') }}
</label>
<label class="form-control">
{{ Form::checkbox('manager', '1', $reportTemplate->checkmarkValue('manager')) }}
{{ Form::checkbox('manager', '1', $template->checkmarkValue('manager')) }}
{{ trans('admin/users/table.manager') }}
</label>
<label class="form-control">
{{ Form::checkbox('department', '1', $reportTemplate->checkmarkValue('department')) }}
{{ Form::checkbox('department', '1', $template->checkmarkValue('department')) }}
{{ trans('general.department') }}
</label>
<label class="form-control">
{{ Form::checkbox('title', '1', $reportTemplate->checkmarkValue('title')) }}
{{ Form::checkbox('title', '1', $template->checkmarkValue('title')) }}
{{ trans('admin/users/table.title') }}
</label>
@ -259,7 +259,7 @@
@foreach ($customfields as $customfield)
<label class="form-control">
{{ Form::checkbox($customfield->db_column_name(), '1', $reportTemplate->checkmarkValue($customfield->db_column_name())) }}
{{ Form::checkbox($customfield->db_column_name(), '1', $template->checkmarkValue($customfield->db_column_name())) }}
{{ $customfield->name }}
</label>
@ -280,68 +280,68 @@
'multiple' => 'true',
'fieldname' => 'by_company_id[]',
'hide_new' => 'true',
'selected' => $reportTemplate->selectValues('by_company_id', \App\Models\Company::class)
'selected' => $template->selectValues('by_company_id', \App\Models\Company::class)
])
@include ('partials.forms.edit.location-select', [
'translated_name' => trans('general.location'),
'multiple' => 'true',
'fieldname' => 'by_location_id[]',
'hide_new' => 'true',
'selected' => $reportTemplate->selectValues('by_location_id', \App\Models\Location::class)
'selected' => $template->selectValues('by_location_id', \App\Models\Location::class)
])
@include ('partials.forms.edit.location-select', [
'translated_name' => trans('admin/hardware/form.default_location'),
'multiple' => 'true',
'fieldname' => 'by_rtd_location_id[]',
'hide_new' => 'true',
'selected' => $reportTemplate->selectValues('by_rtd_location_id', \App\Models\Location::class)
'selected' => $template->selectValues('by_rtd_location_id', \App\Models\Location::class)
])
@include ('partials.forms.edit.department-select', [
'translated_name' => trans('general.department'),
'fieldname' => 'by_dept_id',
'hide_new' => 'true',
'selected' => $reportTemplate->selectValue('by_dept_id', \App\Models\Department::class)
'selected' => $template->selectValue('by_dept_id', \App\Models\Department::class)
])
@include ('partials.forms.edit.supplier-select', [
'translated_name' => trans('general.supplier'),
'fieldname' => 'by_supplier_id[]',
'multiple' => 'true',
'hide_new' => 'true',
'selected' => $reportTemplate->selectValues('by_supplier_id', \App\Models\Supplier::class)
'selected' => $template->selectValues('by_supplier_id', \App\Models\Supplier::class)
])
@include ('partials.forms.edit.model-select', [
'translated_name' => trans('general.asset_model'),
'fieldname' => 'by_model_id[]',
'multiple' => 'true',
'hide_new' => 'true',
'selected' => $reportTemplate->selectValues('by_model_id', \App\Models\AssetModel::class)
'selected' => $template->selectValues('by_model_id', \App\Models\AssetModel::class)
])
@include ('partials.forms.edit.manufacturer-select', [
'translated_name' => trans('general.manufacturer'),
'fieldname' => 'by_manufacturer_id',
'hide_new' => 'true',
'selected' => $reportTemplate->selectValue('by_manufacturer_id', \App\Models\Manufacturer::class)
'selected' => $template->selectValue('by_manufacturer_id', \App\Models\Manufacturer::class)
])
@include ('partials.forms.edit.category-select', [
'translated_name' => trans('general.category'),
'fieldname' => 'by_category_id',
'hide_new' => 'true',
'category_type' => 'asset',
'selected' => $reportTemplate->selectValue('by_category_id', \App\Models\Category::class)
'selected' => $template->selectValue('by_category_id', \App\Models\Category::class)
])
@include ('partials.forms.edit.status-select', [
'translated_name' => trans('admin/hardware/form.status'),
'fieldname' => 'by_status_id[]',
'multiple' => 'true',
'hide_new' => 'true',
'selected' => $reportTemplate->selectValues('by_status_id', \App\Models\Statuslabel::class)
'selected' => $template->selectValues('by_status_id', \App\Models\Statuslabel::class)
])
<!-- Order Number -->
<div class="form-group">
<label for="by_order_number" class="col-md-3 control-label">{{ trans('general.order_number') }}</label>
<div class="col-md-5 col-sm-8">
<input class="form-control" type="text" name="by_order_number" value="{{ $reportTemplate->textValue('by_order_number') }}" aria-label="by_order_number">
<input class="form-control" type="text" name="by_order_number" value="{{ $template->textValue('by_order_number') }}" aria-label="by_order_number">
</div>
</div>
@ -349,9 +349,9 @@
<div class="form-group purchase-range">
<label for="purchase_start" class="col-md-3 control-label">{{ trans('general.purchase_date') }} {{ trans('general.range') }}</label>
<div class="input-daterange input-group col-md-6" id="datepicker">
<input type="text" class="form-control" name="purchase_start" aria-label="purchase_start" value="{{ $reportTemplate->textValue('purchase_start') }}">
<input type="text" class="form-control" name="purchase_start" aria-label="purchase_start" value="{{ $template->textValue('purchase_start') }}">
<span class="input-group-addon">to</span>
<input type="text" class="form-control" name="purchase_end" aria-label="purchase_end" value="{{ $reportTemplate->textValue('purchase_end') }}">
<input type="text" class="form-control" name="purchase_end" aria-label="purchase_end" value="{{ $template->textValue('purchase_end') }}">
</div>
</div>
@ -359,9 +359,9 @@
<div class="form-group purchase-range">
<label for="created_start" class="col-md-3 control-label">{{ trans('general.created_at') }} {{ trans('general.range') }}</label>
<div class="input-daterange input-group col-md-6" id="datepicker">
<input type="text" class="form-control" name="created_start" aria-label="created_start" value="{{ $reportTemplate->textValue('created_start') }}">
<input type="text" class="form-control" name="created_start" aria-label="created_start" value="{{ $template->textValue('created_start') }}">
<span class="input-group-addon">to</span>
<input type="text" class="form-control" name="created_end" aria-label="created_end" value="{{ $reportTemplate->textValue('created_end') }}">
<input type="text" class="form-control" name="created_end" aria-label="created_end" value="{{ $template->textValue('created_end') }}">
</div>
</div>
@ -369,9 +369,9 @@
<div class="form-group checkout-range">
<label for="checkout_date" class="col-md-3 control-label">{{ trans('general.checkout') }} {{ trans('general.range') }}</label>
<div class="input-daterange input-group col-md-6" id="datepicker">
<input type="text" class="form-control" name="checkout_date_start" aria-label="checkout_date_start" value="{{ $reportTemplate->textValue('checkout_date_start') }}">
<input type="text" class="form-control" name="checkout_date_start" aria-label="checkout_date_start" value="{{ $template->textValue('checkout_date_start') }}">
<span class="input-group-addon">to</span>
<input type="text" class="form-control" name="checkout_date_end" aria-label="checkout_date_end" value="{{ $reportTemplate->textValue('checkout_date_end') }}">
<input type="text" class="form-control" name="checkout_date_end" aria-label="checkout_date_end" value="{{ $template->textValue('checkout_date_end') }}">
</div>
</div>
@ -379,9 +379,9 @@
<div class="form-group expected_checkin-range">
<label for="expected_checkin_start" class="col-md-3 control-label">{{ trans('admin/hardware/form.expected_checkin') }}</label>
<div class="input-daterange input-group col-md-6" id="datepicker">
<input type="text" class="form-control" name="expected_checkin_start" aria-label="expected_checkin_start" value="{{ $reportTemplate->textValue('expected_checkin_start') }}">
<input type="text" class="form-control" name="expected_checkin_start" aria-label="expected_checkin_start" value="{{ $template->textValue('expected_checkin_start') }}">
<span class="input-group-addon">to</span>
<input type="text" class="form-control" name="expected_checkin_end" aria-label="expected_checkin_end" value="{{ $reportTemplate->textValue('expected_checkin_end') }}">
<input type="text" class="form-control" name="expected_checkin_end" aria-label="expected_checkin_end" value="{{ $template->textValue('expected_checkin_end') }}">
</div>
</div>
@ -389,9 +389,9 @@
<div class="form-group last_audit-range">
<label for="last_audit_start" class="col-md-3 control-label">{{ trans('general.last_audit') }}</label>
<div class="input-daterange input-group col-md-6" id="datepicker">
<input type="text" class="form-control" name="last_audit_start" aria-label="last_audit_start" value="{{ $reportTemplate->textValue('last_audit_start') }}">
<input type="text" class="form-control" name="last_audit_start" aria-label="last_audit_start" value="{{ $template->textValue('last_audit_start') }}">
<span class="input-group-addon">to</span>
<input type="text" class="form-control" name="last_audit_end" aria-label="last_audit_end" value="{{ $reportTemplate->textValue('last_audit_end') }}">
<input type="text" class="form-control" name="last_audit_end" aria-label="last_audit_end" value="{{ $template->textValue('last_audit_end') }}">
</div>
</div>
@ -399,36 +399,36 @@
<div class="form-group next_audit-range">
<label for="next_audit_start" class="col-md-3 control-label">{{ trans('general.next_audit_date') }}</label>
<div class="input-daterange input-group col-md-6" id="datepicker">
<input type="text" class="form-control" name="next_audit_start" aria-label="nex_audit_start" value="{{ $reportTemplate->textValue('next_audit_start') }}">
<input type="text" class="form-control" name="next_audit_start" aria-label="nex_audit_start" value="{{ $template->textValue('next_audit_start') }}">
<span class="input-group-addon">to</span>
<input type="text" class="form-control" name="next_audit_end" aria-label="next_audit_end" value="{{ $reportTemplate->textValue('next_audit_end') }}">
<input type="text" class="form-control" name="next_audit_end" aria-label="next_audit_end" value="{{ $template->textValue('next_audit_end') }}">
</div>
</div>
<div class="col-md-9 col-md-offset-3">
<label class="form-control">
{{ Form::checkbox('exclude_archived', '1', $reportTemplate->checkmarkValue('exclude_archived')) }}
{{ Form::checkbox('exclude_archived', '1', $template->checkmarkValue('exclude_archived')) }}
{{ trans('general.exclude_archived') }}
</label>
</div>
<div class="col-md-9 col-md-offset-3">
<label class="form-control">
{{ Form::checkbox('use_bom', '1', $reportTemplate->checkmarkValue('use_bom')) }}
{{ Form::checkbox('use_bom', '1', $template->checkmarkValue('use_bom')) }}
{{ trans('general.bom_remark') }}
</label>
</div>
<div class="col-md-9 col-md-offset-3">
<label class="form-control">
{{ Form::radio('deleted_assets', '', $reportTemplate->radioValue('deleted_assets', '', true), ['aria-label'=>'deleted_assets', 'id'=>'deleted_assets_exclude_deleted'])}}
{{ Form::radio('deleted_assets', '', $template->radioValue('deleted_assets', '', true), ['aria-label'=>'deleted_assets', 'id'=>'deleted_assets_exclude_deleted'])}}
{{ trans('general.exclude_deleted') }}
</label>
<label class="form-control">
{{ Form::radio('deleted_assets', '1', $reportTemplate->radioValue('deleted_assets', '1'), ['aria-label'=>'deleted_assets', 'id'=>'deleted_assets_include_deleted']) }}
{{ Form::radio('deleted_assets', '1', $template->radioValue('deleted_assets', '1'), ['aria-label'=>'deleted_assets', 'id'=>'deleted_assets_include_deleted']) }}
{{ trans('general.include_deleted') }}
</label>
<label class="form-control">
{{ Form::radio('deleted_assets', '0', $reportTemplate->radioValue('deleted_assets', '0'), ['aria-label'=>'deleted_assets','id'=>'deleted_assets_only_deleted']) }}
{{ Form::radio('deleted_assets', '0', $template->radioValue('deleted_assets', '0'), ['aria-label'=>'deleted_assets','id'=>'deleted_assets_only_deleted']) }}
{{ trans('general.only_deleted') }}
</label>
</div>
@ -480,7 +480,7 @@
<input type="hidden" id="savetemplateform" name="options">
<div class="form-group{{ $errors->has('name') ? ' has-error' : '' }}">
<label for="name">{{ trans('admin/reports/general.template_name') }}</label>
<input class="form-control" placeholder="" name="name" type="text" id="name" value="{{ $reportTemplate->name }}">
<input class="form-control" placeholder="" name="name" type="text" id="name" value="{{ $template->name }}">
{!! $errors->first('name', '<span class="alert-msg" aria-hidden="true"><i class="fas fa-times" aria-hidden="true"></i> :message</span>') !!}
</div>
<button class="btn btn-primary" style="width: 100%">

View file

@ -17,9 +17,9 @@ class ReportTemplateTest extends TestCase
$this->actingAs(User::factory()->canViewReports()->create())
->get(route('reports/custom'))
->assertOk()
->assertViewHas(['reportTemplate' => function (ReportTemplate $report) {
->assertViewHas(['template' => function (ReportTemplate $template) {
// the view should have an empty report by default
return $report->exists() === false;
return $template->exists() === false;
}]);
}
@ -50,8 +50,8 @@ class ReportTemplateTest extends TestCase
$this->actingAs($user)
->get(route('report-templates.show', $reportTemplate))
->assertOk()
->assertViewHas(['reportTemplate' => function (ReportTemplate $viewReport) use ($reportTemplate) {
return $viewReport->is($reportTemplate);
->assertViewHas(['template' => function (ReportTemplate $templatePassedToView) use ($reportTemplate) {
return $templatePassedToView->is($reportTemplate);
}]);
}
@ -76,7 +76,7 @@ class ReportTemplateTest extends TestCase
$this->assertEquals(['1', '2'], $template->options['by_company_id']);
}
public function testReportTemplateRequiresValidFields()
public function testSavingReportTemplateRequiresValidFields()
{
$this->actingAs(User::factory()->canViewReports()->create())
->post(route('report-templates.store'), [
@ -85,6 +85,21 @@ class ReportTemplateTest extends TestCase
->assertSessionHasErrors('name');
}
public function testCanUpdateAReportTemplate()
{
$this->markTestIncomplete();
$user = User::factory()->canViewReports()->create();
$reportTemplate = ReportTemplate::factory()->for($user)->create();
$this->actingAs($user)
->get(route('report-templates.edit', $reportTemplate))
->assertOk();
// @todo:
}
public function testRedirectingAfterValidationErrorRestoresInputs()
{
$this->actingAs(User::factory()->canViewReports()->create())
@ -96,15 +111,35 @@ class ReportTemplateTest extends TestCase
// set some values to ensure they are still present
// when returning to the custom report page.
'by_company_id' => [2, 3]
])->assertViewHas(['reportTemplate' => function (ReportTemplate $reportTemplate) {
])->assertViewHas(['template' => function (ReportTemplate $reportTemplate) {
return data_get($reportTemplate, 'options.by_company_id') === [2, 3];
}]);
}
public function testUpdatingReportTemplateRequiresValidFields()
{
$this->markTestIncomplete();
}
public function testSavingReportTemplateRequiresCorrectPermission()
{
$this->actingAs(User::factory()->create())
->post(route('report-templates.store'))
->assertForbidden();
}
public function testUpdatingReportTemplateRequiresCorrectPermission()
{
$this->markTestIncomplete();
}
public function testCanDeleteAReportTemplate()
{
$this->markTestIncomplete();
}
public function testDeletingReportTemplateRequiresCorrectPermission()
{
$this->markTestIncomplete();
}
}