Skip to content

Commit

Permalink
Update github tests
Browse files Browse the repository at this point in the history
  • Loading branch information
arthurkirkosa committed Apr 1, 2024
1 parent 10d3f68 commit 151a49a
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 31 deletions.
Empty file added Fix tests for PHPUnit 11
Empty file.
16 changes: 7 additions & 9 deletions tests/Actions/FieldActionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@
use Binaryk\LaravelRestify\Tests\Fixtures\Post\PostRepository;
use Binaryk\LaravelRestify\Tests\IntegrationTestCase;
use Illuminate\Testing\Fluent\AssertableJson;
use PHPUnit\Framework\Attributes\Test;

class FieldActionTest extends IntegrationTestCase
{
/** * @test */
#[Test]
public function can_use_actionable_field(): void
{
$action = new class() extends Action
{
$action = new class () extends Action {
public bool $showOnShow = true;

public function handle(RestifyRequest $request, Post $post)
Expand Down Expand Up @@ -52,11 +52,10 @@ public function handle(RestifyRequest $request, Post $post)

}

/** @test */
#[Test]
public function can_use_actionable_field_on_bulk_store(): void
{
$action = new class() extends Action
{
$action = new class () extends Action {
public bool $showOnShow = true;

public function handle(RestifyRequest $request, Post $post, int $row)
Expand Down Expand Up @@ -97,11 +96,10 @@ public function handle(RestifyRequest $request, Post $post, int $row)
);
}

/** @test */
#[Test]
public function can_use_actionable_field_on_bulk_update(): void
{
$action = new class() extends Action
{
$action = new class () extends Action {
public bool $showOnShow = true;

public function handle(RestifyRequest $request, Post $post, int $row)
Expand Down
5 changes: 3 additions & 2 deletions tests/Controllers/Index/IndexRelatedFeatureTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Http\Request;
use Illuminate\Testing\Fluent\AssertableJson;
use PHPUnit\Framework\Attributes\Test;

class IndexRelatedFeatureTest extends IntegrationTestCase
{
Expand Down Expand Up @@ -197,7 +198,7 @@ public function test_repository_can_resolve_related_using_callables(): void
);
}

/** * @test */
#[Test]
public function it_can_paginate_keeping_relationships(): void
{
PostRepository::$related = [
Expand Down Expand Up @@ -228,7 +229,7 @@ public function it_can_paginate_keeping_relationships(): void
);
}

/** * @test */
#[Test]
public function it_will_call_fields_method_for_related(): void
{
UserRepository::partialMock()
Expand Down
19 changes: 7 additions & 12 deletions tests/Controllers/Index/NestedRepositoryControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,11 @@
use Binaryk\LaravelRestify\Tests\IntegrationTestCase;
use Illuminate\Support\Facades\Gate;
use Illuminate\Testing\Fluent\AssertableJson;
use PHPUnit\Framework\Attributes\Test;

class NestedRepositoryControllerTest extends IntegrationTestCase
{
/** * @test */
#[Test]
public function it_can_list_nested(): void
{
UserRepository::$related = [
Expand All @@ -33,7 +34,7 @@ public function it_can_list_nested(): void
$this->getJson(UserRepository::route('1/posts'))->assertForbidden();
}

/** * @test */
#[Test]
public function it_can_show_nested_using_identifier(): void
{
$post = PostFactory::one([
Expand All @@ -56,7 +57,7 @@ public function it_can_show_nested_using_identifier(): void
$this->getJson(UserRepository::route("$post->user_id/posts/$post->id"))->assertForbidden();
}

/** * @test */
#[Test]
public function it_can_store_nested_related(): void
{
UserRepository::$related = [
Expand All @@ -83,9 +84,7 @@ public function it_can_store_nested_related(): void
])->assertForbidden();
}

/**
* @test
*/
#[Test]
public function it_can_update_nested_related(): void
{
UserRepository::$related = [
Expand Down Expand Up @@ -117,9 +116,7 @@ public function it_can_update_nested_related(): void
])->assertForbidden();
}

/**
* @test
*/
#[Test]
public function it_can_delete_nested_related(): void
{
UserRepository::$related = [
Expand All @@ -139,9 +136,7 @@ public function it_can_delete_nested_related(): void
$this->deleteJson(UserRepository::route("$post->user_id/posts/$post->id"))->assertForbidden();
}

/**
* @test
*/
#[Test]
public function it_will_apply_policies_when_nested_requested(): void
{
$_SERVER['restify.post.delete'] = false;
Expand Down
9 changes: 5 additions & 4 deletions tests/Controllers/Index/RepositoryIndexControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,13 @@
use Binaryk\LaravelRestify\Tests\IntegrationTestCase;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Testing\Fluent\AssertableJson;
use PHPUnit\Framework\Attributes\Test;

class RepositoryIndexControllerTest extends IntegrationTestCase
{
use RefreshDatabase;

/** * @test */
#[Test]
public function it_can_paginate(): void
{
PostFactory::many(15);
Expand Down Expand Up @@ -65,7 +66,7 @@ public function it_can_paginate(): void
);
}

/** * @test */
#[Test]
public function it_can_search_using_query(): void
{
PostFactory::one([
Expand All @@ -91,7 +92,7 @@ public function it_can_search_using_query(): void
]))->assertJson(fn (AssertableJson $json) => $json->count('data', 2)->etc());
}

/** * @test */
#[Test]
public function it_can_sort_using_query(): void
{
PostFactory::one([
Expand Down Expand Up @@ -125,7 +126,7 @@ public function it_can_sort_using_query(): void
);
}

/** * @test */
#[Test]
public function it_can_return_related_entity(): void
{
PostRepository::$related = [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use Binaryk\LaravelRestify\Restify;
use Binaryk\LaravelRestify\Tests\Concerns\WithRepositoriesDataProvider;
use Binaryk\LaravelRestify\Tests\IntegrationTestCase;
use PHPUnit\Framework\Attributes\DataProvider;

class RepositoryLoadedFromServiceProviderTest extends IntegrationTestCase
{
Expand All @@ -22,7 +23,7 @@ protected function tearDown(): void
parent::tearDown();
}

/** @dataProvider repositoryPathsFromFixtures */
#[DataProvider('repositoryPathsFromFixtures')]
public function test_repositories_can_be_loaded_with_service_provider_register_method(
string $directory,
string $namespace,
Expand Down
5 changes: 2 additions & 3 deletions tests/Unit/RepositoriesResolvedFromNamespaceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use Binaryk\LaravelRestify\Tests\Concerns\WithRepositoriesDataProvider;
use Binaryk\LaravelRestify\Tests\IntegrationTestCase;
use Orchestra\Testbench\TestCase;
use PHPUnit\Framework\Attributes\DataProvider;

class RepositoriesResolvedFromNamespaceTest extends IntegrationTestCase
{
Expand Down Expand Up @@ -46,9 +47,7 @@ public function test_repository_can_be_resolved_from_app_namespace(): void
);
}

/**
* @dataProvider repositoryPathsFromFixtures
*/
#[DataProvider('repositoryPathsFromFixtures')]
public function test_repository_can_be_resolved_from_any_namespace(string $directory, string $namespace): void
{
Restify::repositoriesFrom(
Expand Down

0 comments on commit 151a49a

Please sign in to comment.