Skip to content
This repository has been archived by the owner on Oct 19, 2024. It is now read-only.

Commit

Permalink
Merge pull request #26 from Dino-Kupinic/5-symfony-add-phpunit
Browse files Browse the repository at this point in the history
feat: Added PHP-Unit ande example test
  • Loading branch information
Dino-Kupinic authored Mar 14, 2024
2 parents 3c1df55 + 926ecd2 commit 5c025f4
Show file tree
Hide file tree
Showing 8 changed files with 2,493 additions and 97 deletions.
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.

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

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

221 changes: 129 additions & 92 deletions .idea/php.xml

Large diffs are not rendered by default.

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

0 comments on commit 5c025f4

Please sign in to comment.