Skip to content

Commit

Permalink
#112 del not use class
Browse files Browse the repository at this point in the history
  • Loading branch information
bfoujols committed Aug 8, 2024
1 parent 38d7a39 commit 7a03ee1
Show file tree
Hide file tree
Showing 5 changed files with 139 additions and 2 deletions.
24 changes: 24 additions & 0 deletions app/Config/routes.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
index:
uri: /
controller: Controller\HomeController
httpMethod: [GET]
home:
uri: /home
controller: Controller\HomeController
httpMethod: [GET]
link:
uri: /link
controller: Controller\LinkController
httpMethod: [GET]
user:
uri: /user/{id}
controller: Controller\UserController
httpMethod: [GET,POST]
userUpdate:
uri: /user/{id}/update
controller: Controller\UserController
httpMethod: [GET,POST]
userName:
uri: /user/{id:\d+}[/{name}]
controller: Controller\UserController
httpMethod: [GET,POST]
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@
"symfony/yaml": "6.3.*",
"symfony/console": "6.3.*",
"nette/php-generator": "^4.1@dev",
"zircote/swagger-php": "^4.0@dev"
"zircote/swagger-php": "^4.0@dev",
"symfony/filesystem": "7.2.x-dev"
}
,
"require-dev": {
Expand Down
68 changes: 67 additions & 1 deletion composer.lock

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

4 changes: 4 additions & 0 deletions src/EduFramework/Commands/CreateApiCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,10 @@ private function generateRoute(string $name, string $uri, string $className): ar
return $router[$indexName . $name];
}

/**
* Génération du fichier de base openapi
* @return void
*/
private function generateOpenApi(): void
{
$filename = self::CONTROLLER_DIR . self::API_DIR . 'openapi.php';
Expand Down
42 changes: 42 additions & 0 deletions tests/Command/CreateApiCommandTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<?php

namespace Command;

use PHPUnit\Framework\TestCase;

use Studoo\EduFramework\Commands\CreateApiCommand;
use Studoo\EduFramework\Core\ConfigCore;
use Symfony\Component\Console\Application;
use Symfony\Component\Console\Tester\CommandTester;
use Symfony\Component\Filesystem\Filesystem;

class CreateApiCommandTest extends TestCase
{
private $commandeTester;

protected function setUp(): void
{
(new ConfigCore([]));
$application = new Application(ConfigCore::getConfig('name'), ConfigCore::getConfig('version'));
$application->add(new CreateApiCommand());
$command = $application->find("make:api");
$this->commandeTester = new CommandTester($command);
}

protected function tearDown(): void
{
$this->commandeTester = null;
(new Filesystem())->remove("app/Config/routes.yaml");
(new Filesystem())->copy("tests/Config/routes.yaml", "app/Config/routes.yaml");
(new Filesystem())->remove("app/Controller/api/InitController.php");
(new Filesystem())->remove("app/Controller/api/openapi.php");
}

public function testCommandUri(): void
{
$this->commandeTester->execute(["controller-name" => "init"]);
$output = $this->commandeTester->getDisplay();

$this->assertStringContainsString('URI : /api/init', $output);
}
}

0 comments on commit 7a03ee1

Please sign in to comment.