Skip to content

Commit

Permalink
Added composer diff CI. Imported DataProvider attribute.
Browse files Browse the repository at this point in the history
  • Loading branch information
laurentmuller committed May 27, 2024
1 parent 6962d27 commit 8eff2af
Show file tree
Hide file tree
Showing 55 changed files with 274 additions and 186 deletions.
35 changes: 35 additions & 0 deletions .github/workflows/composer_diff.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: Composer Diff

on:
push:
paths:
- 'composer.lock'
pull_request:
paths:
- 'composer.lock'

jobs:
build:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Generate composer diff
id: composer_diff
uses: IonBazan/composer-diff-action@v1

- uses: marocchino/sticky-pull-request-comment@v2
if: ${{ steps.composer_diff.outputs.composer_diff_exit_code != 0 }}
with:
header: composer-diff
message: |
<details>
<summary>Composer package changes</summary>
${{ steps.composer_diff.outputs.composer_diff }}
</details>
16 changes: 8 additions & 8 deletions public/js/application/commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,14 @@ function createPopover() {
});
}

function updateExecute() {
'use strict';
const $command = $('#command');
const $execute = $('.btn-execute');
const href = $execute.data('url').replace('query', $command.val());
$execute.attr('href', href);
}

/**
* Load the given command.
*
Expand All @@ -47,14 +55,6 @@ function loadContent(name) {
});
}

function updateExecute() {
'use strict';
const $command = $('#command');
const $execute = $('.btn-execute');
const href = $execute.data('url').replace('query', $command.val());
$execute.attr('href', href);
}

/**
* Ready function
*/
Expand Down
2 changes: 1 addition & 1 deletion resources/schema/swiss_city.sql
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ CREATE TABLE IF NOT EXISTS city
zip INTEGER NOT NULL,
name TEXT NOT NULL,
state_id TEXT NOT NULL
)
);

CREATE TABLE IF NOT EXISTS state
(
Expand Down
3 changes: 2 additions & 1 deletion tests/Controller/AbstractControllerTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
use App\Controller\AbstractController;
use App\Tests\Web\AbstractAuthenticateWebTestCase;
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\DataProvider;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;

Expand All @@ -39,7 +40,7 @@ abstract public static function getRoutes(): \Iterator;
* @param int $expected the expected result
* @param string $method the request method
*/
#[\PHPUnit\Framework\Attributes\DataProvider('getRoutes')]
#[DataProvider('getRoutes')]
public function testRoutes(
string $url,
string $username = '',
Expand Down
7 changes: 4 additions & 3 deletions tests/Controller/AjaxUserControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
use App\Controller\AjaxUserController;
use App\Tests\Web\AbstractAuthenticateWebTestCase;
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\DataProvider;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Contracts\Translation\TranslatorInterface;
Expand Down Expand Up @@ -53,7 +54,7 @@ public static function getUsers(): \Iterator
yield ['username.not_found', '[email protected]'];
}

#[\PHPUnit\Framework\Attributes\DataProvider('getEmails')]
#[DataProvider('getEmails')]
public function testCheckEmail(string|bool $expected, ?string $email = null, ?int $id = null): void
{
$this->loginUsername('ROLE_SUPER_ADMIN');
Expand All @@ -63,7 +64,7 @@ public function testCheckEmail(string|bool $expected, ?string $email = null, ?in
$this->validateResponse($response, $expected);
}

#[\PHPUnit\Framework\Attributes\DataProvider('getNames')]
#[DataProvider('getNames')]
public function testCheckName(string|bool $expected, ?string $username = null, ?int $id = null): void
{
$this->loginUsername('ROLE_SUPER_ADMIN');
Expand All @@ -73,7 +74,7 @@ public function testCheckName(string|bool $expected, ?string $username = null, ?
$this->validateResponse($response, $expected);
}

#[\PHPUnit\Framework\Attributes\DataProvider('getUsers')]
#[DataProvider('getUsers')]
public function testCheckUser(string|bool $expected, ?string $user = null): void
{
$parameters = ['user' => $user];
Expand Down
5 changes: 3 additions & 2 deletions tests/DataTransformer/AddressTransformerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

use App\Form\DataTransformer\AddressTransformer;
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\TestCase;
use Symfony\Component\Form\Exception\TransformationFailedException;
use Symfony\Component\Mime\Address;
Expand Down Expand Up @@ -52,7 +53,7 @@ public static function getTransformValues(): \Generator
yield [new Address('[email protected]', 'username'), \htmlentities('username <[email protected]>')];
}

#[\PHPUnit\Framework\Attributes\DataProvider('getReverseTransformValues')]
#[DataProvider('getReverseTransformValues')]
public function testReverseTransform(mixed $value, mixed $expected, bool $exception = false): void
{
if ($exception) {
Expand All @@ -66,7 +67,7 @@ public function testReverseTransform(mixed $value, mixed $expected, bool $except
}
}

#[\PHPUnit\Framework\Attributes\DataProvider('getTransformValues')]
#[DataProvider('getTransformValues')]
public function testTransform(mixed $value, mixed $expected, bool $exception = false): void
{
if ($exception) {
Expand Down
5 changes: 3 additions & 2 deletions tests/DataTransformer/EntityTransformerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
use App\Repository\GroupRepository;
use App\Tests\Entity\IdTrait;
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\MockObject\Exception;
use PHPUnit\Framework\TestCase;
use Symfony\Component\Form\Exception\TransformationFailedException;
Expand Down Expand Up @@ -49,7 +50,7 @@ public static function getTransformValues(): \Generator
*
* @throws Exception|\ReflectionException
*/
#[\PHPUnit\Framework\Attributes\DataProvider('getReverseTransformValues')]
#[DataProvider('getReverseTransformValues')]
public function testReverseTransform(mixed $value, mixed $expected, bool $exception = false): void
{
$group = null;
Expand Down Expand Up @@ -83,7 +84,7 @@ public function testReverseTransformGroup(): void
*
* @throws Exception|\ReflectionException
*/
#[\PHPUnit\Framework\Attributes\DataProvider('getTransformValues')]
#[DataProvider('getTransformValues')]
public function testTransform(mixed $value, mixed $expected, bool $exception = false): void
{
$group = null;
Expand Down
3 changes: 2 additions & 1 deletion tests/Entity/AbstractEntityTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

use App\Entity\AbstractEntity;
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\TestCase;

#[CoversClass(AbstractEntity::class)]
Expand Down Expand Up @@ -78,7 +79,7 @@ public function testIsNew(): void
*
* @psalm-suppress InaccessibleMethod
*/
#[\PHPUnit\Framework\Attributes\DataProvider('getTrims')]
#[DataProvider('getTrims')]
public function testTrim(?string $value, ?string $expected): void
{
$entity = $this->getEntity();
Expand Down
3 changes: 2 additions & 1 deletion tests/Entity/ProductTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
use App\Entity\Group;
use App\Entity\Product;
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\DataProvider;

#[CoversClass(Product::class)]
class ProductTest extends AbstractEntityValidatorTestCase
Expand Down Expand Up @@ -160,7 +161,7 @@ public function testNotDuplicate(): void
}
}

#[\PHPUnit\Framework\Attributes\DataProvider('getPrices')]
#[DataProvider('getPrices')]
public function testPrice(float $price, float $expected): void
{
$product = new Product();
Expand Down
9 changes: 5 additions & 4 deletions tests/Enums/EntityActionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
use App\Interfaces\PropertyServiceInterface;
use App\Tests\TranslatorMockTrait;
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\MockObject\Exception;
use PHPUnit\Framework\TestCase;

Expand Down Expand Up @@ -51,13 +52,13 @@ public function testCount(): void
self::assertCount($expected, EntityAction::sorted());
}

#[\PHPUnit\Framework\Attributes\DataProvider('getDefault')]
#[DataProvider('getDefault')]
public function testDefault(EntityAction $value, EntityAction $expected): void
{
self::assertSame($expected, $value);
}

#[\PHPUnit\Framework\Attributes\DataProvider('getLabel')]
#[DataProvider('getLabel')]
public function testLabel(string $expected, EntityAction $action): void
{
$actual = $action->getReadable();
Expand All @@ -78,15 +79,15 @@ public function testSorted(): void
/**
* @throws Exception
*/
#[\PHPUnit\Framework\Attributes\DataProvider('getLabel')]
#[DataProvider('getLabel')]
public function testTranslate(string $expected, EntityAction $action): void
{
$translator = $this->createTranslator();
$actual = $action->trans($translator);
self::assertSame($expected, $actual);
}

#[\PHPUnit\Framework\Attributes\DataProvider('getValues')]
#[DataProvider('getValues')]
public function testValue(EntityAction $action, string $expected): void
{
$actual = $action->value;
Expand Down
15 changes: 8 additions & 7 deletions tests/Enums/EntityNameTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
use App\Model\Role;
use App\Tests\TranslatorMockTrait;
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\MockObject\Exception;
use PHPUnit\Framework\TestCase;

Expand Down Expand Up @@ -167,21 +168,21 @@ public function testCount(): void
self::assertCount($expected, EntityName::sorted());
}

#[\PHPUnit\Framework\Attributes\DataProvider('getLabel')]
#[DataProvider('getLabel')]
public function testLabel(string $expected, EntityName $entity): void
{
$actual = $entity->getReadable();
self::assertSame($expected, $actual);
}

#[\PHPUnit\Framework\Attributes\DataProvider('getOffset')]
#[DataProvider('getOffset')]
public function testOffset(EntityName $entityName, int $expected): void
{
$actual = $entityName->offset();
self::assertSame($expected, $actual);
}

#[\PHPUnit\Framework\Attributes\DataProvider('getRightsField')]
#[DataProvider('getRightsField')]
public function testRightsField(EntityName $entityName, string $expected): void
{
$actual = $entityName->getRightsField();
Expand Down Expand Up @@ -209,15 +210,15 @@ public function testSorted(): void
/**
* @throws Exception
*/
#[\PHPUnit\Framework\Attributes\DataProvider('getLabel')]
#[DataProvider('getLabel')]
public function testTranslate(string $expected, EntityName $entity): void
{
$translator = $this->createTranslator();
$actual = $entity->trans($translator);
self::assertSame($expected, $actual);
}

#[\PHPUnit\Framework\Attributes\DataProvider('getTryFromField')]
#[DataProvider('getTryFromField')]
public function testTryFromField(string $field, ?EntityName $expected): void
{
$actual = EntityName::tryFromField($field);
Expand All @@ -228,14 +229,14 @@ public function testTryFromField(string $field, ?EntityName $expected): void
}
}

#[\PHPUnit\Framework\Attributes\DataProvider('getTryFromMixed')]
#[DataProvider('getTryFromMixed')]
public function testTryFromMixed(mixed $subject, mixed $expected): void
{
$actual = EntityName::tryFromMixed($subject);
self::assertSame($expected, $actual);
}

#[\PHPUnit\Framework\Attributes\DataProvider('getValue')]
#[DataProvider('getValue')]
public function testValue(EntityName $entityName, string $expected): void
{
$actual = $entityName->value;
Expand Down
9 changes: 5 additions & 4 deletions tests/Enums/EntityPermissionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
use App\Tests\TranslatorMockTrait;
use Elao\Enum\FlagBag;
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\MockObject\Exception;
use PHPUnit\Framework\TestCase;

Expand Down Expand Up @@ -121,7 +122,7 @@ public function testDefaultPermission(): void
}
}

#[\PHPUnit\Framework\Attributes\DataProvider('getLabel')]
#[DataProvider('getLabel')]
public function testLabel(EntityPermission $permission, string $expected): void
{
$actual = $permission->getReadable();
Expand Down Expand Up @@ -161,22 +162,22 @@ public function testSum(): void
/**
* @throws Exception
*/
#[\PHPUnit\Framework\Attributes\DataProvider('getLabel')]
#[DataProvider('getLabel')]
public function testTranslate(EntityPermission $permission, string $expected): void
{
$translator = $this->createTranslator();
$actual = $permission->trans($translator);
self::assertSame($expected, $actual);
}

#[\PHPUnit\Framework\Attributes\DataProvider('getTryFromName')]
#[DataProvider('getTryFromName')]
public function testTryFromName(mixed $expected, string $value): void
{
$actual = EntityPermission::tryFromName($value);
self::assertSame($expected, $actual);
}

#[\PHPUnit\Framework\Attributes\DataProvider('getValue')]
#[DataProvider('getValue')]
public function testValue(EntityPermission $permission, int $expected): void
{
$actual = $permission->value;
Expand Down
Loading

0 comments on commit 8eff2af

Please sign in to comment.