Skip to content

Commit

Permalink
Resource tests
Browse files Browse the repository at this point in the history
- Added additional resource tests
  • Loading branch information
deanblackborough committed Jun 29, 2023
1 parent 2b47517 commit 53d793f
Show file tree
Hide file tree
Showing 19 changed files with 637 additions and 205 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -307,10 +307,10 @@ our local test suite is as complete as the Postman request test suite.
| PermittedUser | 4 Tests | 2 Tests |
| Queue | Non yet* | Non yet* |
| Request | Non yet* | Non yet* |
| Resource | 24 Tests | Non yet* |
| Resource | 24 Tests | 22 Tests |
| ResourceType | 23 Tests | 17 Tests |
| Subcategory | 12 Tests | Non yet* |
| **Total tests** | **154** | **68** |
| **Total tests** | **154** | **90** |

*Non yet does not mean there are no tests, it just means there are no PHPUnit tests. There are over 2000 tests in
a private Postman collection, I'm slowing transferring them locally and expanding the test suite.
179 changes: 0 additions & 179 deletions Tests/View/Http/Controllers/ResourceTest.php

This file was deleted.

2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
},
"autoload-dev": {
"psr-4": {
"Tests\\": "Tests/"
"Tests\\": "tests/"
}
},
"scripts": {
Expand Down
26 changes: 13 additions & 13 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

File renamed without changes.
File renamed without changes.
29 changes: 20 additions & 9 deletions Tests/TestCase.php → tests/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -310,16 +310,22 @@ protected function createBudgetProResource(string $resource_type_id): string
$this->fail('Unable to create the resource');
}

protected function createBudgetResource(string $resource_type_id): string
protected function createBudgetResource(
string $resource_type_id,
array $override = []
): string
{
$response = $this->createResource(
$resource_type_id,
[
'name' => $this->faker->text(200),
'description' => $this->faker->text(200),
'item_subtype_id' => $this->item_subtypes['budget']['default']
]
);
$payload = [
'name' => $this->faker->text(200),
'description' => $this->faker->text(200),
'item_subtype_id' => $this->item_subtypes['budget']['default']
];

foreach ($override as $k => $v) {
$payload[$k] = $v;
}

$response = $this->createResource($resource_type_id, $payload);

if ($response->assertStatus(201)) {
return $response->json('id');
Expand Down Expand Up @@ -648,6 +654,11 @@ protected function fetchItemCollection(array $parameters = []): TestResponse
return $this->route('item.list', $parameters);
}

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

protected function fetchResourceTypeCollection(array $parameters = []): TestResponse
{
return $this->route('resource-type.list', $parameters);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Http\Controllers;
namespace Tests\View\Http\Controllers;

use App\User;
use Tests\TestCase;
Expand Down
Loading

0 comments on commit 53d793f

Please sign in to comment.