Skip to content

Commit bac3b8f

Browse files
author
dcorroyer
committed
feat: ci and coverage improvement
1 parent 727bbd6 commit bac3b8f

File tree

5 files changed

+124
-29
lines changed

5 files changed

+124
-29
lines changed

.github/workflows/ci.yml

+26-26
Original file line numberDiff line numberDiff line change
@@ -38,32 +38,32 @@ jobs:
3838
working-directory: app
3939
run: $GITHUB_WORKSPACE/tools/ecs/vendor/bin/ecs check --config $GITHUB_WORKSPACE/tools/ecs/ecs.php --output-format=checkstyle
4040

41-
rector:
42-
name: Rector
43-
runs-on: ubuntu-22.04
44-
steps:
45-
- uses: actions/checkout@v4
46-
47-
- name: Setup PHP
48-
uses: shivammathur/setup-php@v2
49-
with:
50-
php-version: '8.3'
51-
52-
- name: Cache Composer dependencies
53-
uses: actions/cache@v4
54-
with:
55-
path: ~/.composer/cache
56-
key: ${{ runner.os }}-composer-rector-${{ hashFiles('tools/rector/composer.lock') }}
57-
restore-keys: |
58-
${{ runner.os }}-composer-rector-
59-
60-
- name: Install vendors
61-
working-directory: tools/rector
62-
run: composer install --no-interaction
63-
64-
- name: Rector
65-
working-directory: tools/rector
66-
run: $GITHUB_WORKSPACE/tools/rector/vendor/bin/rector process --dry-run --clear-cache --config=$GITHUB_WORKSPACE/tools/rector/rector.php
41+
# rector:
42+
# name: Rector
43+
# runs-on: ubuntu-22.04
44+
# steps:
45+
# - uses: actions/checkout@v4
46+
#
47+
# - name: Setup PHP
48+
# uses: shivammathur/setup-php@v2
49+
# with:
50+
# php-version: '8.3'
51+
#
52+
# - name: Cache Composer dependencies
53+
# uses: actions/cache@v4
54+
# with:
55+
# path: ~/.composer/cache
56+
# key: ${{ runner.os }}-composer-rector-${{ hashFiles('tools/rector/composer.lock') }}
57+
# restore-keys: |
58+
# ${{ runner.os }}-composer-rector-
59+
#
60+
# - name: Install vendors
61+
# working-directory: tools/rector
62+
# run: composer install --no-interaction
63+
#
64+
# - name: Rector
65+
# working-directory: tools/rector
66+
# run: $GITHUB_WORKSPACE/tools/rector/vendor/bin/rector process --dry-run --clear-cache --config=$GITHUB_WORKSPACE/tools/rector/rector.php
6767

6868
phpstan:
6969
name: PHPStan

app/.env.test

-1
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,3 @@ APP_SECRET='$ecretf0rt3st'
44
SYMFONY_DEPRECATIONS_HELPER=999999
55
PANTHER_APP_ENV=panther
66
PANTHER_ERROR_SCREENSHOT_DIR=./var/error-screenshots
7-
DATABASE_URL="postgresql://root:root@database:5432/app?serverVersion=16&charset=utf8"

app/phpunit.xml.dist

+9-2
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,14 @@
3737

3838
<source restrictDeprecations="true" restrictNotices="true" restrictWarnings="true">
3939
<include>
40-
<directory>src</directory>
40+
<directory suffix=".php">src</directory>
4141
</include>
42+
<exclude>
43+
<directory suffix=".php">src/Dto</directory>
44+
<directory suffix=".php">src/Serializable</directory>
45+
<directory suffix=".php">src/DataFixtures</directory>
46+
<directory suffix=".php">src/Kernel.php</directory>
47+
</exclude>
48+
4249
</source>
43-
</phpunit>
50+
</phpunit>

app/src/Repository/UserRepository.php

+1
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ public function getEntityClass(): string
2323
return User::class;
2424
}
2525

26+
// TODO: to test during improvement user creation task
2627
#[\Override]
2728
public function upgradePassword(
2829
PasswordAuthenticatedUserInterface $passwordAuthenticatedUser,
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace App\Tests\Functional\Budget;
6+
7+
use App\Tests\Common\Factory\BudgetFactory;
8+
use App\Tests\Common\Factory\UserFactory;
9+
use App\Tests\Functional\TestBase;
10+
use PHPUnit\Framework\Attributes\Group;
11+
use PHPUnit\Framework\Attributes\Test;
12+
use PHPUnit\Framework\Attributes\TestDox;
13+
use Symfony\Component\HttpFoundation\Request;
14+
15+
/**
16+
* @internal
17+
*/
18+
#[Group('integration')]
19+
#[Group('controller')]
20+
#[Group('budget')]
21+
#[Group('budget-controller')]
22+
final class UpdateBudgetControllerTest extends TestBase
23+
{
24+
private const string API_ENDPOINT = '/api/budgets';
25+
26+
#[TestDox('When you call PUT /api/budgets, it should update and return the budget')]
27+
#[Test]
28+
public function updateBudgetController_WhenDataOk_ReturnsBudget(): void
29+
{
30+
// ARRANGE
31+
$user = UserFactory::createOne()->_real();
32+
$budget = BudgetFactory::createOne([
33+
'user' => $user,
34+
])->_real();
35+
36+
$this->client->loginUser($user);
37+
38+
$budgetPayload = [
39+
'date' => '2024-02',
40+
'incomes' => [
41+
[
42+
'name' => 'Salaire',
43+
'amount' => 2500,
44+
],
45+
[
46+
'name' => 'Prime',
47+
'amount' => 500,
48+
],
49+
],
50+
'expenses' => [
51+
[
52+
'name' => 'Loyer',
53+
'amount' => 1000,
54+
'category' => 'Logement',
55+
],
56+
[
57+
'name' => 'Electricité',
58+
'amount' => 100,
59+
'category' => 'Logement',
60+
],
61+
[
62+
'name' => 'Courses',
63+
'amount' => 200,
64+
'category' => 'Alimentation',
65+
],
66+
[
67+
'name' => 'Téléphone',
68+
'amount' => 20,
69+
'category' => 'Abonnements',
70+
],
71+
],
72+
];
73+
74+
// ACT
75+
$response = $this->clientRequest(
76+
Request::METHOD_PUT,
77+
self::API_ENDPOINT . '/' . $budget->getId(),
78+
$budgetPayload
79+
);
80+
$responseData = $response['data'] ?? [];
81+
82+
// ASSERT
83+
self::assertResponseIsSuccessful();
84+
self::assertResponseFormatSame('json');
85+
self::assertSame('Budget 2024-02', $responseData['name']);
86+
self::assertSame(1680, $responseData['savingCapacity']);
87+
}
88+
}

0 commit comments

Comments
 (0)