From 99773a1d732fcd691ab88440d49548ee378b5d47 Mon Sep 17 00:00:00 2001 From: Alexis Lefebvre Date: Wed, 24 Feb 2021 19:41:26 +0100 Subject: [PATCH 1/2] Add GitHub actions --- .github/workflows/tests.yml | 58 +++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 .github/workflows/tests.yml diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml new file mode 100644 index 00000000..22940abb --- /dev/null +++ b/.github/workflows/tests.yml @@ -0,0 +1,58 @@ +name: CI + +on: [push, pull_request] + +jobs: + tests: + name: Symfony ${{ matrix.symfony-version }} on PHP ${{ matrix.php-version }} + runs-on: ubuntu-latest + + strategy: + fail-fast: false + matrix: + php-version: ['7.2', '7.3', '7.4'] + symfony-version: ['5.1'] + include: + - php-version: 7.2 + symfony-version: "^4.4" + - php-version: 7.3 + symfony-version: "^4.4" + + steps: + - name: Checkout + uses: actions/checkout@v2 + + - name: Setup PHP, with composer and extensions + uses: shivammathur/setup-php@v2 #https://github.com/shivammathur/setup-php + with: + php-version: ${{ matrix.php-version }} + + - name: Get composer cache directory + id: composercache + run: echo "::set-output name=dir::$(composer config cache-files-dir)" + + - name: Cache composer dependencies + uses: actions/cache@v2 + with: + path: ${{ steps.composercache.outputs.dir }} + key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }} + restore-keys: ${{ runner.os }}-composer- + + - name: Require Symfony + run: | + composer require --no-update symfony/browser-kit=${{ matrix.symfony-version }} + composer require --no-update symfony/framework-bundle=${{ matrix.symfony-version }} + composer require --no-update symfony/css-selector=${{ matrix.symfony-version }} + composer require --no-update symfony/form=${{ matrix.symfony-version }} + composer require --no-update symfony/http-kernel=${{ matrix.symfony-version }} + composer require --no-update symfony/phpunit-bridge=${{ matrix.symfony-version }} + composer require --no-update symfony/security-bundle=${{ matrix.symfony-version }} + composer require --no-update symfony/twig-bundle=${{ matrix.symfony-version }} + composer require --no-update symfony/validator=${{ matrix.symfony-version }} + composer require --no-update symfony/yaml=${{ matrix.symfony-version }} + + - name: Install Composer dependencies + run: composer install + + - name: Run tests + run: php ./vendor/bin/phpunit --testdox From 4d8782ea169d32123697012f115c2efbe0c17b33 Mon Sep 17 00:00:00 2001 From: Alexis Lefebvre Date: Wed, 24 Feb 2021 18:51:41 +0000 Subject: [PATCH 2/2] Apply fixes from StyleCI --- .../LiipFunctionalTestExtension.php | 3 -- src/Test/ValidationErrorsConstraint.php | 4 -- src/Test/WebTestCase.php | 50 ++----------------- src/Utils/HttpAssertions.php | 7 +-- tests/App/Command/TestCommand.php | 4 -- tests/App/Command/TestInteractiveCommand.php | 4 -- tests/App/Command/TestStatusCodeCommand.php | 4 -- tests/App/Controller/DefaultController.php | 27 ---------- 8 files changed, 4 insertions(+), 99 deletions(-) diff --git a/src/DependencyInjection/LiipFunctionalTestExtension.php b/src/DependencyInjection/LiipFunctionalTestExtension.php index f4d1d5f4..44d23d3f 100644 --- a/src/DependencyInjection/LiipFunctionalTestExtension.php +++ b/src/DependencyInjection/LiipFunctionalTestExtension.php @@ -22,9 +22,6 @@ class LiipFunctionalTestExtension extends Extension { /** * Loads the services based on your application configuration. - * - * @param array $configs - * @param ContainerBuilder $container */ public function load(array $configs, ContainerBuilder $container): void { diff --git a/src/Test/ValidationErrorsConstraint.php b/src/Test/ValidationErrorsConstraint.php index 115a2d2d..a6d2db51 100644 --- a/src/Test/ValidationErrorsConstraint.php +++ b/src/Test/ValidationErrorsConstraint.php @@ -23,8 +23,6 @@ class ValidationErrorsConstraint extends Constraint /** * ValidationErrorsConstraint constructor. - * - * @param array $expect */ public function __construct(array $expect) { @@ -81,8 +79,6 @@ public function evaluate($other, $description = '', $returnResult = false): ?boo /** * Returns a string representation of the object. - * - * @return string */ public function toString(): string { diff --git a/src/Test/WebTestCase.php b/src/Test/WebTestCase.php index 745bcb4f..c7912e06 100644 --- a/src/Test/WebTestCase.php +++ b/src/Test/WebTestCase.php @@ -65,10 +65,6 @@ abstract class WebTestCase extends BaseWebTestCase /** * Creates a mock object of a service identified by its id. - * - * @param string $id - * - * @return MockBuilder */ protected function getServiceMockBuilder(string $id): MockBuilder { @@ -80,12 +76,6 @@ protected function getServiceMockBuilder(string $id): MockBuilder /** * Builds up the environment to run the given command. - * - * @param string $name - * @param array $params - * @param bool $reuseKernel - * - * @return CommandTester */ protected function runCommand(string $name, array $params = [], bool $reuseKernel = false): CommandTester { @@ -131,8 +121,6 @@ protected function runCommand(string $name, array $params = [], bool $reuseKerne * @see \Symfony\Component\Console\Output\OutputInterface for available levels * * @throws \OutOfBoundsException If the set value isn't accepted - * - * @return int */ protected function getVerbosityLevel(): int { @@ -189,8 +177,6 @@ private function setVerbosityLevelEnv($level): void /** * Retrieves the flag indicating if the output should be decorated or not. - * - * @return bool */ protected function getDecorated(): bool { @@ -215,8 +201,6 @@ public function isDecorated(bool $decorated): void /** * Get an instance of the dependency injection container. * (this creates a kernel *without* parameters). - * - * @return ContainerInterface */ protected function getContainer(): ContainerInterface { @@ -245,10 +229,6 @@ protected function getContainer(): ContainerInterface * $params can be used to pass headers to the client, note that they have * to follow the naming format used in $_SERVER. * Example: 'HTTP_X_REQUESTED_WITH' instead of 'X-Requested-With' - * - * @param array $params - * - * @return Client */ protected function makeClient(array $params = []): Client { @@ -261,10 +241,6 @@ protected function makeClient(array $params = []): Client * $params can be used to pass headers to the client, note that they have * to follow the naming format used in $_SERVER. * Example: 'HTTP_X_REQUESTED_WITH' instead of 'X-Requested-With' - * - * @param array $params - * - * @return Client */ protected function makeAuthenticatedClient(array $params = []): Client { @@ -283,12 +259,6 @@ protected function makeAuthenticatedClient(array $params = []): Client * $params can be used to pass headers to the client, note that they have * to follow the naming format used in $_SERVER. * Example: 'HTTP_X_REQUESTED_WITH' instead of 'X-Requested-With' - * - * @param string $username - * @param string $password - * @param array $params - * - * @return Client */ protected function makeClientWithCredentials(string $username, string $password, array $params = []): Client { @@ -321,11 +291,8 @@ protected function createUserToken(UserInterface $user, string $firewallName): T /** * Extracts the location from the given route. * - * @param string $route The name of the route - * @param array $params Set of parameters - * @param int $absolute - * - * @return string + * @param string $route The name of the route + * @param array $params Set of parameters */ protected function getUrl(string $route, array $params = [], int $absolute = UrlGeneratorInterface::ABSOLUTE_PATH): string { @@ -353,8 +320,6 @@ public function isSuccessful(Response $response, $success = true, $type = 'text/ * @param string $method The HTTP method to use, defaults to GET * @param bool $authentication Whether to use authentication, defaults to false * @param bool $success to define whether the response is expected to be successful - * - * @return string */ public function fetchContent(string $path, string $method = 'GET', bool $authentication = false, bool $success = true): string { @@ -377,8 +342,6 @@ public function fetchContent(string $path, string $method = 'GET', bool $authent * @param string $method The HTTP method to use, defaults to GET * @param bool $authentication Whether to use authentication, defaults to false * @param bool $success Whether the response is expected to be successful - * - * @return Crawler */ public function fetchCrawler(string $path, string $method = 'GET', bool $authentication = false, bool $success = true): Crawler { @@ -392,9 +355,6 @@ public function fetchCrawler(string $path, string $method = 'GET', bool $authent } /** - * @param UserInterface $user - * @param string $firewallName - * * @return WebTestCase */ public function loginAs(UserInterface $user, string $firewallName): self @@ -434,9 +394,6 @@ public function loginClient(KernelBrowser $client, UserInterface $user, string $ * Asserts that the HTTP response code of the last request performed by * $client matches the expected code. If not, raises an error with more * information. - * - * @param int $expectedStatusCode - * @param Client $client */ public static function assertStatusCode(int $expectedStatusCode, Client $client): void { @@ -447,8 +404,7 @@ public static function assertStatusCode(int $expectedStatusCode, Client $client) * Assert that the last validation errors within $container match the * expected keys. * - * @param array $expected A flat array of field names - * @param ContainerInterface $container + * @param array $expected A flat array of field names */ public static function assertValidationErrors(array $expected, ContainerInterface $container): void { diff --git a/src/Utils/HttpAssertions.php b/src/Utils/HttpAssertions.php index f136330a..bcfb19d2 100644 --- a/src/Utils/HttpAssertions.php +++ b/src/Utils/HttpAssertions.php @@ -27,7 +27,6 @@ class HttpAssertions extends TestCase * * @param Response $response Response object * @param bool $success to define whether the response is expected to be successful - * @param string $type */ public static function isSuccessful(Response $response, bool $success = true, string $type = 'text/html'): void { @@ -54,9 +53,6 @@ public static function isSuccessful(Response $response, bool $success = true, st * Asserts that the HTTP response code of the last request performed by * $client matches the expected code. If not, raises an error with more * information. - * - * @param int $expectedStatusCode - * @param Client $client */ public static function assertStatusCode(int $expectedStatusCode, Client $client): void { @@ -87,8 +83,7 @@ public static function assertStatusCode(int $expectedStatusCode, Client $client) * Assert that the last validation errors within $container match the * expected keys. * - * @param array $expected A flat array of field names - * @param ContainerInterface $container + * @param array $expected A flat array of field names */ public static function assertValidationErrors(array $expected, ContainerInterface $container): void { diff --git a/tests/App/Command/TestCommand.php b/tests/App/Command/TestCommand.php index c2024bbd..cf9b239b 100644 --- a/tests/App/Command/TestCommand.php +++ b/tests/App/Command/TestCommand.php @@ -37,10 +37,6 @@ protected function configure(): void ->setDescription('Test command'); } - /** - * @param InputInterface $input - * @param OutputInterface $output - */ protected function execute(InputInterface $input, OutputInterface $output) { // Symfony version check diff --git a/tests/App/Command/TestInteractiveCommand.php b/tests/App/Command/TestInteractiveCommand.php index eec7f3c1..c21eeb2b 100644 --- a/tests/App/Command/TestInteractiveCommand.php +++ b/tests/App/Command/TestInteractiveCommand.php @@ -30,10 +30,6 @@ protected function configure(): void ; } - /** - * @param InputInterface $input - * @param OutputInterface $output - */ protected function execute(InputInterface $input, OutputInterface $output) { $helper = $this->getHelper('question'); diff --git a/tests/App/Command/TestStatusCodeCommand.php b/tests/App/Command/TestStatusCodeCommand.php index ea106e97..f93dee1c 100644 --- a/tests/App/Command/TestStatusCodeCommand.php +++ b/tests/App/Command/TestStatusCodeCommand.php @@ -27,10 +27,6 @@ protected function configure(): void ->setDescription('Test command'); } - /** - * @param InputInterface $input - * @param OutputInterface $output - */ protected function execute(InputInterface $input, OutputInterface $output): int { return 10; diff --git a/tests/App/Controller/DefaultController.php b/tests/App/Controller/DefaultController.php index cf11dea4..3ed65b0b 100644 --- a/tests/App/Controller/DefaultController.php +++ b/tests/App/Controller/DefaultController.php @@ -22,9 +22,6 @@ class DefaultController extends AbstractController { - /** - * @return Response - */ public function indexAction(): Response { return $this->render( @@ -32,11 +29,6 @@ public function indexAction(): Response ); } - /** - * @param int $userId - * - * @return Response - */ public function userAction(int $userId): Response { /** @var \Liip\Acme\Tests\App\Entity\User $user */ @@ -54,21 +46,11 @@ public function userAction(int $userId): Response ); } - /** - * @param Request $request - * - * @return Response - */ public function formAction(Request $request): Response { return $this->form($request, 'form.html.twig'); } - /** - * @param Request $request - * - * @return Response - */ public function formWithEmbedAction(Request $request): Response { return $this->form($request, 'form_with_embed.html.twig'); @@ -77,11 +59,6 @@ public function formWithEmbedAction(Request $request): Response /** * Common form functionality used to test form submissions both * with and without an embedded request. - * - * @param Request $request - * @param string $template - * - * @return Response */ private function form(Request $request, string $template): Response { @@ -111,8 +88,6 @@ private function form(Request $request, string $template): Response /** * Used to test a JSON content with corresponding Content-Type. - * - * @return Response */ public function jsonAction(): Response { @@ -124,8 +99,6 @@ public function jsonAction(): Response /** * Used to embed content as a sub-request. - * - * @return Response */ public function embeddedAction(): Response {