From 44aa212562cc876ba8f7652d3210cc74f3c7b8c8 Mon Sep 17 00:00:00 2001 From: MamelAlbouryNdiaye Date: Mon, 2 Jan 2023 23:32:14 +0100 Subject: [PATCH 1/2] ajout de l'entity --- Back-End/src/Entity/LandValue.php | 75 ++++++++++++++++++++++++++++++- 1 file changed, 74 insertions(+), 1 deletion(-) diff --git a/Back-End/src/Entity/LandValue.php b/Back-End/src/Entity/LandValue.php index 14560931..159116e3 100644 --- a/Back-End/src/Entity/LandValue.php +++ b/Back-End/src/Entity/LandValue.php @@ -5,9 +5,81 @@ namespace App\Entity; use ApiPlatform\Core\Annotation\ApiFilter; use ApiPlatform\Core\Annotation\ApiResource; use ApiPlatform\Core\Bridge\Doctrine\Orm\Filter\SearchFilter; +use App\Controller\Api\DonutChartController; +use App\Controller\Api\BarChartController; +use App\Controller\Api\LineChartController; +use App\Repository\LandValueRepository; use Doctrine\ORM\Mapping as ORM; - +/** + * @ORM\Entity(repositoryClass=LandValueRepository::class) + */ +#[ApiResource( + collectionOperations: [ + 'get_line_chart' => [ + 'method' => 'GET', + 'path' => '/land/linechart', + 'controller' => LineChartController::class, + 'openapi_context' => [ + 'parameters' => [[ + 'name' => 'type', + 'in' => 'query', + 'schema' => [ + 'type' => 'string', + 'enum' => ['maison', 'appartement', 'dependance', 'local'] + ] + ]] + ] + ], + 'get_donut_chart' => [ + 'method' => 'GET', + 'path' => '/land/donutchart', + 'controller' => DonutChartController::class, + 'openapi_context' => [ + 'parameters' => [[ + 'name' => 'date', + 'in' => 'query', + 'schema' => [ + 'type' => 'int', + 'enum' => [2017, 2018, 2019, 2020, 2021, 2022] + ] + ]] + ] + ], + 'get_bar_chart' => [ + 'method' => 'GET', + 'path' => '/land/barchart', + 'controller' => BarChartController::class, + 'openapi_context' => [ + 'parameters' => [ + [ + 'name' => 'group', + 'in' => 'query', + 'schema' => [ + 'type' => 'string', + 'enum' => ['day', 'month', 'year'] + ] + ], + [ + 'name' => 'start', + 'in' => 'query', + 'schema' => [ + 'type' => 'date', + ] + ], + [ + 'name' => 'end', + 'in' => 'query', + 'schema' => [ + 'type' => 'date', + ] + ] + ] + ] + ], + ],itemOperations: [] +)] +//#[ApiFilter(SearchFilter::class, properties: ['type' => 'exact'])] class LandValue { @@ -117,3 +189,4 @@ class LandValue return $this; } } + -- GitLab From 2abbcaf035e1aa5da2d7edbdf286ef26c6f8a536 Mon Sep 17 00:00:00 2001 From: MamelAlbouryNdiaye Date: Mon, 2 Jan 2023 23:38:13 +0100 Subject: [PATCH 2/2] ajout de ApiTest --- Back-End/tests/ApiTest.php | 41 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 Back-End/tests/ApiTest.php diff --git a/Back-End/tests/ApiTest.php b/Back-End/tests/ApiTest.php new file mode 100644 index 00000000..e3639198 --- /dev/null +++ b/Back-End/tests/ApiTest.php @@ -0,0 +1,41 @@ +request('GET', 'land/linechart'); + + $this->assertEquals(200, $client->getResponse()->getStatusCode()); + } + + public function testDonutChart() + { + $client = static::createClient(); + + $client->request('GET', 'land/donutchart'); + + $this->assertEquals(200, $client->getResponse()->getStatusCode()); + } + + public function testBarChart() + { + $client = static::createClient(); + + $client->request('GET', 'land/barchart'); + + $this->assertEquals(200, $client->getResponse()->getStatusCode()); + + + + } + +} -- GitLab