Skip to content

Commit

Permalink
Merge pull request #579 from liip/add-github-actions
Browse files Browse the repository at this point in the history
Add GitHub actions
  • Loading branch information
alexislefebvre authored Feb 24, 2021
2 parents 55016c6 + 9431293 commit 2c81a43
Show file tree
Hide file tree
Showing 9 changed files with 62 additions and 99 deletions.
58 changes: 58 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -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
3 changes: 0 additions & 3 deletions src/DependencyInjection/LiipFunctionalTestExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down
4 changes: 0 additions & 4 deletions src/Test/ValidationErrorsConstraint.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@ class ValidationErrorsConstraint extends Constraint

/**
* ValidationErrorsConstraint constructor.
*
* @param array $expect
*/
public function __construct(array $expect)
{
Expand Down Expand Up @@ -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
{
Expand Down
50 changes: 3 additions & 47 deletions src/Test/WebTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand All @@ -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
{
Expand Down Expand Up @@ -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
{
Expand Down Expand Up @@ -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
{
Expand All @@ -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
{
Expand Down Expand Up @@ -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
{
Expand All @@ -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
{
Expand All @@ -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
{
Expand Down Expand Up @@ -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
{
Expand Down Expand Up @@ -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
{
Expand All @@ -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
{
Expand All @@ -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
Expand Down Expand Up @@ -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
{
Expand All @@ -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
{
Expand Down
7 changes: 1 addition & 6 deletions src/Utils/HttpAssertions.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand All @@ -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
{
Expand Down Expand Up @@ -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
{
Expand Down
4 changes: 0 additions & 4 deletions tests/App/Command/TestCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 0 additions & 4 deletions tests/App/Command/TestInteractiveCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down
4 changes: 0 additions & 4 deletions tests/App/Command/TestStatusCodeCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
27 changes: 0 additions & 27 deletions tests/App/Controller/DefaultController.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,21 +22,13 @@

class DefaultController extends AbstractController
{
/**
* @return Response
*/
public function indexAction(): Response
{
return $this->render(
'layout.html.twig'
);
}

/**
* @param int $userId
*
* @return Response
*/
public function userAction(int $userId): Response
{
/** @var \Liip\Acme\Tests\App\Entity\User $user */
Expand All @@ -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');
Expand All @@ -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
{
Expand Down Expand Up @@ -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
{
Expand All @@ -124,8 +99,6 @@ public function jsonAction(): Response

/**
* Used to embed content as a sub-request.
*
* @return Response
*/
public function embeddedAction(): Response
{
Expand Down

0 comments on commit 2c81a43

Please sign in to comment.