refs #1081. API ImageRepository. Edit Image API with this
testing/ogcore-api/pipeline/head This commit looks good Details

pull/13/head
Manuel Aranda Rosales 2024-10-29 17:13:10 +01:00
parent edee27994b
commit 5a7afc23b9
3 changed files with 63 additions and 0 deletions

View File

@ -38,6 +38,7 @@ final class ImageFactory extends ModelFactory
'path' => self::faker()->text(255),
'size' => self::faker()->randomNumber(),
'softwareProfile' => SoftwareProfileFactory::new(),
'repository' => ImageRepositoryFactory::new(),
'updatedAt' => self::faker()->dateTime(),
'remotePc' => self::faker()->boolean(),
];

View File

@ -0,0 +1,56 @@
<?php
namespace App\Factory;
use App\Entity\ImageRepository;
use App\Repository\ImageRepositoryRepository;
use Zenstruck\Foundry\ModelFactory;
use Zenstruck\Foundry\Persistence\PersistentProxyObjectFactory;
use Zenstruck\Foundry\Persistence\Proxy;
use Zenstruck\Foundry\Persistence\ProxyRepositoryDecorator;
/**
* @extends PersistentProxyObjectFactory<ImageRepository>
*/
final class ImageRepositoryFactory extends ModelFactory
{
/**
* @see https://symfony.com/bundles/ZenstruckFoundryBundle/current/index.html#factories-as-services
*
* @todo inject services if required
*/
public function __construct()
{
parent::__construct();
}
public static function getClass(): string
{
return ImageRepository::class;
}
/**
* @see https://symfony.com/bundles/ZenstruckFoundryBundle/current/index.html#model-factories
*
* @todo add your default values here
*/
protected function getDefaults(): array
{
return [
'createdAt' => self::faker()->dateTime(),
'ip' => self::faker()->text(255),
'name' => self::faker()->text(255),
'updatedAt' => self::faker()->dateTime()
];
}
/**
* @see https://symfony.com/bundles/ZenstruckFoundryBundle/current/index.html#initialization
*/
protected function initialize(): self
{
return $this
// ->afterInstantiate(function(ImageRepository $imageRepository): void {})
;
}
}

View File

@ -4,10 +4,12 @@ namespace Functional;
use App\Entity\Client;
use App\Entity\Image;
use App\Entity\ImageRepository;
use App\Entity\OrganizationalUnit;
use App\Entity\SoftwareProfile;
use App\Factory\ClientFactory;
use App\Factory\ImageFactory;
use App\Factory\ImageRepositoryFactory;
use App\Factory\OrganizationalUnitFactory;
use App\Factory\SoftwareProfileFactory;
use App\Factory\UserFactory;
@ -67,11 +69,15 @@ class ImageTest extends AbstractTest
SoftwareProfileFactory::createOne(['description' => self::SOFTWARE_PROFILE]);
$swPIri = $this->findIriBy(SoftwareProfile::class, ['description' => self::SOFTWARE_PROFILE]);
ImageRepositoryFactory::createOne(['name' => 'repository-test']);
$irIri = $this->findIriBy(ImageRepository::class, ['name' => 'repository-test']);
$this->createClientWithCredentials()->request('POST', '/images',['json' => [
'name' => self::IMAGE_CREATE,
'size' => 123,
'path' => '/path/to/image',
'softwareProfile' => $swPIri,
'imageRepository' => $irIri
]]);
$this->assertResponseStatusCodeSame(201);