cover example

/** @var DocumentEntity $document */
        $document = $documents->first();
        static::assertNotNull($document->getOrder());
        static::assertEquals('00000000000000000000000000000000', $document->getOrder()->getVersionId());
    }

    public function testManyToOneInheritedWorks(): void
    {
        $ids = new TestDataCollection();
        $p = (new ProductBuilder($ids, 'p1'))
            ->price(100)
            ->cover('cover')
            ->variant(
                (new ProductBuilder($ids, 'p2'))
                    ->price(200)
                    ->build()
            );

        $connection = $this->getContainer()->get(Connection::class);
        $productRepo = $this->getContainer()->get('product.repository');

        $context = Context::createDefaultContext();
        $productRepo->create([$p->build()]$context);

        

class Migration1688556247FixCoverMediaVersionIDTest extends TestCase
{
    use DatabaseTransactionBehaviour;
    use KernelTestBehaviour;

    public function testMigration(): void
    {
        $product = (new ProductBuilder(new IdsCollection(), 'test'))
            ->cover('cover')
            ->price(100)
            ->build();

        $connection = $this->getContainer()->get(Connection::class);
        $connection->executeStatement('DELETE FROM product');

        $this->getContainer()->get('product.repository')->create([$product], Context::createDefaultContext());

        $connection->executeStatement('UPDATE product SET product_media_version_id = NULL');

        $migration = new Migration1688556247FixCoverMediaVersionID();
        
use IntegrationTestBehaviour;

    public function testProductMediaConstraint(): void
    {
        $ids = new IdsCollection();

        $productRepository = $this->getContainer()->get('product.repository');

        $product = (new ProductBuilder($ids, 'p1'))
            ->price(100)
            ->media('m1')
            ->cover('m1');

        $productRepository->create([$product->build()], Context::createDefaultContext());

        $productMediaRepository = $this->getContainer()->get('product_media.repository');
        $productMediaRepository->delete([['id' => $ids->get('m1')]], Context::createDefaultContext());

        $product = $productRepository->search(new Criteria([$ids->get('p1')]), Context::createDefaultContext())->first();
        static::assertNull($product->getCoverId());
    }
}
Home | Imprint | This part of the site doesn't use cookies.