Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: phpunit workflow #27

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions .github/workflows/phpunit.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: Symfony-Tests

on:
push:
branches: [ main, develop ]
pull_request:
branches: [ main, develop ]

permissions:
contents: read

jobs:
test:
runs-on: ubuntu-latest

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

- name: Set up PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.2'

# - name: Install dependencies
# run: cd backend && composer install

- name: Run PHPUnit tests
run: php bin/phpunit
4 changes: 2 additions & 2 deletions .github/workflows/vitest.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
name: Vitest Tests
on:
push:
branches: [ main, master, develop ]
branches: [ main, develop ]
pull_request:
branches: [ main, master, develop ]
branches: [ main, develop ]
jobs:
test:
timeout-minutes: 10
Expand Down
2 changes: 2 additions & 0 deletions .idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 0 additions & 5 deletions .idea/Schulbuchaktion.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

37 changes: 37 additions & 0 deletions .idea/php.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion backend/.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ APP_SECRET=YOUR_APP_SECRET
SECRET_PASSWORD=YOUR_PASSWORD
USERNAME=YOUR_USERNAME
BIND_PORT=YOUR_PORT
DATABASE_URL="mysql://root:${SECRET_PASSWORD}@127.0.0.1:${YOUR_PORT}/schulbuchaktion"
DATABASE_URL="mysql://root:${SECRET_PASSWORD}@127.0.0.1:${BIND_PORT}/schulbuchaktion"
###< doctrine/doctrine-bundle ###

###> symfony/messenger ###
Expand Down
17 changes: 17 additions & 0 deletions backend/src/Controller/TestingController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?php

namespace App\Controller;

use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Attribute\Route;

class TestingController extends AbstractController
{
#[Route('/test/example', name: 'app_testing')]
public function index(): Response
{
return $this->json(['name' => 'John']);
}

}
6 changes: 4 additions & 2 deletions backend/templates/base.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,12 @@
{% endblock %}

{% block javascripts %}
{% block importmap %}{{ importmap('app') }}{% endblock %}

{% endblock %}
</head>
<body>
{% block body %}{% endblock %}
{% block body %}

{% endblock %}
</body>
</html>
17 changes: 17 additions & 0 deletions backend/tests/TestingControllerTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?php

namespace App\Tests;

use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;

class TestingControllerTest extends WebTestCase
{
public function testJson(): void
{
$client = self::createClient();
$client->request('GET', '/test/example');
$this->assertResponseIsSuccessful();
$this->assertResponseHeaderSame('content-type', 'application/json');
$this->assertJsonStringEqualsJsonString('{"name":"John"}', $client->getResponse()->getContent());
}
}
5 changes: 5 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"require-dev": {
"symfony/test-pack": "^1.1"
}
}
Loading
Loading