Merge branch 'master' of github.com:akaunting/akaunting

This commit is contained in:
Cüneyt Şentürk 2021-06-22 09:51:40 +03:00
commit b92ac7f25d
17 changed files with 164 additions and 57 deletions

View File

@ -320,28 +320,4 @@ class Customers extends Controller
return response()->json($customer); return response()->json($customer);
} }
public function field(BaseRequest $request)
{
$html = '';
if ($request['fields']) {
foreach ($request['fields'] as $field) {
switch ($field) {
case 'password':
$html .= \Form::passwordGroup('password', trans('auth.password.current'), 'key', [], 'col-md-6 password');
break;
case 'password_confirmation':
$html .= \Form::passwordGroup('password_confirmation', trans('auth.password.current_confirm'), 'key', [], 'col-md-6 password');
break;
}
}
}
$json = [
'html' => $html
];
return response()->json($json);
}
} }

View File

@ -27,6 +27,7 @@ class Widget extends FormRequest
'dashboard_id' => 'required|integer', 'dashboard_id' => 'required|integer',
'name' => 'required|string', 'name' => 'required|string',
'class' => 'required', 'class' => 'required',
'sort' => 'integer',
]; ];
} }
} }

View File

@ -4,10 +4,11 @@ namespace App\Models\Common;
use App\Abstracts\Model; use App\Abstracts\Model;
use Bkwld\Cloner\Cloneable; use Bkwld\Cloner\Cloneable;
use Illuminate\Database\Eloquent\Factories\HasFactory;
class Widget extends Model class Widget extends Model
{ {
use Cloneable; use Cloneable, HasFactory;
protected $table = 'widgets'; protected $table = 'widgets';
@ -36,4 +37,14 @@ class Widget extends Model
{ {
return $this->hasManyThrough('App\Models\Auth\User', 'App\Models\Common\Dashboard'); return $this->hasManyThrough('App\Models\Auth\User', 'App\Models\Common\Dashboard');
} }
/**
* Create a new factory instance for the model.
*
* @return \Illuminate\Database\Eloquent\Factories\Factory
*/
protected static function newFactory()
{
return \Database\Factories\Widget::new();
}
} }

View File

@ -0,0 +1,47 @@
<?php
namespace Database\Factories;
use App\Abstracts\Factory;
use App\Models\Common\Dashboard;
use App\Models\Common\Widget as Model;
class Widget extends Factory
{
/**
* The name of the factory's corresponding model.
*
* @var string
*/
protected $model = Model::class;
public $classes = [
'App\Widgets\TotalIncome',
'App\Widgets\TotalExpenses',
'App\Widgets\TotalProfit',
'App\Widgets\CashFlow',
'App\Widgets\IncomeByCategory',
'App\Widgets\ExpensesByCategory',
'App\Widgets\AccountBalance',
'App\Widgets\LatestIncome',
'App\Widgets\LatestExpenses',
'App\Widgets\Currencies',
];
/**
* Define the model's default state.
*
* @return array
*/
public function definition()
{
$dashboard = Dashboard::first();
return [
'company_id' => $this->company->id,
'dashboard_id' => $dashboard->id,
'name' => $this->faker->text(15),
'class' => $this->faker->randomElement($this->classes),
];
}
}

View File

@ -75,6 +75,8 @@
:label="text.sort" :label="text.sort"
prepend-icon="fas fa-sort" prepend-icon="fas fa-sort"
:placeholder="placeholder.sort" :placeholder="placeholder.sort"
:error="form.errors.sort[0]"
@input="form.errors.sort[0] = ''"
inputGroupClasses="input-group-merge"></base-input> inputGroupClasses="input-group-merge"></base-input>
</div> </div>
</div> </div>
@ -220,6 +222,7 @@ export default {
errors: { errors: {
name: [], name: [],
class: [], class: [],
sort: [],
} }
}, },
display: this.show display: this.show
@ -258,7 +261,9 @@ export default {
} }
if (response.errors) { if (response.errors) {
self.form.errors = error.response.data.errors; self.form.errors.name = (error.response.data.errors.name) ? error.response.data.errors.name : [];
self.form.errors.class = (error.response.data.errors.class) ? error.response.data.errors.class : [];
self.form.errors.sort = (error.response.data.errors.sort) ? error.response.data.errors.sort : [];
self.form.loading = false; self.form.loading = false;
} }
@ -266,7 +271,9 @@ export default {
self.form.response = response.data; self.form.response = response.data;
}) })
.catch(function (error) { .catch(function (error) {
self.form.errors = error.response.data.errors; self.form.errors.name = (error.response.data.errors.name) ? error.response.data.errors.name : [];
self.form.errors.class = (error.response.data.errors.class) ? error.response.data.errors.class : [];
self.form.errors.sort = (error.response.data.errors.sort) ? error.response.data.errors.sort : [];
self.form.loading = false; self.form.loading = false;
}); });

View File

@ -30,11 +30,11 @@
<thead class="thead-light"> <thead class="thead-light">
<tr class="row table-head-line"> <tr class="row table-head-line">
<th class="col-sm-2 col-md-1 col-lg-1 col-xl-1 d-none d-sm-block">{{ Form::bulkActionAllGroup() }}</th> <th class="col-sm-2 col-md-1 col-lg-1 col-xl-1 d-none d-sm-block">{{ Form::bulkActionAllGroup() }}</th>
<th class="col-xs-4 col-sm-4 col-md-3 col-lg-3 col-xl-2">@sortablelink('name', trans('general.name'), ['filter' => 'active, visible'], ['class' => 'col-aka', 'rel' => 'nofollow'])</th> <th class="col-xs-4 col-sm-4 col-md-4 col-lg-4 col-xl-3">@sortablelink('name', trans('general.name'), ['filter' => 'active, visible'], ['rel' => 'nofollow'])</th>
<th class="col-md-2 col-lg-2 col-xl-3 d-none d-md-block text-left">@sortablelink('number', trans('accounts.number'))</th> <th class="col-md-2 col-lg-2 col-xl-2 d-none d-md-block text-left">@sortablelink('number', trans('accounts.number'))</th>
<th class="col-sm-2 col-md-2 col-lg-3 col-xl-4 d-none d-sm-block text-right">@sortablelink('opening_balance', trans('accounts.current_balance'))</th> <th class="col-sm-2 col-md-2 col-lg-2 col-xl-4 d-none d-sm-block text-right">@sortablelink('opening_balance', trans('accounts.current_balance'))</th>
<th class="col-xs-4 col-sm-2 col-md-2 col-lg-2 col-xl-1">@sortablelink('enabled', trans('general.enabled'))</th> <th class="col-xs-4 col-sm-2 col-md-2 col-lg-2 col-xl-1">@sortablelink('enabled', trans('general.enabled'))</th>
<th class="col-xs-4 col-sm-2 col-md-2 col-lg-1 col-xl-1 text-center">{{ trans('general.actions') }}</th> <th class="col-xs-4 col-sm-2 col-md-1 col-lg-1 col-xl-1 text-center">{{ trans('general.actions') }}</th>
</tr> </tr>
</thead> </thead>
@ -44,10 +44,10 @@
<td class="col-sm-2 col-md-1 col-lg-1 col-xl-1 d-none d-sm-block"> <td class="col-sm-2 col-md-1 col-lg-1 col-xl-1 d-none d-sm-block">
{{ Form::bulkActionGroup($item->id, $item->name) }} {{ Form::bulkActionGroup($item->id, $item->name) }}
</td> </td>
<td class="col-xs-4 col-sm-4 col-md-3 col-lg-3 col-xl-2"><a class="col-aka" href="{{ route('accounts.edit', $item->id) }}">{{ $item->name }}</a></td> <td class="col-xs-4 col-sm-4 col-md-4 col-lg-4 col-xl-3 long-texts"><a href="{{ route('accounts.edit', $item->id) }}">{{ $item->name }}</a></td>
<td class="col-md-2 col-lg-2 col-xl-3 d-none d-md-block text-left">{{ $item->number }}</td> <td class="col-md-2 col-lg-2 col-xl-2 d-none d-md-block text-left">{{ $item->number }}</td>
<td class="col-sm-2 col-md-2 col-lg-3 col-xl-4 d-none d-sm-block text-right">@money($item->balance, $item->currency_code, true)</td> <td class="col-sm-2 col-md-2 col-lg-2 col-xl-4 d-none d-sm-block text-right">@money($item->balance, $item->currency_code, true)</td>
<td class="col-xs-4 col-sm-2 col-md-2 col-lg-2 col-xl-1"> <td class="col-xs-4 col-sm-2 col-md-1 col-lg-2 col-xl-1">
@if (user()->can('update-banking-accounts')) @if (user()->can('update-banking-accounts'))
{{ Form::enabledGroup($item->id, $item->name, $item->enabled) }} {{ Form::enabledGroup($item->id, $item->name, $item->enabled) }}
@else @else

View File

@ -45,7 +45,7 @@
<tr class="row align-items-center border-top-1"> <tr class="row align-items-center border-top-1">
<td class="col-sm-2 col-md-1 col-lg-1 d-none d-sm-block">{{ Form::bulkActionGroup($item->id, $item->account->name) }}</td> <td class="col-sm-2 col-md-1 col-lg-1 d-none d-sm-block">{{ Form::bulkActionGroup($item->id, $item->account->name) }}</td>
<td class="col-sm-3 col-md-2 col-lg-2 d-none d-sm-block"><a class="col-aka" href="{{ route('reconciliations.edit', $item->id) }}">@date($item->created_at)</a></td> <td class="col-sm-3 col-md-2 col-lg-2 d-none d-sm-block"><a class="col-aka" href="{{ route('reconciliations.edit', $item->id) }}">@date($item->created_at)</a></td>
<td class="col-xs-3 col-sm-2 col-md-2 col-lg-2">{{ $item->account->name }}</td> <td class="col-xs-3 col-sm-2 col-md-2 col-lg-2 long-texts">{{ $item->account->name }}</td>
<td class="col-md-2 col-lg-2 d-none d-lg-block border-0">@date($item->started_at) - @date($item->ended_at)</td> <td class="col-md-2 col-lg-2 d-none d-lg-block border-0">@date($item->started_at) - @date($item->ended_at)</td>
<td class="col-md-2 col-lg-2 d-none d-md-block text-right">@money($item->closing_balance, $item->account->currency_code, true)</td> <td class="col-md-2 col-lg-2 d-none d-md-block text-right">@money($item->closing_balance, $item->account->currency_code, true)</td>
<td class="col-xs-4 col-sm-2 col-md-2 col-lg-2"> <td class="col-xs-4 col-sm-2 col-md-2 col-lg-2">

View File

@ -56,7 +56,7 @@
<td class="col-xs-4 col-sm-4 col-md-3 col-lg-2 col-xl-2 text-right">@money($item->amount, $item->currency_code, true)</td> <td class="col-xs-4 col-sm-4 col-md-3 col-lg-2 col-xl-2 text-right">@money($item->amount, $item->currency_code, true)</td>
<td class="col-md-2 col-lg-1 col-xl-1 d-none d-md-block text-left">{{ $item->type_title }}</td> <td class="col-md-2 col-lg-1 col-xl-1 d-none d-md-block text-left">{{ $item->type_title }}</td>
<td class="col-lg-2 col-xl-2 d-none d-lg-block text-left">{{ $item->category->name }}</td> <td class="col-lg-2 col-xl-2 d-none d-lg-block text-left">{{ $item->category->name }}</td>
<td class="col-lg-2 col-xl-2 d-none d-lg-block text-left">{{ $item->account->name }}</td> <td class="col-lg-2 col-xl-2 d-none d-lg-block text-left long-texts">{{ $item->account->name }}</td>
<td class="col-xs-4 col-sm-2 col-md-2 col-lg-3 col-xl-3 d-none d-md-block long-texts">{{ $item->description }}</td> <td class="col-xs-4 col-sm-2 col-md-2 col-lg-3 col-xl-3 d-none d-md-block long-texts">{{ $item->description }}</td>
</tr> </tr>
@endforeach @endforeach

View File

@ -53,9 +53,9 @@
<tr class="row align-items-center border-top-1"> <tr class="row align-items-center border-top-1">
<td class="col-sm-2 col-md-1 d-none d-sm-block">{{ Form::bulkActionGroup($item->id, $item->expense_transaction->account->name) }}</td> <td class="col-sm-2 col-md-1 d-none d-sm-block">{{ Form::bulkActionGroup($item->id, $item->expense_transaction->account->name) }}</td>
<td class="col-md-2 d-none d-md-block"><a class="col-aka" href="{{ route('transfers.edit', $item->id) }}">@date($item->expense_transaction->paid_at)</a></td> <td class="col-md-2 d-none d-md-block"><a class="col-aka" href="{{ route('transfers.edit', $item->id) }}">@date($item->expense_transaction->paid_at)</a></td>
<td class="col-sm-2 col-md-3 d-none d-sm-block">{{ $item->expense_transaction->account->name }}</td> <td class="col-sm-2 col-md-3 d-none d-sm-block long-texts">{{ $item->expense_transaction->account->name }}</td>
<td class="col-xs-4 col-sm-4 col-md-2">{{ $item->income_transaction->account->name }}</td> <td class="col-xs-4 col-sm-4 col-md-2 long-texts">{{ $item->income_transaction->account->name }}</td>
<td class="col-xs-4 col-sm-2 col-md-2 text-right">@money($item->expense_transaction->amount, $item->expense_transaction->currency_code, true)</td> <td class="col-xs-4 col-sm-2 col-md-2 text-right long-texts">@money($item->expense_transaction->amount, $item->expense_transaction->currency_code, true)</td>
<td class="col-xs-4 col-sm-2 col-md-2 text-center"> <td class="col-xs-4 col-sm-2 col-md-2 text-center">
<div class="dropdown"> <div class="dropdown">
<a class="btn btn-neutral btn-sm text-light items-align-center py-2" href="#" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"> <a class="btn btn-neutral btn-sm text-light items-align-center py-2" href="#" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">

View File

@ -78,7 +78,7 @@
@endif @endif
</td> </td>
<td class="col-lg-2 col-xl-2 d-none d-lg-block text-left long-texts">{{ $item->category->name }}</td> <td class="col-lg-2 col-xl-2 d-none d-lg-block text-left long-texts">{{ $item->category->name }}</td>
<td class="col-lg-2 col-xl-2 d-none d-lg-block text-left">{{ $item->account->name }}</td> <td class="col-lg-2 col-xl-2 d-none d-lg-block text-left long-texts">{{ $item->account->name }}</td>
<td class="col-xs-4 col-sm-2 col-md-2 col-lg-1 col-xl-1 text-center"> <td class="col-xs-4 col-sm-2 col-md-2 col-lg-1 col-xl-1 text-center">
<div class="dropdown"> <div class="dropdown">
<a class="btn btn-neutral btn-sm text-light items-align-center py-2" href="#" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"> <a class="btn btn-neutral btn-sm text-light items-align-center py-2" href="#" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">

View File

@ -47,7 +47,7 @@
<td class="col-sm-2 col-md-1 col-lg-1 col-xl-1 d-none d-sm-block"> <td class="col-sm-2 col-md-1 col-lg-1 col-xl-1 d-none d-sm-block">
{{ Form::bulkActionGroup($item->id, $item->name) }} {{ Form::bulkActionGroup($item->id, $item->name) }}
</td> </td>
<td class="col-xs-4 col-sm-3 col-md-4 col-lg-3 col-xl-3"> <td class="col-xs-4 col-sm-3 col-md-4 col-lg-3 col-xl-3 long-texts">
<a class="col-aka" href="{{ route('vendors.show', $item->id) }}">{{ $item->name }}</a> <a class="col-aka" href="{{ route('vendors.show', $item->id) }}">{{ $item->name }}</a>
</td> </td>
<td class="col-md-3 col-lg-3 col-xl-3 d-none d-md-block long-texts"> <td class="col-md-3 col-lg-3 col-xl-3 d-none d-md-block long-texts">

View File

@ -54,9 +54,9 @@
@stack('create_user_input_end') @stack('create_user_input_end')
<div v-if="can_login" class="row col-md-12"> <div v-if="can_login" class="row col-md-12">
{{Form::passwordGroup('password', trans('auth.password.current'), 'key', [], 'col-md-6 password')}} {{Form::passwordGroup('password', trans('auth.password.current'), 'key', ['required' => 'required'], 'col-md-6 password')}}
{{Form::passwordGroup('password_confirmation', trans('auth.password.current_confirm'), 'key', [], 'col-md-6 password')}} {{Form::passwordGroup('password_confirmation', trans('auth.password.current_confirm'), 'key', ['required' => 'required'], 'col-md-6 password')}}
</div> </div>
</div> </div>
</div> </div>

View File

@ -64,9 +64,9 @@
@stack('create_user_input_end') @stack('create_user_input_end')
<div v-if="can_login" class="row col-md-12"> <div v-if="can_login" class="row col-md-12">
{{Form::passwordGroup('password', trans('auth.password.current'), 'key', [], 'col-md-6 password')}} {{Form::passwordGroup('password', trans('auth.password.current'), 'key', ['required' => 'required'], 'col-md-6 password')}}
{{Form::passwordGroup('password_confirmation', trans('auth.password.current_confirm'), 'key', [], 'col-md-6 password')}} {{Form::passwordGroup('password_confirmation', trans('auth.password.current_confirm'), 'key', ['required' => 'required'], 'col-md-6 password')}}
</div> </div>
</div> </div>
</div> </div>

View File

@ -47,7 +47,7 @@
<td class="col-sm-2 col-md-1 col-lg-1 col-xl-1 d-none d-sm-block"> <td class="col-sm-2 col-md-1 col-lg-1 col-xl-1 d-none d-sm-block">
{{ Form::bulkActionGroup($item->id, $item->name) }} {{ Form::bulkActionGroup($item->id, $item->name) }}
</td> </td>
<td class="col-xs-4 col-sm-3 col-md-4 col-lg-3 col-xl-3"> <td class="col-xs-4 col-sm-3 col-md-4 col-lg-3 col-xl-3 long-texts">
<a class="col-aka" href="{{ route('customers.show', $item->id) }}">{{ $item->name }}</a> <a class="col-aka" href="{{ route('customers.show', $item->id) }}">{{ $item->name }}</a>
</td> </td>
<td class="col-md-3 col-lg-3 col-xl-3 d-none d-md-block long-texts"> <td class="col-md-3 col-lg-3 col-xl-3 d-none d-md-block long-texts">

View File

@ -78,7 +78,7 @@
@endif @endif
</td> </td>
<td class="col-lg-2 col-xl-2 d-none d-lg-block text-left long-texts">{{ $item->category->name }}</td> <td class="col-lg-2 col-xl-2 d-none d-lg-block text-left long-texts">{{ $item->category->name }}</td>
<td class="col-lg-2 col-xl-2 d-none d-lg-block text-left">{{ $item->account->name }}</td> <td class="col-lg-2 col-xl-2 d-none d-lg-block text-left long-texts">{{ $item->account->name }}</td>
<td class="col-xs-4 col-sm-2 col-md-2 col-lg-1 col-xl-1 text-center"> <td class="col-xs-4 col-sm-2 col-md-2 col-lg-1 col-xl-1 text-center">
<div class="dropdown"> <div class="dropdown">
<a class="btn btn-neutral btn-sm text-light items-align-center py-2" href="#" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"> <a class="btn btn-neutral btn-sm text-light items-align-center py-2" href="#" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">

View File

@ -88,7 +88,6 @@ Route::group(['prefix' => 'sales'], function () {
Route::get('customers/currency', 'Sales\Customers@currency'); Route::get('customers/currency', 'Sales\Customers@currency');
Route::get('customers/{customer}/duplicate', 'Sales\Customers@duplicate')->name('customers.duplicate'); Route::get('customers/{customer}/duplicate', 'Sales\Customers@duplicate')->name('customers.duplicate');
Route::post('customers/field', 'Sales\Customers@field')->name('customers.field');
Route::post('customers/import', 'Sales\Customers@import')->name('customers.import'); Route::post('customers/import', 'Sales\Customers@import')->name('customers.import');
Route::get('customers/export', 'Sales\Customers@export')->name('customers.export'); Route::get('customers/export', 'Sales\Customers@export')->name('customers.export');
Route::get('customers/{customer}/enable', 'Sales\Customers@enable')->name('customers.enable'); Route::get('customers/{customer}/enable', 'Sales\Customers@enable')->name('customers.enable');

View File

@ -2,9 +2,10 @@
namespace Tests\Feature\Common; namespace Tests\Feature\Common;
use App\Jobs\Common\CreateDashboard; use App\Models\Common\Widget;
use App\Models\Common\Dashboard; use App\Models\Common\Dashboard;
use Tests\Feature\FeatureTestCase; use Tests\Feature\FeatureTestCase;
use App\Jobs\Common\CreateDashboard;
class DashboardsTest extends FeatureTestCase class DashboardsTest extends FeatureTestCase
{ {
@ -12,7 +13,7 @@ class DashboardsTest extends FeatureTestCase
{ {
$this->loginAs() $this->loginAs()
->get(route('dashboard')) ->get(route('dashboard'))
->assertStatus(200) ->assertOk()
->assertSeeText(trans_choice('general.dashboards', 1)); ->assertSeeText(trans_choice('general.dashboards', 1));
} }
@ -20,7 +21,7 @@ class DashboardsTest extends FeatureTestCase
{ {
$this->loginAs() $this->loginAs()
->get(route('dashboards.index')) ->get(route('dashboards.index'))
->assertStatus(200) ->assertOk()
->assertSeeText(trans_choice('general.dashboards', 2)); ->assertSeeText(trans_choice('general.dashboards', 2));
} }
@ -28,7 +29,7 @@ class DashboardsTest extends FeatureTestCase
{ {
$this->loginAs() $this->loginAs()
->get(route('dashboards.create')) ->get(route('dashboards.create'))
->assertStatus(200) ->assertOk()
->assertSeeText(trans('general.title.new', ['type' => trans_choice('general.dashboards', 1)])); ->assertSeeText(trans('general.title.new', ['type' => trans_choice('general.dashboards', 1)]));
} }
@ -38,7 +39,7 @@ class DashboardsTest extends FeatureTestCase
$this->loginAs() $this->loginAs()
->post(route('dashboards.store'), $request) ->post(route('dashboards.store'), $request)
->assertStatus(200); ->assertOk();
$this->assertFlashLevel('success'); $this->assertFlashLevel('success');
@ -53,7 +54,7 @@ class DashboardsTest extends FeatureTestCase
$this->loginAs() $this->loginAs()
->get(route('dashboards.edit', $dashboard->id)) ->get(route('dashboards.edit', $dashboard->id))
->assertStatus(200) ->assertOk()
->assertSee($dashboard->name); ->assertSee($dashboard->name);
} }
@ -67,7 +68,7 @@ class DashboardsTest extends FeatureTestCase
$this->loginAs() $this->loginAs()
->patch(route('dashboards.update', $dashboard->id), $request) ->patch(route('dashboards.update', $dashboard->id), $request)
->assertStatus(200) ->assertOk()
->assertSee($request['name']); ->assertSee($request['name']);
$this->assertFlashLevel('success'); $this->assertFlashLevel('success');
@ -84,18 +85,83 @@ class DashboardsTest extends FeatureTestCase
$this->loginAs() $this->loginAs()
->delete(route('dashboards.destroy', $dashboard->id)) ->delete(route('dashboards.destroy', $dashboard->id))
->assertStatus(200); ->assertOk();
$this->assertFlashLevel('success'); $this->assertFlashLevel('success');
$this->assertSoftDeleted('dashboards', $this->getAssertRequest($request)); $this->assertSoftDeleted('dashboards', $this->getAssertRequest($request));
} }
public function testItShouldSeeWidgetCreate()
{
$classes = Widget::factory()->classes;
$class = $classes[rand(0, 9)];
$this->loginAs()
->get(route('widgets.index'))
->assertOk()
->assertSeeText((new $class())->getDefaultName());
}
public function testItShouldSeeWidgetEdit()
{
$widget = Widget::create($this->getWidget());
$this->loginAs()
->get(route('widgets.edit', $widget->id))
->assertOk()
->assertSee($widget->name);
}
public function testItShouldCreateWidget()
{
$request = $this->getWidget();
$this->loginAs()
->post(route('widgets.store'), $request)
->assertOk();
$this->assertDatabaseHas('widgets', $this->getAssertRequest($request));
}
public function testItShouldUpdateWidget()
{
$request = $this->getWidget();
$widget = Widget::create($request);
$request['name'] = $this->faker->name;
$this->loginAs()
->patch(route('widgets.update', $widget->id), $request)
->assertOk();
$this->assertDatabaseHas('widgets', $this->getAssertRequest($request));
}
public function testItShouldDeleteWidget()
{
$request = $this->getWidget();
$widget = Widget::create($request);
$this->loginAs()
->delete(route('widgets.destroy', $widget->id))
->assertOk();
$this->assertSoftDeleted('widgets', $this->getAssertRequest($request));
}
public function getRequest() public function getRequest()
{ {
return Dashboard::factory()->enabled()->users()->raw(); return Dashboard::factory()->enabled()->users()->raw();
} }
public function getWidget()
{
return Widget::factory()->raw();
}
public function getAssertRequest($request) public function getAssertRequest($request)
{ {
unset($request['users']); unset($request['users']);