diff --git a/Back-End/src/Entity/LandValue.php b/Back-End/src/Entity/LandValue.php index 14560931b8958a1f16e2d6b77802f40838d27445..159116e3514696ab8e8ab673a3f31897c8c75012 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; } } + diff --git a/Back-End/tests/ApiTest.php b/Back-End/tests/ApiTest.php new file mode 100644 index 0000000000000000000000000000000000000000..e3639198f860779a28daea6d7769d340fc2c1321 --- /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()); + + + + } + +}