Auto commit for release 'develop' on 2024-09-02

This commit is contained in:
github-actions
2024-09-02 05:06:53 +02:00
parent b6897ec3a9
commit 7e665dbdfc
9 changed files with 353 additions and 343 deletions

View File

@@ -36,52 +36,55 @@ use FireflyIII\Models\UserGroup;
*
* @coversNothing
*/
final class BillControllerTest extends TestCase {
final class BillControllerTest extends TestCase
{
/**
* @covers \FireflyIII\Api\V1\Controllers\Autocomplete\BillController
*/
use RefreshDatabase;
private function createAuthenticatedUser(): User {
private function createAuthenticatedUser(): User
{
$userGroup = UserGroup::create(['title' => 'Test Group']);
return User::create([
'email' => 'test@email.com',
'password' => 'password',
'email' => 'test@email.com',
'password' => 'password',
'user_group_id' => $userGroup->id,
]);
}
]);
}
private function createTestBills(int $count, User $user): void {
for ($i = 1; $i <= $count; $i++) {
private function createTestBills(int $count, User $user): void
{
for ($i = 1; $i <= $count; ++$i) {
$bill = Bill::create([
'user_id' => $user->id,
'name' => 'Bill ' . $i,
'user_id' => $user->id,
'name' => 'Bill '.$i,
'user_group_id' => $user->user_group_id,
'amount_min' => rand(1, 100), // random amount
'amount_max' => rand(101, 200), // random amount
'match' => 'MIGRATED_TO_RULES',
'date' => '2024-01-01',
'repeat_freq' => 'monthly',
'automatch' => 1,
'amount_min' => rand(1, 100), // random amount
'amount_max' => rand(101, 200), // random amount
'match' => 'MIGRATED_TO_RULES',
'date' => '2024-01-01',
'repeat_freq' => 'monthly',
'automatch' => 1,
]);
}
}
public function testGivenAnUnauthenticatedRequestWhenCallingTheBillsEndpointThenReturns401HttpCode(): void {
public function testGivenAnUnauthenticatedRequestWhenCallingTheBillsEndpointThenReturns401HttpCode(): void
{
// test API
$response = $this->get(route('api.v1.autocomplete.bills'), ['Accept' => 'application/json']);
$response->assertStatus(401);
$response->assertHeader('Content-Type', 'application/json');
$response->assertContent('{"message":"Unauthenticated","exception":"AuthenticationException"}');
}
public function testGivenAuthenticatedRequestWhenCallingTheBillsEndpointThenReturns200HttpCode(): void
{
// act as a user
$user = $this->createAuthenticatedUser();
$user = $this->createAuthenticatedUser();
$this->actingAs($user);
$response = $this->get(route('api.v1.autocomplete.bills'), ['Accept' => 'application/json']);
@@ -92,7 +95,7 @@ final class BillControllerTest extends TestCase {
public function testGivenAuthenticatedRequestWhenCallingTheBillsEndpointThenReturnsBills(): void
{
$user = $this->createAuthenticatedUser();
$user = $this->createAuthenticatedUser();
$this->actingAs($user);
$this->createTestBills(5, $user);
@@ -105,21 +108,21 @@ final class BillControllerTest extends TestCase {
'*' => [
'id',
'name',
'active'
]
'active',
],
]);
}
public function testGivenAuthenticatedRequestWhenCallingTheBillsEndpointWithQueryThenReturnsBillsWithLimit(): void
{
$user = $this->createAuthenticatedUser();
$user = $this->createAuthenticatedUser();
$this->actingAs($user);
$this->createTestBills(5, $user);
$response = $this->get(route('api.v1.autocomplete.bills', [
'query' => 'Bill',
'limit' => 3
'limit' => 3,
]), ['Accept' => 'application/json']);
$response->assertStatus(200);
@@ -130,15 +133,15 @@ final class BillControllerTest extends TestCase {
'*' => [
'id',
'name',
'active'
]
'active',
],
]);
}
public function testGivenAuthenticatedRequestWhenCallingTheBillsEndpointWithQueryThenReturnsBillsThatMatchQuery(): void
{
$user = $this->createAuthenticatedUser();
$user = $this->createAuthenticatedUser();
$this->actingAs($user);
$this->createTestBills(20, $user);
@@ -153,5 +156,4 @@ final class BillControllerTest extends TestCase {
$response->assertJsonCount(11);
$response->assertJsonMissing(['name' => 'Bill 2']);
}
}
}

View File

@@ -36,46 +36,49 @@ use FireflyIII\User;
*
* @coversNothing
*/
final class BudgetControllerTest extends TestCase {
final class BudgetControllerTest extends TestCase
{
/**
* @covers \FireflyIII\Api\V1\Controllers\Autocomplete\BudgetController
*/
use RefreshDatabase;
private function createAuthenticatedUser(): User {
private function createAuthenticatedUser(): User
{
$userGroup = UserGroup::create(['title' => 'Test Group']);
return User::create([
'email' => 'test@email.com',
'password' => 'password',
'email' => 'test@email.com',
'password' => 'password',
'user_group_id' => $userGroup->id,
]);
}
]);
}
private function createTestBudgets(int $count, User $user): void {
for ($i = 1; $i <= $count; $i++) {
private function createTestBudgets(int $count, User $user): void
{
for ($i = 1; $i <= $count; ++$i) {
$budget = Budget::create([
'user_id' => $user->id,
'name' => 'Budget ' . $i,
'user_id' => $user->id,
'name' => 'Budget '.$i,
'user_group_id' => $user->user_group_id,
'active' => 1,
'active' => 1,
]);
}
}
public function testGivenAnUnauthenticatedRequestWhenCallingTheBudgetsEndpointThenReturns401HttpCode(): void {
public function testGivenAnUnauthenticatedRequestWhenCallingTheBudgetsEndpointThenReturns401HttpCode(): void
{
// test API
$response = $this->get(route('api.v1.autocomplete.budgets'), ['Accept' => 'application/json']);
$response->assertStatus(401);
$response->assertHeader('Content-Type', 'application/json');
$response->assertContent('{"message":"Unauthenticated","exception":"AuthenticationException"}');
}
public function testGivenAuthenticatedRequestWhenCallingTheBudgetsEndpointThenReturns200HttpCode(): void
{
// act as a user
$user = $this->createAuthenticatedUser();
$user = $this->createAuthenticatedUser();
$this->actingAs($user);
$response = $this->get(route('api.v1.autocomplete.budgets'), ['Accept' => 'application/json']);
@@ -86,7 +89,7 @@ final class BudgetControllerTest extends TestCase {
public function testGivenAuthenticatedRequestWhenCallingTheBudgetsEndpointThenReturnsBudgets(): void
{
$user = $this->createAuthenticatedUser();
$user = $this->createAuthenticatedUser();
$this->actingAs($user);
$this->createTestBudgets(5, $user);
@@ -95,7 +98,7 @@ final class BudgetControllerTest extends TestCase {
$response->assertHeader('Content-Type', 'application/json');
$response->assertJsonCount(5);
$response->assertJsonFragment(['name' => 'Budget 1']);
$response->assertJsonStructure([
$response->assertJsonStructure([
'*' => [
'id',
'name',
@@ -105,13 +108,13 @@ final class BudgetControllerTest extends TestCase {
public function testGivenAuthenticatedRequestWhenCallingTheBudgetsEndpointWithQueryThenReturnsBudgetsWithLimit(): void
{
$user = $this->createAuthenticatedUser();
$user = $this->createAuthenticatedUser();
$this->actingAs($user);
$this->createTestBudgets(5, $user);
$response = $this->get(route('api.v1.autocomplete.budgets', [
'query' => 'Budget',
'limit' => 3
'limit' => 3,
]), ['Accept' => 'application/json']);
$response->assertStatus(200);
@@ -121,7 +124,7 @@ final class BudgetControllerTest extends TestCase {
public function testGivenAuthenticatedRequestWhenCallingTheBudgetsEndpointWithQueryThenReturnsBudgetsThatMatchQuery(): void
{
$user = $this->createAuthenticatedUser();
$user = $this->createAuthenticatedUser();
$this->actingAs($user);
$this->createTestBudgets(20, $user);
@@ -136,5 +139,4 @@ final class BudgetControllerTest extends TestCase {
$response->assertJsonCount(11);
$response->assertJsonMissing(['name' => 'Budget 2']);
}
}
}

View File

@@ -35,42 +35,45 @@ use FireflyIII\User;
*
* @coversNothing
*/
final class CategoryControllerTest extends TestCase {
final class CategoryControllerTest extends TestCase
{
/**
* @covers \FireflyIII\Api\V1\Controllers\Autocomplete\CategoryController
*/
use RefreshDatabase;
private function createAuthenticatedUser(): User {
private function createAuthenticatedUser(): User
{
return User::create([
'email' => 'test@email.com',
'email' => 'test@email.com',
'password' => 'password',
]);
}
]);
}
private function createTestCategories(int $count, User $user): void {
for ($i = 1; $i <= $count; $i++) {
private function createTestCategories(int $count, User $user): void
{
for ($i = 1; $i <= $count; ++$i) {
$category = Category::create([
'user_id' => $user->id,
'name' => 'Category ' . $i,
'user_id' => $user->id,
'name' => 'Category '.$i,
'user_group_id' => $user->user_group_id,
]);
}
}
public function testGivenAnUnauthenticatedRequestWhenCallingTheCategoriesEndpointThenReturns401HttpCode(): void {
public function testGivenAnUnauthenticatedRequestWhenCallingTheCategoriesEndpointThenReturns401HttpCode(): void
{
// test API
$response = $this->get(route('api.v1.autocomplete.categories'), ['Accept' => 'application/json']);
$response->assertStatus(401);
$response->assertHeader('Content-Type', 'application/json');
$response->assertContent('{"message":"Unauthenticated","exception":"AuthenticationException"}');
}
public function testGivenAuthenticatedRequestWhenCallingTheCategoriesEndpointThenReturns200HttpCode(): void
{
// act as a user
$user = $this->createAuthenticatedUser();
$user = $this->createAuthenticatedUser();
$this->actingAs($user);
$response = $this->get(route('api.v1.autocomplete.categories'), ['Accept' => 'application/json']);
@@ -81,7 +84,7 @@ final class CategoryControllerTest extends TestCase {
public function testGivenAuthenticatedRequestWhenCallingTheCategoriesEndpointThenReturnsCategories(): void
{
$user = $this->createAuthenticatedUser();
$user = $this->createAuthenticatedUser();
$this->actingAs($user);
$this->createTestCategories(5, $user);
@@ -90,7 +93,7 @@ final class CategoryControllerTest extends TestCase {
$response->assertHeader('Content-Type', 'application/json');
$response->assertJsonCount(5);
$response->assertJsonFragment(['name' => 'Category 1']);
$response->assertJsonStructure([
$response->assertJsonStructure([
'*' => [
'id',
'name',
@@ -100,13 +103,13 @@ final class CategoryControllerTest extends TestCase {
public function testGivenAuthenticatedRequestWhenCallingTheCategoriesEndpointWithQueryThenReturnsCategoriesWithLimit(): void
{
$user = $this->createAuthenticatedUser();
$user = $this->createAuthenticatedUser();
$this->actingAs($user);
$this->createTestCategories(5, $user);
$response = $this->get(route('api.v1.autocomplete.categories', [
'query' => 'Category',
'limit' => 3
'limit' => 3,
]), ['Accept' => 'application/json']);
$response->assertStatus(200);
@@ -116,7 +119,7 @@ final class CategoryControllerTest extends TestCase {
public function testGivenAuthenticatedRequestWhenCallingTheCategoriesEndpointWithQueryThenReturnsCategoriesThatMatchQuery(): void
{
$user = $this->createAuthenticatedUser();
$user = $this->createAuthenticatedUser();
$this->actingAs($user);
$this->createTestCategories(20, $user);
@@ -131,5 +134,4 @@ final class CategoryControllerTest extends TestCase {
$response->assertJsonCount(11);
$response->assertJsonMissing(['name' => 'Category 2']);
}
}
}