refs #1081. API ImageRepository. Edit Image API with this
testing/ogcore-api/pipeline/head This commit looks good
Details
testing/ogcore-api/pipeline/head This commit looks good
Details
parent
edee27994b
commit
5a7afc23b9
|
@ -38,6 +38,7 @@ final class ImageFactory extends ModelFactory
|
||||||
'path' => self::faker()->text(255),
|
'path' => self::faker()->text(255),
|
||||||
'size' => self::faker()->randomNumber(),
|
'size' => self::faker()->randomNumber(),
|
||||||
'softwareProfile' => SoftwareProfileFactory::new(),
|
'softwareProfile' => SoftwareProfileFactory::new(),
|
||||||
|
'repository' => ImageRepositoryFactory::new(),
|
||||||
'updatedAt' => self::faker()->dateTime(),
|
'updatedAt' => self::faker()->dateTime(),
|
||||||
'remotePc' => self::faker()->boolean(),
|
'remotePc' => self::faker()->boolean(),
|
||||||
];
|
];
|
||||||
|
|
|
@ -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 {})
|
||||||
|
;
|
||||||
|
}
|
||||||
|
}
|
|
@ -4,10 +4,12 @@ namespace Functional;
|
||||||
|
|
||||||
use App\Entity\Client;
|
use App\Entity\Client;
|
||||||
use App\Entity\Image;
|
use App\Entity\Image;
|
||||||
|
use App\Entity\ImageRepository;
|
||||||
use App\Entity\OrganizationalUnit;
|
use App\Entity\OrganizationalUnit;
|
||||||
use App\Entity\SoftwareProfile;
|
use App\Entity\SoftwareProfile;
|
||||||
use App\Factory\ClientFactory;
|
use App\Factory\ClientFactory;
|
||||||
use App\Factory\ImageFactory;
|
use App\Factory\ImageFactory;
|
||||||
|
use App\Factory\ImageRepositoryFactory;
|
||||||
use App\Factory\OrganizationalUnitFactory;
|
use App\Factory\OrganizationalUnitFactory;
|
||||||
use App\Factory\SoftwareProfileFactory;
|
use App\Factory\SoftwareProfileFactory;
|
||||||
use App\Factory\UserFactory;
|
use App\Factory\UserFactory;
|
||||||
|
@ -67,11 +69,15 @@ class ImageTest extends AbstractTest
|
||||||
SoftwareProfileFactory::createOne(['description' => self::SOFTWARE_PROFILE]);
|
SoftwareProfileFactory::createOne(['description' => self::SOFTWARE_PROFILE]);
|
||||||
$swPIri = $this->findIriBy(SoftwareProfile::class, ['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' => [
|
$this->createClientWithCredentials()->request('POST', '/images',['json' => [
|
||||||
'name' => self::IMAGE_CREATE,
|
'name' => self::IMAGE_CREATE,
|
||||||
'size' => 123,
|
'size' => 123,
|
||||||
'path' => '/path/to/image',
|
'path' => '/path/to/image',
|
||||||
'softwareProfile' => $swPIri,
|
'softwareProfile' => $swPIri,
|
||||||
|
'imageRepository' => $irIri
|
||||||
]]);
|
]]);
|
||||||
|
|
||||||
$this->assertResponseStatusCodeSame(201);
|
$this->assertResponseStatusCodeSame(201);
|
||||||
|
|
Loading…
Reference in New Issue