Compare commits
6 commits
Author | SHA1 | Date | |
---|---|---|---|
696760659f | |||
5a0df96142 | |||
b00b923d43 | |||
d92a63fd7d | |||
2b5d943116 | |||
9119029419 |
25 changed files with 2771 additions and 292 deletions
4
.env
4
.env
|
@ -28,3 +28,7 @@ DATABASE_URL="sqlite:///%kernel.project_dir%/var/data.db"
|
||||||
# DATABASE_URL="mysql://app:!ChangeMe!@127.0.0.1:3306/app?serverVersion=10.11.2-MariaDB&charset=utf8mb4"
|
# DATABASE_URL="mysql://app:!ChangeMe!@127.0.0.1:3306/app?serverVersion=10.11.2-MariaDB&charset=utf8mb4"
|
||||||
# DATABASE_URL="postgresql://app:!ChangeMe!@127.0.0.1:5432/app?serverVersion=16&charset=utf8"
|
# DATABASE_URL="postgresql://app:!ChangeMe!@127.0.0.1:5432/app?serverVersion=16&charset=utf8"
|
||||||
###< doctrine/doctrine-bundle ###
|
###< doctrine/doctrine-bundle ###
|
||||||
|
|
||||||
|
###> nelmio/cors-bundle ###
|
||||||
|
CORS_ALLOW_ORIGIN='^https?://(localhost|127\.0\.0\.1)(:[0-9]+)?$'
|
||||||
|
###< nelmio/cors-bundle ###
|
||||||
|
|
|
@ -7,18 +7,29 @@
|
||||||
"php": ">=8.4",
|
"php": ">=8.4",
|
||||||
"ext-ctype": "*",
|
"ext-ctype": "*",
|
||||||
"ext-iconv": "*",
|
"ext-iconv": "*",
|
||||||
|
"api-platform/doctrine-orm": "^4.0",
|
||||||
|
"api-platform/symfony": "^4.0",
|
||||||
"doctrine/dbal": "^4.1",
|
"doctrine/dbal": "^4.1",
|
||||||
"doctrine/doctrine-bundle": "^2.12",
|
"doctrine/doctrine-bundle": "^2.12",
|
||||||
"doctrine/doctrine-migrations-bundle": "^3.3.1",
|
"doctrine/doctrine-migrations-bundle": "^3.3.1",
|
||||||
"doctrine/orm": "^3.2.1",
|
"doctrine/orm": "^3.2.1",
|
||||||
|
"nelmio/cors-bundle": "^2.5",
|
||||||
|
"phpdocumentor/reflection-docblock": "^5.6",
|
||||||
|
"phpstan/phpdoc-parser": "^1.33",
|
||||||
"psr/clock": "^1.0",
|
"psr/clock": "^1.0",
|
||||||
|
"symfony/asset": "7.2.*",
|
||||||
"symfony/console": "7.1.*",
|
"symfony/console": "7.1.*",
|
||||||
"symfony/dotenv": "7.1.*",
|
"symfony/dotenv": "7.1.*",
|
||||||
|
"symfony/expression-language": "7.2.*",
|
||||||
"symfony/flex": "^2.4.6",
|
"symfony/flex": "^2.4.6",
|
||||||
"symfony/form": "7.1.*",
|
"symfony/form": "7.1.*",
|
||||||
"symfony/framework-bundle": "7.1.*",
|
"symfony/framework-bundle": "7.1.*",
|
||||||
|
"symfony/property-access": "7.2.*",
|
||||||
|
"symfony/property-info": "7.2.*",
|
||||||
"symfony/runtime": "7.1.*",
|
"symfony/runtime": "7.1.*",
|
||||||
|
"symfony/security-bundle": "7.2.*",
|
||||||
"symfony/security-csrf": "7.1.*",
|
"symfony/security-csrf": "7.1.*",
|
||||||
|
"symfony/serializer": "7.2.*",
|
||||||
"symfony/twig-bundle": "7.1.*",
|
"symfony/twig-bundle": "7.1.*",
|
||||||
"symfony/uid": "7.1.*",
|
"symfony/uid": "7.1.*",
|
||||||
"symfony/validator": "7.1.*",
|
"symfony/validator": "7.1.*",
|
||||||
|
@ -26,10 +37,12 @@
|
||||||
},
|
},
|
||||||
"require-dev": {
|
"require-dev": {
|
||||||
"doctrine/doctrine-fixtures-bundle": "^4.0",
|
"doctrine/doctrine-fixtures-bundle": "^4.0",
|
||||||
|
"liip/test-fixtures-bundle": "^3.2",
|
||||||
"lubiana/code-quality": "^1.7.2",
|
"lubiana/code-quality": "^1.7.2",
|
||||||
"pestphp/pest": "^3.6",
|
"pestphp/pest": "^3.6",
|
||||||
"symfony/browser-kit": "7.2.*",
|
"symfony/browser-kit": "7.2.*",
|
||||||
"symfony/css-selector": "7.2.*",
|
"symfony/css-selector": "7.2.*",
|
||||||
|
"symfony/http-client": "7.2.*",
|
||||||
"symfony/maker-bundle": "^1.60",
|
"symfony/maker-bundle": "^1.60",
|
||||||
"symfony/stopwatch": "7.2.*",
|
"symfony/stopwatch": "7.2.*",
|
||||||
"symfony/web-profiler-bundle": "7.2.*",
|
"symfony/web-profiler-bundle": "7.2.*",
|
||||||
|
@ -85,7 +98,7 @@
|
||||||
"rector",
|
"rector",
|
||||||
"ecs --fix || ecs --fix"
|
"ecs --fix || ecs --fix"
|
||||||
],
|
],
|
||||||
"test": "pest"
|
"test": "pest --parallel"
|
||||||
},
|
},
|
||||||
"conflict": {
|
"conflict": {
|
||||||
"symfony/symfony": "*"
|
"symfony/symfony": "*"
|
||||||
|
|
2775
composer.lock
generated
2775
composer.lock
generated
File diff suppressed because it is too large
Load diff
|
@ -1,10 +1,14 @@
|
||||||
<?php declare(strict_types=1);
|
<?php declare(strict_types=1);
|
||||||
|
|
||||||
|
use ApiPlatform\Symfony\Bundle\ApiPlatformBundle;
|
||||||
use Doctrine\Bundle\DoctrineBundle\DoctrineBundle;
|
use Doctrine\Bundle\DoctrineBundle\DoctrineBundle;
|
||||||
use Doctrine\Bundle\FixturesBundle\DoctrineFixturesBundle;
|
use Doctrine\Bundle\FixturesBundle\DoctrineFixturesBundle;
|
||||||
use Doctrine\Bundle\MigrationsBundle\DoctrineMigrationsBundle;
|
use Doctrine\Bundle\MigrationsBundle\DoctrineMigrationsBundle;
|
||||||
|
use Liip\TestFixturesBundle\LiipTestFixturesBundle;
|
||||||
|
use Nelmio\CorsBundle\NelmioCorsBundle;
|
||||||
use Symfony\Bundle\FrameworkBundle\FrameworkBundle;
|
use Symfony\Bundle\FrameworkBundle\FrameworkBundle;
|
||||||
use Symfony\Bundle\MakerBundle\MakerBundle;
|
use Symfony\Bundle\MakerBundle\MakerBundle;
|
||||||
|
use Symfony\Bundle\SecurityBundle\SecurityBundle;
|
||||||
use Symfony\Bundle\TwigBundle\TwigBundle;
|
use Symfony\Bundle\TwigBundle\TwigBundle;
|
||||||
use Symfony\Bundle\WebProfilerBundle\WebProfilerBundle;
|
use Symfony\Bundle\WebProfilerBundle\WebProfilerBundle;
|
||||||
|
|
||||||
|
@ -32,4 +36,17 @@ return [
|
||||||
'dev' => true,
|
'dev' => true,
|
||||||
'test' => true,
|
'test' => true,
|
||||||
],
|
],
|
||||||
|
SecurityBundle::class => [
|
||||||
|
'all' => true,
|
||||||
|
],
|
||||||
|
NelmioCorsBundle::class => [
|
||||||
|
'all' => true,
|
||||||
|
],
|
||||||
|
ApiPlatformBundle::class => [
|
||||||
|
'all' => true,
|
||||||
|
],
|
||||||
|
LiipTestFixturesBundle::class => [
|
||||||
|
'dev' => true,
|
||||||
|
'test' => true,
|
||||||
|
],
|
||||||
];
|
];
|
||||||
|
|
22
config/packages/api_platform.php
Normal file
22
config/packages/api_platform.php
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
<?php declare(strict_types=1);
|
||||||
|
|
||||||
|
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
|
||||||
|
|
||||||
|
return static function (ContainerConfigurator $containerConfigurator): void {
|
||||||
|
$containerConfigurator->extension('api_platform', [
|
||||||
|
'title' => 'Futtern API',
|
||||||
|
'version' => '1.0.0',
|
||||||
|
'show_webby' => false,
|
||||||
|
'enable_swagger' => true,
|
||||||
|
'defaults' => [
|
||||||
|
'stateless' => true,
|
||||||
|
'cache_headers' => [
|
||||||
|
'vary' => [
|
||||||
|
'Content-Type',
|
||||||
|
'Authorization',
|
||||||
|
'Origin',
|
||||||
|
],
|
||||||
|
],
|
||||||
|
],
|
||||||
|
]);
|
||||||
|
};
|
33
config/packages/nelmio_cors.php
Normal file
33
config/packages/nelmio_cors.php
Normal file
|
@ -0,0 +1,33 @@
|
||||||
|
<?php declare(strict_types=1);
|
||||||
|
|
||||||
|
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
|
||||||
|
|
||||||
|
return static function (ContainerConfigurator $containerConfigurator): void {
|
||||||
|
$containerConfigurator->extension('nelmio_cors', [
|
||||||
|
'defaults' => [
|
||||||
|
'origin_regex' => true,
|
||||||
|
'allow_origin' => [
|
||||||
|
'%env(CORS_ALLOW_ORIGIN)%',
|
||||||
|
],
|
||||||
|
'allow_methods' => [
|
||||||
|
'GET',
|
||||||
|
'OPTIONS',
|
||||||
|
'POST',
|
||||||
|
'PUT',
|
||||||
|
'PATCH',
|
||||||
|
'DELETE',
|
||||||
|
],
|
||||||
|
'allow_headers' => [
|
||||||
|
'Content-Type',
|
||||||
|
'Authorization',
|
||||||
|
],
|
||||||
|
'expose_headers' => [
|
||||||
|
'Link',
|
||||||
|
],
|
||||||
|
'max_age' => 3600,
|
||||||
|
],
|
||||||
|
'paths' => [
|
||||||
|
'^/' => null,
|
||||||
|
],
|
||||||
|
]);
|
||||||
|
};
|
40
config/packages/security.php
Normal file
40
config/packages/security.php
Normal file
|
@ -0,0 +1,40 @@
|
||||||
|
<?php declare(strict_types=1);
|
||||||
|
|
||||||
|
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
|
||||||
|
use Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface;
|
||||||
|
|
||||||
|
return static function (ContainerConfigurator $containerConfigurator): void {
|
||||||
|
$containerConfigurator->extension('security', [
|
||||||
|
'password_hashers' => [
|
||||||
|
PasswordAuthenticatedUserInterface::class => 'auto',
|
||||||
|
],
|
||||||
|
'providers' => [
|
||||||
|
'users_in_memory' => [
|
||||||
|
'memory' => null,
|
||||||
|
],
|
||||||
|
],
|
||||||
|
'firewalls' => [
|
||||||
|
'dev' => [
|
||||||
|
'pattern' => '^/(_(profiler|wdt)|css|images|js)/',
|
||||||
|
'security' => false,
|
||||||
|
],
|
||||||
|
'main' => [
|
||||||
|
'lazy' => true,
|
||||||
|
'provider' => 'users_in_memory',
|
||||||
|
],
|
||||||
|
],
|
||||||
|
'access_control' => null,
|
||||||
|
]);
|
||||||
|
if ($containerConfigurator->env() === 'test') {
|
||||||
|
$containerConfigurator->extension('security', [
|
||||||
|
'password_hashers' => [
|
||||||
|
PasswordAuthenticatedUserInterface::class => [
|
||||||
|
'algorithm' => 'auto',
|
||||||
|
'cost' => 4,
|
||||||
|
'time_cost' => 3,
|
||||||
|
'memory_cost' => 10,
|
||||||
|
],
|
||||||
|
],
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
};
|
8
config/routes/api_platform.php
Normal file
8
config/routes/api_platform.php
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
<?php declare(strict_types=1);
|
||||||
|
|
||||||
|
use Symfony\Component\Routing\Loader\Configurator\RoutingConfigurator;
|
||||||
|
|
||||||
|
return static function (RoutingConfigurator $routingConfigurator): void {
|
||||||
|
$routingConfigurator->import('.', 'api_platform')
|
||||||
|
->prefix('/api');
|
||||||
|
};
|
7
config/routes/security.php
Normal file
7
config/routes/security.php
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
<?php declare(strict_types=1);
|
||||||
|
|
||||||
|
use Symfony\Component\Routing\Loader\Configurator\RoutingConfigurator;
|
||||||
|
|
||||||
|
return static function (RoutingConfigurator $routingConfigurator): void {
|
||||||
|
$routingConfigurator->import('security.route_loader.logout', 'service');
|
||||||
|
};
|
|
@ -15,7 +15,6 @@ do
|
||||||
cp -r ../../"$path" ./
|
cp -r ../../"$path" ./
|
||||||
done
|
done
|
||||||
|
|
||||||
rm ./bin/phpunit
|
|
||||||
APP_ENV=prod composer install --no-dev -a
|
APP_ENV=prod composer install --no-dev -a
|
||||||
rm -rf ./var/cache
|
rm -rf ./var/cache
|
||||||
|
|
||||||
|
|
|
@ -26,12 +26,12 @@ ExecStart=/usr/bin/podman run \
|
||||||
--replace \
|
--replace \
|
||||||
-d \
|
-d \
|
||||||
--name futtern-php \
|
--name futtern-php \
|
||||||
--volume %h/futtern/etc/php83/php-fpm.d/www.conf:/etc/php83/php-fpm.d/www.conf \
|
--volume %h/futtern/etc/php84/php-fpm.d/www.conf:/etc/php84/php-fpm.d/www.conf \
|
||||||
--volume %h/futtern/app:/var/www/html \
|
--volume %h/futtern/app:/var/www/html \
|
||||||
--volume %h/futtern/app/var:/var/www/html/var \
|
--volume %h/futtern/app/var:/var/www/html/var \
|
||||||
--env APP_ENV=prod \
|
--env APP_ENV=prod \
|
||||||
--env APP_SECRET=UwUtHiSisNotSecurePlZcHanGeMe \
|
--env APP_SECRET=UwUtHiSisNotSecurePlZcHanGeMe \
|
||||||
git.php.fail/lubiana/container/php:8.3-fpm
|
git.php.fail/lubiana/container/php:8.4-fpm
|
||||||
ExecStop=/usr/bin/podman stop \
|
ExecStop=/usr/bin/podman stop \
|
||||||
--ignore -t 10 \
|
--ignore -t 10 \
|
||||||
--cidfile=%t/%n.ctr-id
|
--cidfile=%t/%n.ctr-id
|
||||||
|
|
0
src/ApiResource/.gitignore
vendored
Normal file
0
src/ApiResource/.gitignore
vendored
Normal file
|
@ -2,8 +2,10 @@
|
||||||
|
|
||||||
namespace App\DataFixtures;
|
namespace App\DataFixtures;
|
||||||
|
|
||||||
|
use App\Entity\FoodOrder;
|
||||||
use App\Entity\FoodVendor;
|
use App\Entity\FoodVendor;
|
||||||
use App\Entity\MenuItem;
|
use App\Entity\MenuItem;
|
||||||
|
use App\Entity\OrderItem;
|
||||||
use Doctrine\Bundle\FixturesBundle\Fixture;
|
use Doctrine\Bundle\FixturesBundle\Fixture;
|
||||||
use Doctrine\Persistence\ObjectManager;
|
use Doctrine\Persistence\ObjectManager;
|
||||||
use Override;
|
use Override;
|
||||||
|
@ -39,12 +41,26 @@ final class AppFixtures extends Fixture
|
||||||
|
|
||||||
public function addMenuItemsToVendor(FoodVendor $vendor): void
|
public function addMenuItemsToVendor(FoodVendor $vendor): void
|
||||||
{
|
{
|
||||||
|
$menuItems = [];
|
||||||
foreach (range(1, 10) as $i) {
|
foreach (range(1, 10) as $i) {
|
||||||
$item = new MenuItem;
|
$item = new MenuItem;
|
||||||
$item->setName("{$vendor->getName()} Item {$i}");
|
$item->setName("{$vendor->getName()} Item {$i}");
|
||||||
$item->setFoodVendor($vendor);
|
$item->setFoodVendor($vendor);
|
||||||
$this->manager->persist($item);
|
$this->manager->persist($item);
|
||||||
$this->manager->flush();
|
$this->manager->flush();
|
||||||
|
$menuItems[] = $item;
|
||||||
|
}
|
||||||
|
|
||||||
|
$order = new FoodOrder;
|
||||||
|
$order->setFoodVendor($vendor);
|
||||||
|
|
||||||
|
$this->manager->persist($order);
|
||||||
|
foreach ($menuItems as $item) {
|
||||||
|
$orderItem = new OrderItem;
|
||||||
|
$orderItem->setMenuItem($item);
|
||||||
|
$orderItem->setCreatedBy('John');
|
||||||
|
$order->addOrderItem($orderItem);
|
||||||
|
$this->manager->persist($orderItem);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
namespace App\Entity;
|
namespace App\Entity;
|
||||||
|
|
||||||
|
use ApiPlatform\Metadata\ApiResource;
|
||||||
use App\Repository\FoodOrderRepository;
|
use App\Repository\FoodOrderRepository;
|
||||||
use DateInterval;
|
use DateInterval;
|
||||||
use DateTimeImmutable;
|
use DateTimeImmutable;
|
||||||
|
@ -14,6 +15,7 @@ use Symfony\Component\Uid\Ulid;
|
||||||
use function iterator_to_array;
|
use function iterator_to_array;
|
||||||
|
|
||||||
#[ORM\Entity(repositoryClass: FoodOrderRepository::class)]
|
#[ORM\Entity(repositoryClass: FoodOrderRepository::class)]
|
||||||
|
#[ApiResource]
|
||||||
class FoodOrder
|
class FoodOrder
|
||||||
{
|
{
|
||||||
#[ORM\Column(nullable: true)]
|
#[ORM\Column(nullable: true)]
|
||||||
|
@ -39,6 +41,7 @@ class FoodOrder
|
||||||
#[ORM\Column(type: UlidType::NAME, unique: true)]
|
#[ORM\Column(type: UlidType::NAME, unique: true)]
|
||||||
private Ulid|null $id = new Ulid
|
private Ulid|null $id = new Ulid
|
||||||
) {
|
) {
|
||||||
|
$this->id ??= new Ulid;
|
||||||
$this->orderItems = new ArrayCollection;
|
$this->orderItems = new ArrayCollection;
|
||||||
$this->open();
|
$this->open();
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
namespace App\Entity;
|
namespace App\Entity;
|
||||||
|
|
||||||
|
use ApiPlatform\Metadata\ApiResource;
|
||||||
use App\Repository\FoodVendorRepository;
|
use App\Repository\FoodVendorRepository;
|
||||||
use Doctrine\Common\Collections\ArrayCollection;
|
use Doctrine\Common\Collections\ArrayCollection;
|
||||||
use Doctrine\Common\Collections\Collection;
|
use Doctrine\Common\Collections\Collection;
|
||||||
|
@ -11,6 +12,7 @@ use Symfony\Bridge\Doctrine\Types\UlidType;
|
||||||
use Symfony\Component\Uid\Ulid;
|
use Symfony\Component\Uid\Ulid;
|
||||||
|
|
||||||
#[ORM\Entity(repositoryClass: FoodVendorRepository::class)]
|
#[ORM\Entity(repositoryClass: FoodVendorRepository::class)]
|
||||||
|
#[ApiResource]
|
||||||
class FoodVendor
|
class FoodVendor
|
||||||
{
|
{
|
||||||
#[ORM\Column(length: 50)]
|
#[ORM\Column(length: 50)]
|
||||||
|
@ -43,6 +45,7 @@ class FoodVendor
|
||||||
#[ORM\CustomIdGenerator(class: UlidGenerator::class)]
|
#[ORM\CustomIdGenerator(class: UlidGenerator::class)]
|
||||||
private Ulid|null $id = new Ulid
|
private Ulid|null $id = new Ulid
|
||||||
) {
|
) {
|
||||||
|
$this->id ??= new Ulid;
|
||||||
$this->foodOrders = new ArrayCollection;
|
$this->foodOrders = new ArrayCollection;
|
||||||
$this->menuItems = new ArrayCollection;
|
$this->menuItems = new ArrayCollection;
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
namespace App\Entity;
|
namespace App\Entity;
|
||||||
|
|
||||||
|
use ApiPlatform\Metadata\ApiResource;
|
||||||
use App\Repository\MenuItemRepository;
|
use App\Repository\MenuItemRepository;
|
||||||
use DateTimeImmutable;
|
use DateTimeImmutable;
|
||||||
use Doctrine\Common\Collections\ArrayCollection;
|
use Doctrine\Common\Collections\ArrayCollection;
|
||||||
|
@ -12,6 +13,7 @@ use Symfony\Bridge\Doctrine\Types\UlidType;
|
||||||
use Symfony\Component\Uid\Ulid;
|
use Symfony\Component\Uid\Ulid;
|
||||||
|
|
||||||
#[ORM\Entity(repositoryClass: MenuItemRepository::class)]
|
#[ORM\Entity(repositoryClass: MenuItemRepository::class)]
|
||||||
|
#[ApiResource]
|
||||||
class MenuItem
|
class MenuItem
|
||||||
{
|
{
|
||||||
#[ORM\Column(length: 255)]
|
#[ORM\Column(length: 255)]
|
||||||
|
@ -40,6 +42,7 @@ class MenuItem
|
||||||
#[ORM\CustomIdGenerator(class: UlidGenerator::class)]
|
#[ORM\CustomIdGenerator(class: UlidGenerator::class)]
|
||||||
private Ulid|null $id = new Ulid
|
private Ulid|null $id = new Ulid
|
||||||
) {
|
) {
|
||||||
|
$this->id ??= new Ulid;
|
||||||
$this->aliases = new ArrayCollection;
|
$this->aliases = new ArrayCollection;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
namespace App\Entity;
|
namespace App\Entity;
|
||||||
|
|
||||||
|
use ApiPlatform\Metadata\ApiResource;
|
||||||
use App\Repository\OrderItemRepository;
|
use App\Repository\OrderItemRepository;
|
||||||
use Doctrine\ORM\Mapping as ORM;
|
use Doctrine\ORM\Mapping as ORM;
|
||||||
use Symfony\Bridge\Doctrine\IdGenerator\UlidGenerator;
|
use Symfony\Bridge\Doctrine\IdGenerator\UlidGenerator;
|
||||||
|
@ -9,14 +10,9 @@ use Symfony\Bridge\Doctrine\Types\UlidType;
|
||||||
use Symfony\Component\Uid\Ulid;
|
use Symfony\Component\Uid\Ulid;
|
||||||
|
|
||||||
#[ORM\Entity(repositoryClass: OrderItemRepository::class)]
|
#[ORM\Entity(repositoryClass: OrderItemRepository::class)]
|
||||||
|
#[ApiResource]
|
||||||
class OrderItem
|
class OrderItem
|
||||||
{
|
{
|
||||||
#[ORM\Id]
|
|
||||||
#[ORM\GeneratedValue(strategy: 'CUSTOM')]
|
|
||||||
#[ORM\Column(type: UlidType::NAME, unique: true)]
|
|
||||||
#[ORM\CustomIdGenerator(class: UlidGenerator::class)]
|
|
||||||
private Ulid|null $id = null;
|
|
||||||
|
|
||||||
#[ORM\Column(length: 255)]
|
#[ORM\Column(length: 255)]
|
||||||
private string|null $name = null;
|
private string|null $name = null;
|
||||||
|
|
||||||
|
@ -36,6 +32,16 @@ class OrderItem
|
||||||
])]
|
])]
|
||||||
private string|null $createdBy = 'nobody';
|
private string|null $createdBy = 'nobody';
|
||||||
|
|
||||||
|
public function __construct(
|
||||||
|
#[ORM\Id]
|
||||||
|
#[ORM\GeneratedValue(strategy: 'CUSTOM')]
|
||||||
|
#[ORM\Column(type: UlidType::NAME, unique: true)]
|
||||||
|
#[ORM\CustomIdGenerator(class: UlidGenerator::class)]
|
||||||
|
private Ulid|null $id = new Ulid
|
||||||
|
) {
|
||||||
|
$this->id ??= new Ulid;
|
||||||
|
}
|
||||||
|
|
||||||
public function getId(): Ulid|null
|
public function getId(): Ulid|null
|
||||||
{
|
{
|
||||||
return $this->id;
|
return $this->id;
|
||||||
|
@ -85,6 +91,7 @@ class OrderItem
|
||||||
public function setMenuItem(MenuItem|null $menuItem): static
|
public function setMenuItem(MenuItem|null $menuItem): static
|
||||||
{
|
{
|
||||||
$this->menuItem = $menuItem;
|
$this->menuItem = $menuItem;
|
||||||
|
$this->name = $menuItem->getName();
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
42
symfony.lock
42
symfony.lock
|
@ -1,4 +1,18 @@
|
||||||
{
|
{
|
||||||
|
"api-platform/symfony": {
|
||||||
|
"version": "4.0",
|
||||||
|
"recipe": {
|
||||||
|
"repo": "github.com/symfony/recipes",
|
||||||
|
"branch": "main",
|
||||||
|
"version": "4.0",
|
||||||
|
"ref": "e9952e9f393c2d048f10a78f272cd35e807d972b"
|
||||||
|
},
|
||||||
|
"files": [
|
||||||
|
"config/packages/api_platform.yaml",
|
||||||
|
"config/routes/api_platform.yaml",
|
||||||
|
"src/ApiResource/.gitignore"
|
||||||
|
]
|
||||||
|
},
|
||||||
"doctrine/doctrine-bundle": {
|
"doctrine/doctrine-bundle": {
|
||||||
"version": "2.12",
|
"version": "2.12",
|
||||||
"recipe": {
|
"recipe": {
|
||||||
|
@ -38,6 +52,21 @@
|
||||||
"migrations/.gitignore"
|
"migrations/.gitignore"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
"liip/test-fixtures-bundle": {
|
||||||
|
"version": "3.2.1"
|
||||||
|
},
|
||||||
|
"nelmio/cors-bundle": {
|
||||||
|
"version": "2.5",
|
||||||
|
"recipe": {
|
||||||
|
"repo": "github.com/symfony/recipes",
|
||||||
|
"branch": "main",
|
||||||
|
"version": "1.5",
|
||||||
|
"ref": "6bea22e6c564fba3a1391615cada1437d0bde39c"
|
||||||
|
},
|
||||||
|
"files": [
|
||||||
|
"config/packages/nelmio_cors.yaml"
|
||||||
|
]
|
||||||
|
},
|
||||||
"phpstan/phpstan": {
|
"phpstan/phpstan": {
|
||||||
"version": "1.11",
|
"version": "1.11",
|
||||||
"recipe": {
|
"recipe": {
|
||||||
|
@ -135,6 +164,19 @@
|
||||||
"config/routes.yaml"
|
"config/routes.yaml"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
"symfony/security-bundle": {
|
||||||
|
"version": "7.2",
|
||||||
|
"recipe": {
|
||||||
|
"repo": "github.com/symfony/recipes",
|
||||||
|
"branch": "main",
|
||||||
|
"version": "6.4",
|
||||||
|
"ref": "2ae08430db28c8eb4476605894296c82a642028f"
|
||||||
|
},
|
||||||
|
"files": [
|
||||||
|
"config/packages/security.yaml",
|
||||||
|
"config/routes/security.yaml"
|
||||||
|
]
|
||||||
|
},
|
||||||
"symfony/twig-bundle": {
|
"symfony/twig-bundle": {
|
||||||
"version": "7.1",
|
"version": "7.1",
|
||||||
"recipe": {
|
"recipe": {
|
||||||
|
|
|
@ -34,7 +34,8 @@
|
||||||
<a
|
<a
|
||||||
href="https://git.hannover.ccc.de/lubiana/futtern/issues/new"
|
href="https://git.hannover.ccc.de/lubiana/futtern/issues/new"
|
||||||
target="_blank"
|
target="_blank"
|
||||||
>Create Issue</a>
|
>Create Issue</a> /
|
||||||
|
<a href="/api">API</a>
|
||||||
</nav>
|
</nav>
|
||||||
</header>
|
</header>
|
||||||
<main>
|
<main>
|
||||||
|
|
|
@ -40,6 +40,7 @@
|
||||||
<table class="table">
|
<table class="table">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
|
<th>Index</th>
|
||||||
<th>username</th>
|
<th>username</th>
|
||||||
<th>name</th>
|
<th>name</th>
|
||||||
<th>extras</th>
|
<th>extras</th>
|
||||||
|
@ -49,6 +50,7 @@
|
||||||
<tbody>
|
<tbody>
|
||||||
{% for item in food_order.orderItemsSortedByName %}
|
{% for item in food_order.orderItemsSortedByName %}
|
||||||
<tr>
|
<tr>
|
||||||
|
<td>{{ loop.index }}</td>
|
||||||
<td>{{ item.createdBy }}</td>
|
<td>{{ item.createdBy }}</td>
|
||||||
<td>{{ item.name }}</td>
|
<td>{{ item.name }}</td>
|
||||||
<td>{{ item.extras }}</td>
|
<td>{{ item.extras }}</td>
|
||||||
|
|
26
tests/DbApiTestCase.php
Normal file
26
tests/DbApiTestCase.php
Normal file
|
@ -0,0 +1,26 @@
|
||||||
|
<?php declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace App\Tests;
|
||||||
|
|
||||||
|
use ApiPlatform\Symfony\Bundle\Test\ApiTestCase;
|
||||||
|
use ApiPlatform\Symfony\Bundle\Test\Client;
|
||||||
|
use App\DataFixtures\AppFixtures;
|
||||||
|
use Doctrine\ORM\EntityManagerInterface;
|
||||||
|
use Liip\TestFixturesBundle\Services\DatabaseToolCollection;
|
||||||
|
use Override;
|
||||||
|
|
||||||
|
abstract class DbApiTestCase extends ApiTestCase
|
||||||
|
{
|
||||||
|
protected EntityManagerInterface $manager;
|
||||||
|
protected Client $client;
|
||||||
|
|
||||||
|
#[Override]
|
||||||
|
protected function setUp(): void
|
||||||
|
{
|
||||||
|
parent::setUp();
|
||||||
|
$this->client = static::createClient();
|
||||||
|
$this->manager = static::getContainer()->get('doctrine')->getManager();
|
||||||
|
$toolKit = self::getContainer()->get(DatabaseToolCollection::class)->get();
|
||||||
|
$toolKit->loadFixtures([AppFixtures::class]);
|
||||||
|
}
|
||||||
|
}
|
15
tests/Feature/Api/ApiSmokeTest.php
Normal file
15
tests/Feature/Api/ApiSmokeTest.php
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
<?php declare(strict_types=1);
|
||||||
|
|
||||||
|
test('orders', function (): void {
|
||||||
|
$response = $this->client->request('GET', '/api/food_orders');
|
||||||
|
$this->assertResponseIsSuccessful();
|
||||||
|
$this->assertResponseHeaderSame('content-type', 'application/ld+json; charset=utf-8');
|
||||||
|
$this->assertJsonContains([
|
||||||
|
'@context' => '/api/contexts/FoodOrder',
|
||||||
|
'@id' => '/api/food_orders',
|
||||||
|
'@type' => 'Collection',
|
||||||
|
'totalItems' => 1,
|
||||||
|
]);
|
||||||
|
$array = $response->toArray();
|
||||||
|
expect($array['member'][0]['orderItems'])->toHaveCount(10);
|
||||||
|
});
|
|
@ -1,5 +1,6 @@
|
||||||
<?php declare(strict_types=1);
|
<?php declare(strict_types=1);
|
||||||
|
|
||||||
|
use App\Tests\DbApiTestCase;
|
||||||
use App\Tests\DbWebTest;
|
use App\Tests\DbWebTest;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -15,6 +16,8 @@ use App\Tests\DbWebTest;
|
||||||
|
|
||||||
pest()
|
pest()
|
||||||
->extends(DbWebTest::class)->in('Feature/Controller/*.php');
|
->extends(DbWebTest::class)->in('Feature/Controller/*.php');
|
||||||
|
pest()
|
||||||
|
->extends(DbApiTestCase::class)->in('Feature/Api/*.php');
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|--------------------------------------------------------------------------
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
@ -6,6 +6,8 @@ require dirname(__DIR__) . '/vendor/autoload.php';
|
||||||
|
|
||||||
if (method_exists(Dotenv::class, 'bootEnv')) {
|
if (method_exists(Dotenv::class, 'bootEnv')) {
|
||||||
(new Dotenv)->bootEnv(dirname(__DIR__) . '/.env');
|
(new Dotenv)->bootEnv(dirname(__DIR__) . '/.env');
|
||||||
|
$token = $_SERVER['TEST_TOKEN'] ?? '';
|
||||||
|
$_ENV['DATABASE_URL'] .= $token;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($_SERVER['APP_DEBUG']) {
|
if ($_SERVER['APP_DEBUG']) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue