Skip to content

Commit

Permalink
Resource Tests
Browse files Browse the repository at this point in the history
- OPTIONS resource tests
  • Loading branch information
deanblackborough committed Jun 28, 2023
1 parent 3fa853f commit 2b47517
Show file tree
Hide file tree
Showing 3 changed files with 543 additions and 0 deletions.
5 changes: 5 additions & 0 deletions Tests/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -703,6 +703,11 @@ protected function fetchOptionsForResource(array $parameters = []): TestResponse
return $this->optionsRoute('resource.show.options', $parameters);
}

protected function fetchOptionsForResourceCollection(array $parameters = []): TestResponse
{
return $this->optionsRoute('resource.list.options', $parameters);
}

protected function fetchOptionsForResourceType(array $parameters = []): TestResponse
{
return $this->optionsRoute('resource-type.show.options', $parameters);
Expand Down
80 changes: 80 additions & 0 deletions Tests/View/Http/Controllers/ResourceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,22 @@ public function optionsRequestForAllocatedExpenseResource(): void
$this->assertProvidedJsonMatchesDefinedSchema($response->content(), 'api/schema/options/resource.json');
}

/** @test */
public function optionsRequestForAllocatedExpenseResourceCollection(): void
{
$this->actingAs(User::find(1));

$resource_type_id = $this->createAllocatedExpenseResourceType();

$response = $this->fetchOptionsForResourceCollection([
'resource_type_id' => $resource_type_id
]);
$response->assertStatus(200);

// Resource is the same for all types, we are testing the OPTIONS request for the different item types, until the resources differ later on.
$this->assertProvidedJsonMatchesDefinedSchema($response->content(), 'api/schema/options/resource-collection.json');
}

/** @test */
public function optionsRequestForBudgetResource(): void
{
Expand All @@ -43,6 +59,22 @@ public function optionsRequestForBudgetResource(): void
$this->assertProvidedJsonMatchesDefinedSchema($response->content(), 'api/schema/options/resource.json');
}

/** @test */
public function optionsRequestForBudgetResourceCollection(): void
{
$this->actingAs(User::find(1));

$resource_type_id = $this->createBudgetResourceType();

$response = $this->fetchOptionsForResourceCollection([
'resource_type_id' => $resource_type_id
]);
$response->assertStatus(200);

// Resource is the same for all types, we are testing the OPTIONS request for the different item types, until the resources differ later on.
$this->assertProvidedJsonMatchesDefinedSchema($response->content(), 'api/schema/options/resource-collection.json');
}

/** @test */
public function optionsRequestForBudgetProResource(): void
{
Expand All @@ -61,6 +93,22 @@ public function optionsRequestForBudgetProResource(): void
$this->assertProvidedJsonMatchesDefinedSchema($response->content(), 'api/schema/options/resource.json');
}

/** @test */
public function optionsRequestForBudgetProResourceCollection(): void
{
$this->actingAs(User::find(1));

$resource_type_id = $this->createBudgetProResourceType();

$response = $this->fetchOptionsForResourceCollection([
'resource_type_id' => $resource_type_id
]);
$response->assertStatus(200);

// Resource is the same for all types, we are testing the OPTIONS request for the different item types, until the resources differ later on.
$this->assertProvidedJsonMatchesDefinedSchema($response->content(), 'api/schema/options/resource-collection.json');
}

/** @test */
public function optionsRequestForYahtzeeResource(): void
{
Expand All @@ -79,6 +127,22 @@ public function optionsRequestForYahtzeeResource(): void
$this->assertProvidedJsonMatchesDefinedSchema($response->content(), 'api/schema/options/resource.json');
}

/** @test */
public function optionsRequestForYahtzeeResourceCollection(): void
{
$this->actingAs(User::find(1));

$resource_type_id = $this->createGameResourceType();

$response = $this->fetchOptionsForResourceCollection([
'resource_type_id' => $resource_type_id
]);
$response->assertStatus(200);

// Resource is the same for all types, we are testing the OPTIONS request for the different item types, until the resources differ later on.
$this->assertProvidedJsonMatchesDefinedSchema($response->content(), 'api/schema/options/resource-collection.json');
}

/** @test */
public function optionsRequestForYatzyResource(): void
{
Expand All @@ -96,4 +160,20 @@ public function optionsRequestForYatzyResource(): void
// Resource is the same for all types, we are testing the OPTIONS request for the different item types, until the resources differ later on.
$this->assertProvidedJsonMatchesDefinedSchema($response->content(), 'api/schema/options/resource.json');
}

/** @test */
public function optionsRequestForYatzyResourceCollection(): void
{
$this->actingAs(User::find(1));

$resource_type_id = $this->createGameResourceType();

$response = $this->fetchOptionsForResourceCollection([
'resource_type_id' => $resource_type_id
]);
$response->assertStatus(200);

// Resource is the same for all types, we are testing the OPTIONS request for the different item types, until the resources differ later on.
$this->assertProvidedJsonMatchesDefinedSchema($response->content(), 'api/schema/options/resource-collection.json');
}
}
Loading

0 comments on commit 2b47517

Please sign in to comment.