Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
iamgergo committed Jul 1, 2024
1 parent 4c49764 commit 0e88b9c
Show file tree
Hide file tree
Showing 18 changed files with 160 additions and 182 deletions.
2 changes: 1 addition & 1 deletion src/Http/Controllers/NotificationController.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,6 @@ public function destroy(Request $request, string $id): JsonResponse

$notification->delete();

return new JsonResponse($notification);
return new JsonResponse(['deleted' => true]);
}
}
8 changes: 8 additions & 0 deletions src/Widgets/Widget.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,14 @@ public function getUriKey(): string
return $this->getKey();
}

/**
* Get the blade template.
*/
public function getTemplate(): string
{
return $this->template;
}

/**
* Get the view data.
*/
Expand Down
2 changes: 1 addition & 1 deletion tests/Fields/RepeaterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public function test_a_repeater_field_has_repeater_template(): void
$this->assertSame('root::fields.repeater', $this->field->getTemplate());
}

public function test_a_repeater_field_register_routes(): void
public function test_a_repeater_field_registers_routes(): void
{
$this->app['router']->prefix('posts/fields')->group(function ($router) {
$this->field->registerRoutes($this->app['request'], $router);
Expand Down
2 changes: 1 addition & 1 deletion tests/Http/ActionControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public function setUp(): void
$this->admin = User::factory()->create();
}

public function test_an_action_controller_handles_action_request(): void
public function test_action_controller_handles_action_request(): void
{
$this->actingAs($this->admin)
->post('/root/users/actions/send-password-reset-notification')
Expand Down
8 changes: 4 additions & 4 deletions tests/Http/BelongsToManyControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public function setUp(): void
});
}

public function test_a_belongs_to_many_controller_handles_index(): void
public function test_belongs_to_many_controller_handles_index(): void
{
$this->actingAs($this->admin)
->get('/root/users/'.$this->admin->getKey().'/fields/teams')
Expand All @@ -46,7 +46,7 @@ public function test_a_belongs_to_many_controller_handles_index(): void
->assertViewHas($this->field->toIndex($this->app['request'], $this->admin));
}

public function test_a_belongs_to_many_controller_handles_store(): void
public function test_belongs_to_many_controller_handles_store(): void
{
$team = Team::factory()->create();

Expand All @@ -65,7 +65,7 @@ public function test_a_belongs_to_many_controller_handles_store(): void
]);
}

public function test_a_belongs_to_many_controller_handles_update(): void
public function test_belongs_to_many_controller_handles_update(): void
{
$team = $this->admin->teams->first();

Expand All @@ -82,7 +82,7 @@ public function test_a_belongs_to_many_controller_handles_update(): void
$this->assertSame('member', $team->pivot->refresh()->role);
}

public function test_a_belongs_to_many_controller_handles_destroy(): void
public function test_belongs_to_many_controller_handles_destroy(): void
{
$team = $this->admin->teams->first();

Expand Down
2 changes: 1 addition & 1 deletion tests/Http/DashboardControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public function setUp(): void
$this->admin = User::factory()->create();
}

public function test_a_dashboard_controller_handles_request(): void
public function test_dashboard_controller_handles_request(): void
{
$this->actingAs($this->admin)
->get('/root')
Expand Down
2 changes: 1 addition & 1 deletion tests/Http/DownloadControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public function setUp(): void
$this->admin = User::factory()->create();
}

public function test_a_download_controller_handles_request(): void
public function test_download_controller_handles_request(): void
{
$medium = Medium::factory()->create();

Expand Down
36 changes: 0 additions & 36 deletions tests/Http/ForgotPasswordControllerTest.php

This file was deleted.

56 changes: 0 additions & 56 deletions tests/Http/LoginControllerTest.php

This file was deleted.

6 changes: 3 additions & 3 deletions tests/Http/MediaControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,15 @@ public function setUp(): void
});
}

public function test_a_media_controller_handles_index(): void
public function test_media_controller_handles_index(): void
{
$this->actingAs($this->admin)
->get('/root/users/'.$this->admin->getKey().'/fields/media')
->assertOk()
->assertJson($this->field->paginateRelatable($this->app['request'], $this->admin)->toArray());
}

public function test_a_media_controller_handles_store(): void
public function test_media_controller_handles_store(): void
{
Queue::fake();

Expand All @@ -59,7 +59,7 @@ public function test_a_media_controller_handles_store(): void
Queue::assertPushedWithChain(MoveFile::class, [PerformConversions::class]);
}

public function test_a_media_controller_handles_destroy(): void
public function test_media_controller_handles_destroy(): void
{
$medium = Medium::factory()->create();

Expand Down
2 changes: 1 addition & 1 deletion tests/Http/MorphToControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public function setUp(): void
$this->admin = User::factory()->create();
}

public function test_a_morph_to_controller_handles_request(): void
public function test_morph_to_controller_handles_request(): void
{
$this->actingAs($this->admin)
->get('/root/users/'.$this->admin->getKey().'/fields/employer')
Expand Down
61 changes: 61 additions & 0 deletions tests/Http/NotificationControllerTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
<?php

namespace Cone\Root\Tests\Http;

use Cone\Root\Models\Notification;
use Cone\Root\Tests\TestCase;
use Cone\Root\Tests\User;

class NotificationControllerTest extends TestCase
{
protected User $admin;

protected Notification $notification;

public function setUp(): void
{
parent::setUp();

$this->admin = User::factory()->create();

$this->notification = Notification::factory()->unread()->for($this->admin, 'notifiable')->create();
}

public function test_notification_controller_handles_index(): void
{
$this->actingAs($this->admin)
->get('/root/api/notifications')
->assertOk()
->assertJson($this->admin->rootNotifications()->paginate()->toArray());
}

public function test_notification_controller_handles_show(): void
{
$this->actingAs($this->admin)
->get('/root/api/notifications/'.$this->notification->getKey())
->assertOk()
->assertJson($this->notification->toArray());
}

public function test_notification_controller_handles_update(): void
{
$this->assertTrue($this->notification->unread());

$this->actingAs($this->admin)
->patch('/root/api/notifications/'.$this->notification->getKey())
->assertOk()
->assertJson($this->notification->refresh()->toArray());

$this->assertTrue($this->notification->read());
}

public function test_notification_controller_handles_destroy(): void
{
$this->actingAs($this->admin)
->delete('/root/api/notifications/'.$this->notification->getKey())
->assertOk()
->assertJson(['deleted' => true]);

$this->assertDatabaseMissing('root_notifications', ['id' => $this->notification->getKey()]);
}
}
14 changes: 7 additions & 7 deletions tests/Http/RelationControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public function setUp(): void
);
}

public function test_a_relation_controller_handles_index(): void
public function test_relation_controller_handles_index(): void
{
$this->actingAs($this->admin)
->get('/root/users/'.$this->admin->getKey().'/fields/uploads')
Expand All @@ -44,7 +44,7 @@ public function test_a_relation_controller_handles_index(): void
->assertViewHas($this->field->toIndex($this->app['request'], $this->admin));
}

public function test_a_relation_controller_handles_create(): void
public function test_relation_controller_handles_create(): void
{
$this->actingAs($this->admin)
->get('/root/users/'.$this->admin->getKey().'/fields/uploads/create')
Expand All @@ -53,7 +53,7 @@ public function test_a_relation_controller_handles_create(): void
->assertViewHas($this->field->toCreate($this->app['request'], $this->admin));
}

public function test_a_relation_controller_handles_store(): void
public function test_relation_controller_handles_store(): void
{
$this->actingAs($this->admin)
->post('/root/users/'.$this->admin->getKey().'/fields/uploads', $data = Medium::factory()->make()->toArray())
Expand All @@ -65,7 +65,7 @@ public function test_a_relation_controller_handles_store(): void
);
}

public function test_a_relation_controller_handles_show(): void
public function test_relation_controller_handles_show(): void
{
$this->app['request']->setRouteResolver(function () {
return $this->app['router']->getRoutes()->get('GET')['root/users/{resourceModel}/fields/uploads/{usersUpload}'];
Expand All @@ -78,7 +78,7 @@ public function test_a_relation_controller_handles_show(): void
->assertViewHas($this->field->toShow($this->app['request'], $this->admin, $this->medium));
}

public function test_a_relation_controller_handles_edit(): void
public function test_relation_controller_handles_edit(): void
{
$this->app['request']->setRouteResolver(function () {
return $this->app['router']->getRoutes()->get('GET')['root/users/{resourceModel}/fields/uploads/{usersUpload}/edit'];
Expand All @@ -91,7 +91,7 @@ public function test_a_relation_controller_handles_edit(): void
->assertViewHas($this->field->toEdit($this->app['request'], $this->admin, $this->medium));
}

public function test_a_relation_controller_handles_update(): void
public function test_relation_controller_handles_update(): void
{
$this->app['request']->setRouteResolver(function () {
return $this->app['router']->getRoutes()->get('PATCH')['root/users/{resourceModel}/fields/uploads/{usersUpload}'];
Expand All @@ -108,7 +108,7 @@ public function test_a_relation_controller_handles_update(): void
$this->assertSame('updated.png', $this->medium->refresh()->file_name);
}

public function test_a_relation_controller_handles_destroy(): void
public function test_relation_controller_handles_destroy(): void
{
$this->app['request']->setRouteResolver(function () {
return $this->app['router']->getRoutes()->get('DELETE')['root/users/{resourceModel}/fields/uploads/{usersUpload}'];
Expand Down
2 changes: 1 addition & 1 deletion tests/Http/RepeaterControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public function setUp(): void
$this->admin = User::factory()->create();
}

public function test_a_repeater_controller_handles_request(): void
public function test_repeater_controller_handles_request(): void
{
$this->actingAs($this->admin)
->post('/root/users/'.$this->admin->getKey().'/fields/settings')
Expand Down
Loading

0 comments on commit 0e88b9c

Please sign in to comment.