diff --git a/app/Http/Controllers/ReceptionScreenController.php b/app/Http/Controllers/ReceptionScreenController.php deleted file mode 100644 index a402db0..0000000 --- a/app/Http/Controllers/ReceptionScreenController.php +++ /dev/null @@ -1,82 +0,0 @@ -middleware('auth'); - } - public function index(): View|Application|Factory|\Illuminate\Contracts\Foundation\Application - { - abort_if(Auth::guest(), 403); - - $receptionScreens = ReceptionScreen::all()->sortBy('position'); - return view('admin-reception-screen.index', compact('receptionScreens')); - } - - public function create(): View - { - abort_if(Auth::guest(), 403); - - $receptionScreens = ReceptionScreen::all()->sortBy('position'); - return view('admin-reception-screen.create', compact('receptionScreens')); - } - - public function store(StoreReceptionScreenRequest $request) - { - abort_if(Auth::guest(), 403); - - $validated = $request->validated(); - $receptionScreen = new ReceptionScreen(); - $receptionScreen->name = $validated['name']; - $receptionScreen->position = $validated['position']; - $receptionScreen->save(); - - return redirect()->route('admin-reception-screen.index'); - } - public function edit($id) - { - abort_if(Auth::guest(), 403); - - $receptionScreen = new ReceptionScreen(); - $currentReceptionScreen = $receptionScreen->find($id); - $receptionScreens = $receptionScreen->all()->sortBy('position'); - return view('admin-reception-screen.edit', compact('currentReceptionScreen', 'receptionScreens')); - } - - public function update(UpdateReceptionScreenRequest $request, $id) - { - abort_if(Auth::guest(), 403); - - $validated = $request->validated(); - $receptionScreen = new ReceptionScreen(); - $currentReceptionScreen = $receptionScreen->find($id); - $currentReceptionScreen->name = $validated['name']; - $currentReceptionScreen->position = $validated['position']; - $currentReceptionScreen->save(); - - return redirect()->route('admin-reception-screen.index'); - } - - public function destroy($id) - { - $receptionScreen = new ReceptionScreen(); - $currentReceptionScreen = $receptionScreen->find($id); - if ($currentReceptionScreen->files()->exists()) { - return back(); - } - $currentReceptionScreen->delete(); - - return redirect()->route('admin-reception-screen.index'); - } -} diff --git a/app/Http/Controllers/admin/AdmissionController.php b/app/Http/Controllers/admin/AdmissionController.php new file mode 100644 index 0000000..a19f69a --- /dev/null +++ b/app/Http/Controllers/admin/AdmissionController.php @@ -0,0 +1,72 @@ +sortBy('position'); + return view('admin.admission.index', compact('admissions')); + } + + public function create() + { + $admissions = Admission::all()->sortBy('position'); + return view('admin.admission.create', compact('admissions')); + } + + public function store(StoreAdmissionRequest $request) + { + $validated = $request->validated(); + + $admission = new Admission(); + $admission->name = $validated['name']; + $admission->description = $validated['description']; + $admission->slug = $validated['slug']; + $admission->position = $validated['position']; + $admission->save(); + + return redirect()->route('admissions.index'); + } + + public function show(Admission $admission) + { + return view('admin.admission.show', compact('admission')); + } + + public function edit(Admission $admission) + { + return view('admin.admission.edit', compact('admission')); + } + + public function update(UpdateAdmissionRequest $request, Admission $admission) + { + $validated = $request->validated(); + + $admission->name = $validated['name']; + $admission->description = $validated['description']; + $admission->slug = $validated['slug']; + $admission->position = $validated['position']; + $admission->save(); + + return redirect()->route('admissions.index'); + } + + /** + * Remove the specified resource from storage. + */ + public function destroy(Admission $admission) + { + if ($admission->documents()->exists()) { + return back(); + } + $admission->delete(); + return redirect()->route('admissions.index'); + } +} diff --git a/app/Http/Requests/StoreReceptionScreenRequest.php b/app/Http/Requests/StoreReceptionScreenRequest.php deleted file mode 100644 index b03e0aa..0000000 --- a/app/Http/Requests/StoreReceptionScreenRequest.php +++ /dev/null @@ -1,29 +0,0 @@ -|string> - */ - public function rules(): array - { - return [ - 'name' => 'required|max:255', - 'position' => 'required||int|max:255', - ]; - } -} diff --git a/app/Http/Requests/UpdateReceptionScreenRequest.php b/app/Http/Requests/UpdateReceptionScreenRequest.php deleted file mode 100644 index dad4306..0000000 --- a/app/Http/Requests/UpdateReceptionScreenRequest.php +++ /dev/null @@ -1,29 +0,0 @@ -|string> - */ - public function rules(): array - { - return [ - 'name' => 'required|max:255', - 'position' => 'required||int|max:255', - ]; - } -} diff --git a/app/Http/Requests/admin/StoreAdmissionRequest.php b/app/Http/Requests/admin/StoreAdmissionRequest.php new file mode 100644 index 0000000..30694d5 --- /dev/null +++ b/app/Http/Requests/admin/StoreAdmissionRequest.php @@ -0,0 +1,23 @@ + 'required|int|max:255', + 'name' => 'required|string|max:255|unique:admissions,name', + 'description' => 'string', + 'slug' => 'required|string', + ]; + } +} diff --git a/app/Http/Requests/admin/UpdateAdmissionRequest.php b/app/Http/Requests/admin/UpdateAdmissionRequest.php new file mode 100644 index 0000000..1acd5ce --- /dev/null +++ b/app/Http/Requests/admin/UpdateAdmissionRequest.php @@ -0,0 +1,28 @@ + 'required|int|max:255', + 'description' => 'string', + 'slug' => 'string|required', + 'name' => [ + 'required', + 'string', + 'max:255', + "unique:admissions,name,{$this->admission->id}", + ], + ]; + } +} diff --git a/app/Models/ReceptionScreen.php b/app/Models/Admission.php similarity index 67% rename from app/Models/ReceptionScreen.php rename to app/Models/Admission.php index ae66db4..a556810 100644 --- a/app/Models/ReceptionScreen.php +++ b/app/Models/Admission.php @@ -6,7 +6,7 @@ use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Relations\HasMany; -class ReceptionScreen extends Model +class Admission extends Model { use HasFactory; @@ -16,8 +16,8 @@ class ReceptionScreen extends Model 'position' ]; - public function files(): HasMany + public function documents(): HasMany { - return $this->hasMany('App\Models\File', 'reception_screen_id'); + return $this->hasMany('App\Models\Document', 'admission_id'); } } diff --git a/app/Policies/ReceptionScreenPolicy.php b/app/Policies/ReceptionScreenPolicy.php deleted file mode 100644 index 253bd14..0000000 --- a/app/Policies/ReceptionScreenPolicy.php +++ /dev/null @@ -1,66 +0,0 @@ - fake()->name(), + 'description' => fake()->text(), + 'slug' => fake()->slug(), + 'position' => fake()->randomDigit(), + ]; + } +} diff --git a/database/factories/ReceptionScreenFactory.php b/database/factories/ReceptionScreenFactory.php deleted file mode 100644 index 66876ae..0000000 --- a/database/factories/ReceptionScreenFactory.php +++ /dev/null @@ -1,23 +0,0 @@ - - */ -class ReceptionScreenFactory extends Factory -{ - /** - * Define the model's default state. - * - * @return array - */ - public function definition(): array - { - return [ - // - ]; - } -} diff --git a/database/migrations/2024_01_18_082251_create_reception_screens_table.php b/database/migrations/2024_01_18_082250_create_admissions_table.php similarity index 72% rename from database/migrations/2024_01_18_082251_create_reception_screens_table.php rename to database/migrations/2024_01_18_082250_create_admissions_table.php index 0c25a1b..66a5c20 100644 --- a/database/migrations/2024_01_18_082251_create_reception_screens_table.php +++ b/database/migrations/2024_01_18_082250_create_admissions_table.php @@ -11,9 +11,11 @@ return new class extends Migration */ public function up(): void { - Schema::create('reception_screens', function (Blueprint $table) { + Schema::create('admissions', function (Blueprint $table) { $table->id(); $table->string('name'); + $table->text('description'); + $table->string('slug'); $table->integer('position'); $table->timestamps(); }); @@ -24,6 +26,6 @@ return new class extends Migration */ public function down(): void { - Schema::dropIfExists('reception_screens'); + Schema::dropIfExists('admissions'); } }; diff --git a/database/migrations/2024_01_22_070323_create_submenu_table.php b/database/migrations/2024_01_22_070323_create_submenu_table.php deleted file mode 100644 index c935591..0000000 --- a/database/migrations/2024_01_22_070323_create_submenu_table.php +++ /dev/null @@ -1,33 +0,0 @@ -id(); - $table->string('name'); - $table->string('description'); - $table->string('parent'); - $table->string('meta_title'); - $table->string('meta_description'); - $table->string('meta_keywords'); - $table->timestamps(); - }); - } - - /** - * Reverse the migrations. - */ - public function down(): void - { - Schema::dropIfExists('submenu'); - } -}; diff --git a/database/seeders/AdmissionSeeder.php b/database/seeders/AdmissionSeeder.php new file mode 100644 index 0000000..7454189 --- /dev/null +++ b/database/seeders/AdmissionSeeder.php @@ -0,0 +1,37 @@ +insert([ + [ + 'name' => 'Пункт 1', + 'position' => 2, + 'description' => 'description 1', + 'slug' => 'point-1', + 'created_at' => now(), + ], + [ + 'name' => 'Пункт 2', + 'position' => 3, + 'description' => 'description 2', + 'slug' => 'point-2', + 'created_at' => now(), + ], + [ + 'name' => 'Пункт 3', + 'description' => 'description 3', + 'position' => 1, + 'slug' => 'point-3', + 'created_at' => now(), + ] + ]); + } +} diff --git a/database/seeders/DatabaseSeeder.php b/database/seeders/DatabaseSeeder.php index 45fe4a2..711c6fa 100644 --- a/database/seeders/DatabaseSeeder.php +++ b/database/seeders/DatabaseSeeder.php @@ -21,12 +21,15 @@ class DatabaseSeeder extends Seeder User::factory(10)->create(); $this->call([ - ReceptionScreenSeeder::class, - DocumentSeeder::class, EducationalInstitutionSeeder::class, FacultySeeder::class, DepartmentSeeder::class, DirectionSeeder::class, ]); + + $this->call([ + AdmissionSeeder::class, + DocumentSeeder::class, + ]); } } diff --git a/database/seeders/ReceptionScreenSeeder.php b/database/seeders/ReceptionScreenSeeder.php deleted file mode 100644 index 7d5d213..0000000 --- a/database/seeders/ReceptionScreenSeeder.php +++ /dev/null @@ -1,35 +0,0 @@ -insert([ - [ - 'name' => 'Пункт 1 с файлами', - 'position' => 2, - 'created_at' => Carbon::now(), - ], - [ - 'name' => 'Пункт 2 с файлами', - 'position' => 3, - 'created_at' => Carbon::now(), - ], - [ - 'name' => 'Пункт 3 с файлами', - 'position' => 1, - 'created_at' => Carbon::now(), - ] - ]); - } -} diff --git a/resources/js/app.js b/resources/js/app.js index ccb88a8..22a5851 100644 --- a/resources/js/app.js +++ b/resources/js/app.js @@ -1,4 +1,4 @@ -import './bootstrap'; +// import './bootstrap'; import Alpine from 'alpinejs'; import ujs from '@rails/ujs'; diff --git a/resources/views/admin-reception-screen/edit.blade.php b/resources/views/admin-reception-screen/edit.blade.php deleted file mode 100644 index 82c7eff..0000000 --- a/resources/views/admin-reception-screen/edit.blade.php +++ /dev/null @@ -1,60 +0,0 @@ -@extends('layouts.admin-layout') -@section('content') - - @auth() -
-
-

Изменить пункт Экрана приема

- - {{ Form::open(['url' => route('admin-reception-screen.update', $currentReceptionScreen), 'method' => 'PATCH', 'class' => '']) }} -
-
- {{ Form::label('position', 'Позиция') }} -
-
- {{ Form::text('position', $currentReceptionScreen->position, ['class' => 'form-control']) }} -
-
- @if ($errors->any()) - {{ $errors->first('position') }} - @endif -
- -
- {{ Form::label('name', 'Название') }} -
-
- {{ Form::text('name', $currentReceptionScreen->name, ['class' => 'form-control']) }} -
-
- @if ($errors->any()) - {{ $errors->first('name') }} - @endif -
- -
- {{ Form::submit('Изменить', ['class' => 'btn btn-primary']) }} -
-
- {{ Form::close() }} -
-
- - - - - - - - - @foreach($receptionScreens as $receptionScreen) - - - - @endforeach - -
ПозицияНазвание
{{ $receptionScreen->position }}{{ $receptionScreen->name }}
-
-
- @endauth -@endsection diff --git a/resources/views/admin-reception-screen/index.blade.php b/resources/views/admin-reception-screen/index.blade.php deleted file mode 100644 index 89d8d4c..0000000 --- a/resources/views/admin-reception-screen/index.blade.php +++ /dev/null @@ -1,144 +0,0 @@ -@extends('layouts.admin-layout') -@section('content') - -
-

Экран Приема

-
- Создать пункт Экрана приема -
-
- - - - - - - - - - - - @foreach($receptionScreens as $receptionScreen) - name) ?> - - - - - - - @if(count($receptionScreen->files) !== 0) - - - - - @else - - - - @endif - @endforeach - -
ПозицияНазваниедействия
{{ $receptionScreen->position }}{{ $receptionScreen->name }}редактировать - - удалить - - - -
- - - - - - - - - - - - - - @foreach($receptionScreen->files->sortBy('position') as $file) - - - - - - - @endforeach - - - - - - - - -
ПозицияИмя Файладействия
{{ $file->position }}{{ $file->name }}редактировать - - удалить - -
- - -
- @php($idReceptionScreen = $receptionScreen->id) - Добавить - файл -
-
-
-
- - - - - - - - - - - - - - - - - - - - - - - - - - -@endsection diff --git a/resources/views/admin-reception-screen/create.blade.php b/resources/views/admin/admission/create.blade.php similarity index 60% rename from resources/views/admin-reception-screen/create.blade.php rename to resources/views/admin/admission/create.blade.php index 5d14036..6c23b30 100644 --- a/resources/views/admin-reception-screen/create.blade.php +++ b/resources/views/admin/admission/create.blade.php @@ -1,11 +1,11 @@ -@extends('layouts.admin-layout') +@extends('layouts.admin_layout') @section('content') @auth()

Создать пункт Экрана приема

- {{ Form::open(['url' => route('admin-reception-screen.store'), 'method' => 'POST', 'class' => '']) }} + {{ Form::open(['url' => route('admissions.store'), 'method' => 'POST', 'class' => '']) }}
{{ Form::label('position', 'Позиция') }} @@ -31,6 +31,30 @@ @endif
+
+ {{ Form::label('description', 'Описание') }} +
+
+ {{ Form::text('description', '', ['class' => 'form-control']) }} +
+
+ @if ($errors->any()) + {{ $errors->first('description') }} + @endif +
+ +
+ {{ Form::label('slug', 'URL') }} +
+
+ {{ Form::text('slug', '', ['class' => 'form-control']) }} +
+
+ @if ($errors->any()) + {{ $errors->first('description') }} + @endif +
+
{{ Form::submit('создать', ['class' => 'btn btn-primary']) }}
@@ -46,10 +70,10 @@ - @foreach($receptionScreens as $receptionScreen) + @foreach($admissions->sortBy('position') as $admission) - {{ $receptionScreen->position }} - {{ $receptionScreen->name }} + {{ $admission->position }} + {{ $admission->name }} @endforeach diff --git a/resources/views/admin/admission/edit.blade.php b/resources/views/admin/admission/edit.blade.php new file mode 100644 index 0000000..f8eda41 --- /dev/null +++ b/resources/views/admin/admission/edit.blade.php @@ -0,0 +1,66 @@ +@extends('layouts.admin_layout') +@section('content') + + @auth() +
+
+

Изменить пункт меню Экрана приема

+ {{ Form::open(['url' => route('admissions.update', $admission), 'method' => 'PATCH', 'class' => '']) }} +
+
+ {{ Form::label('position', 'Позиция') }} +
+
+ {{ Form::text('position', $admission->position, ['class' => 'form-control']) }} +
+
+ @if ($errors->any()) + {{ $errors->first('position') }} + @endif +
+ +
+ {{ Form::label('name', 'Название') }} +
+
+ {{ Form::text('name', $admission->name, ['class' => 'form-control']) }} +
+
+ @if ($errors->any()) + {{ $errors->first('name') }} + @endif +
+ +
+ {{ Form::label('description', 'Описание') }} +
+
+ {{ Form::text('description', $admission->description, ['class' => 'form-control']) }} +
+
+ @if ($errors->any()) + {{ $errors->first('description') }} + @endif +
+ +
+ {{ Form::label('slug', 'URL') }} +
+
+ {{ Form::text('slug', $admission->slug, ['class' => 'form-control']) }} +
+
+ @if ($errors->any()) + {{ $errors->first('description') }} + @endif +
+ +
+ {{ Form::submit('Изменить', ['class' => 'btn btn-primary']) }} +
+
+ {{ Form::close() }} +
+
+ @endauth +@endsection diff --git a/resources/views/admin/admission/index.blade.php b/resources/views/admin/admission/index.blade.php new file mode 100644 index 0000000..da41bd3 --- /dev/null +++ b/resources/views/admin/admission/index.blade.php @@ -0,0 +1,109 @@ +@extends('layouts.admin_layout') +@section('content') +
+

Меню экрана приема

+
+ Добавить меню экрана приема +
+
+ + + + + + + + + + + @foreach($admissions as $admission) + + + + + + @if(count($admission->documents) !== 0) + + + + + + + + @else + + + + + + @endif + @endforeach + +
ПозицияНазваниедействия
{{ $admission->position }}{{ $admission->name }} + @if(count($admission->documents) !== 0) + -- {{ count($admission->documents) }} файла(ов) + @endif + редактировать + удалить + + + +
+
+ + + + + + + + + + @foreach($admission->documents as $document) + + + + + + @endforeach + + + + +
ПозицияИмя Файладействия
{{ $document->position }}{{ $document->name }}редактировать + + удалить + +
+ +
+
+
+ Сверунть +
+ Добавить + файл +
+
+
+
+ +@endsection diff --git a/resources/views/admin/admission/show.blade.php b/resources/views/admin/admission/show.blade.php new file mode 100644 index 0000000..36cc2bc --- /dev/null +++ b/resources/views/admin/admission/show.blade.php @@ -0,0 +1,19 @@ +@extends('layouts.admin_layout') +@section('content') + @auth() +
+

Название

+

{{ $admission->name }}

+

Описание

+

{{ $admission->description }}

+

Позиция

+

{{ $admission->position }}

+

URL

+

{{ $admission->slug }}

+

Документы

+ @foreach($admission->documents as $document) +

{{ $document->name }}

+ @endforeach +
+ @endauth +@endsection diff --git a/routes/admin.php b/routes/admin.php index 8fcc68b..707d223 100644 --- a/routes/admin.php +++ b/routes/admin.php @@ -1,11 +1,11 @@ prefix('admin')->group(function () { @@ -13,7 +13,7 @@ Route::middleware(['auth', 'verified'])->prefix('admin')->group(function () { return view('admin'); })->name('dashboard'); - Route::get('/documents/create/{document?}', [DocumentController::class, 'create'])->name('documents_create'); + Route::get('/documents/create/{admission}', [DocumentController::class, 'createFromAdmission'])->name('documents_create_with_admission'); Route::get('/documents/download/{Document}', [DocumentController::class, 'download'])->name('documents_download'); Route::resource('/educational_institutions', EducationalInstitutionController::class) @@ -25,10 +25,12 @@ Route::middleware(['auth', 'verified'])->prefix('admin')->group(function () { ->scoped(['department' => 'slug']); Route::resource('/faculties', FacultyController::class) ->scoped(['faculty' => 'slug']); + Route::resource('/faculties', FacultyController::class) + ->scoped(['faculty' => 'slug']); + Route::resource('/admissions', AdmissionController::class); Route::resources([ '/documents' => DocumentController::class, '/users' => UserController::class, - '/admin-reception-screen' => ReceptionScreenController::class, ]); }); diff --git a/tests/Feature/ReceptionScreenTest.php b/tests/Feature/ReceptionScreenTest.php deleted file mode 100644 index 945baec..0000000 --- a/tests/Feature/ReceptionScreenTest.php +++ /dev/null @@ -1,131 +0,0 @@ -user = User::factory()->make()->only([ - 'name', - 'email', - 'password' - ]); - $this->adminUser = User::factory()->create([ - 'name' => 'admin', - 'email' => 'test@example.com', - 'password' => 123456 - ]); - $this->noAdminUser = User::factory()->create([ - 'name' => 'noadmin', - 'email' => 'notest@example.com', - 'password' => 'no123456' - ]); - } - public function testUsersPage(): void - { - $response = $this->actingAs($this->adminUser) - ->withSession(['banned' => false]) - ->get(route('users.index')); - - $response->assertOk(); - } - - public function testNoAdminNoSeeUsersPage(): void - { - $response = $this->actingAs($this->noAdminUser) - ->withSession(['banned' => false]) - ->get(route('users.index')); - - $response->assertStatus(403); - } - - public function testCreateUserPage(): void - { - $response = $this->actingAs($this->adminUser) - ->withSession(['banned' => false]) - ->get(route('users.create')); - - $response->assertOk(); - } - public function testNoAdminCreateUserPage(): void - { - $response = $this->actingAs($this->noAdminUser) - ->withSession(['banned' => false]) - ->get(route('users.create')); - - $response->assertStatus(403); - } - - public function testStoreUser(): void - { - $response = $this->actingAs($this->adminUser) - ->withSession(['banned' => false]) - ->post(route('users.store', $this->user)); - - $response->assertRedirect(route('users.index')); - - $this->assertDatabaseHas('users', $this->user); - } - - public function testNoAdminNoStoreUser(): void - { - $response = $this->actingAs($this->noAdminUser) - ->withSession(['banned' => false]) - ->post(route('users.store', $this->user)); - - $response->assertStatus(403); - - $this->assertDatabaseMissing('users', $this->user); - } - - public function testEditUserPage(): void - { - $response = $this->actingAs($this->adminUser) - ->withSession(['banned' => false]) - ->get(route('users.edit', $this->adminUser)); - - $response->assertOk(); - } - public function testNoAdminEditUserPage(): void - { - $response = $this->actingAs($this->noAdminUser) - ->withSession(['banned' => false]) - ->get(route('users.edit', $this->noAdminUser)); - - $response->assertStatus(403); - } - - public function testUpdateUser(): void - { - $response = $this->actingAs($this->adminUser) - ->withSession(['banned' => false]) - ->patch(route('users.update', $this->noAdminUser), $this->user); - - $response->assertRedirect(route('users.index')); - - $dataWithOutHashPassword = $this->user; - unset($dataWithOutHashPassword['password']); - $this->assertDatabaseHas('users', $dataWithOutHashPassword); - } - - public function testNoAdminNoUpdateUser(): void - { - $response = $this->actingAs($this->noAdminUser) - ->withSession(['banned' => false]) - ->patch(route('users.update', $this->noAdminUser), $this->user); - - $response->assertStatus(403); - - $noAdminData = $this->noAdminUser->only(['name', 'email', 'password']); - $this->assertDatabaseHas('users', $noAdminData); - $this->assertDatabaseMissing('users', $this->user); - } -} diff --git a/tests/Feature/admin/AdmissionTest.php b/tests/Feature/admin/AdmissionTest.php new file mode 100644 index 0000000..a24de03 --- /dev/null +++ b/tests/Feature/admin/AdmissionTest.php @@ -0,0 +1,101 @@ +admission = Admission::factory()->create(); + + $this->data = Admission::factory()->make()->only([ + 'position', + 'name', + 'description', + 'slug', + ]); + + $this->user = User::factory()->create([ + 'name' => 'admin', + 'email' => 'test@example.com', + 'password' => 123456 + ]); + } + + public function testIndexAdmissionsPage(): void + { + $response = $this->actingAs($this->user) + ->withSession(['banned' => false]) + ->get(route('admissions.index')); + + $response->assertOk(); + } + + public function testCreateAdmissionPage(): void + { + $response = $this->actingAs($this->user) + ->withSession(['banned' => false]) + ->get(route('admissions.create')); + + $response->assertOk(); + } + + public function testStoreAdmission(): void + { + $response = $this->actingAs($this->user) + ->withSession(['banned' => false]) + ->post(route('admissions.store', $this->data)); + + $response->assertRedirect(route('admissions.index')); + + $this->assertDatabaseHas('admissions', $this->data); + } + + public function testShowAdmissionPage(): void + { + $response = $this->actingAs($this->user) + ->withSession(['banned' => false]) + ->get(route('admissions.show', $this->admission)); + + $response->assertOk(); + } + + public function testEditAdmissionPage(): void + { + $response = $this->actingAs($this->user) + ->withSession(['banned' => false]) + ->get(route('admissions.edit', $this->admission)); + + $response->assertOk(); + } + + public function testUpdateAdmission(): void + { + $response = $this->actingAs($this->user) + ->withSession(['banned' => false]) + ->patch(route('admissions.update', $this->admission), $this->data); + + $response->assertRedirect(route('admissions.index')); + + $this->assertDatabaseHas('admissions', $this->data); + } + + public function testDestroyFaculty(): void + { + $response = $this->actingAs($this->user) + ->withSession(['banned' => false]) + ->delete(route('admissions.destroy', $this->admission)); + + $response->assertRedirect(route('admissions.index')); + + $this->assertDatabaseMissing('faculties', $this->admission->toArray()); + } +}