Skip to content

Commit

Permalink
Test code with github actions
Browse files Browse the repository at this point in the history
  • Loading branch information
ajgarlag committed Feb 3, 2021
1 parent 3553f2d commit 5599891
Show file tree
Hide file tree
Showing 6 changed files with 57 additions and 18 deletions.
42 changes: 42 additions & 0 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: tests

on:
push:
pull_request:

jobs:
tests:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
php: [7.2, 7.3, 7.4, 8.0]
stability: [prefer-lowest, prefer-stable, dev]


name: ${{ matrix.php }}-${{ matrix.stability }}

steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Cache dependencies
uses: actions/cache@v1
with:
path: ~/.composer/cache/files
key: dependencies-php-${{ matrix.php }}-composer-${{ hashFiles('composer.json') }}

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
coverage: none

- name: Install dependencies
run: composer update --${{ matrix.stability }} --prefer-dist --no-interaction --no-progress

- name: Check coding standard
run: composer lint

- name: Execute tests
run: composer test
11 changes: 7 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@
"symfony/framework-bundle": "^4.4|^5.0"
},
"require-dev": {
"friendsofphp/php-cs-fixer": "^2.18",
"nyholm/psr7": "^1.1",
"symfony/phpunit-bridge": "^4.4.9|^5.0.9",
"symfony/yaml": "^4.4|^5.0",
"symfony/browser-kit": "^4.4|^5.0",
"doctrine/annotations": "^1.0",
"symfony/monolog-bridge": "^4.0|^5.0",
"symfony/monolog-bundle": "^3.2",
"friendsofphp/php-cs-fixer": "^2.18"
"symfony/phpunit-bridge": "^4.4.11|^5.0.11",
"symfony/yaml": "^4.4|^5.0"
},
"conflict": {
"sension/framework-extra-bundle": "<6.0"
Expand Down Expand Up @@ -51,6 +51,9 @@
"vendor/bin/simple-phpunit --colors=always"
]
},
"config": {
"sort-packages": true
},
"extra": {
"branch-alias": {
"dev-main": "1.0.x-dev"
Expand Down
1 change: 0 additions & 1 deletion phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
<php>
<server name="KERNEL_CLASS" value="Tests\Fixtures\TestKernel" />
<server name="KERNEL_DIR" value="tests/Fixtures/" />
<server name="SYMFONY_PHPUNIT_VERSION" value="7.5" />
<env name="SYMFONY_DEPRECATIONS_HELPER" value="/disabled/" />
</php>
<filter>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,24 +16,14 @@
use Psr\Http\Message\RequestInterface;
use Psr\Http\Message\ServerRequestInterface;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;

/**
* @Route("/action-arguments")
*/
class ActionArgumentsController
{
/**
* @Route("/invoke/")
*/
public function __invoke(RequestInterface $request, MessageInterface $message, ServerRequestInterface $serverRequest)
{
return new Response('<html><body>ok</body></html>');
}

/**
* @Route("/normal/")
*/
public function normalAction(RequestInterface $request, MessageInterface $message, ServerRequestInterface $serverRequest)
{
return new Response('<html><body>ok</body></html>');
Expand Down
1 change: 1 addition & 0 deletions tests/Fixtures/config/config.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
framework:
test: true
secret: test
router:
resource: "%kernel.project_dir%/config/routing.yml"

Expand Down
10 changes: 7 additions & 3 deletions tests/Fixtures/config/routing.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
action_arguments_bundle:
resource: "@ActionArgumentsBundle/Controller/ActionArgumentsController.php"
type: annotation
action_arguments_bundle_invoke:
path: '/action-arguments/invoke/'
controller: 'Tests\Fixtures\ActionArgumentsBundle\Controller\ActionArgumentsController'

action_arguments_bundle_normal:
path: '/action-arguments/normal/'
controller: 'Tests\Fixtures\ActionArgumentsBundle\Controller\ActionArgumentsController::normalAction'

0 comments on commit 5599891

Please sign in to comment.