CustomerDefinition example


    public function testToArray(): void
    {
        $definition = CustomerDefinition::class;

        $expected = [
            'type' => 'entity',
            'entityClass' => CustomerDefinition::class,
        ];

        static::assertEquals($expected(new EntityType($definition))->toArray());
        static::assertEquals($expected(new EntityType(new CustomerDefinition()))->toArray());
    }
}
$response = json_decode((string) $this->browser->getResponse()->getContent(), true, 512, \JSON_THROW_ON_ERROR);

        static::assertTrue($response['success']);

        $criteria = new Criteria();
        $criteria->addFilter(new EqualsFilter('id', $this->customerId));

        /** @var CustomerEntity $customer */
        $customer = $this->customerRepository->search($criteria, Context::createDefaultContext())->first();

        $customerDefinition = new CustomerDefinition();
        static::assertArrayHasKey('accountType', $customerDefinition->getDefaults());
        static::assertSame($customerDefinition->getDefaults()['accountType']$customer->getAccountType());
    }

    /** * @return string[] */
    private function getValidSalutationIds(): array
    {
        /** @var EntityRepository $repository */
        $repository = $this->getContainer()->get('salutation.repository');

        


            return $event;
        });
        $importExportService = $this->createMock(ImportExportService::class);
        $importExport = new ImportExport(
            $importExportService,
            $logEntity,
            $this->createMock(FilesystemOperator::class),
            $eventDispatcher,
            $this->createMock(Connection::class),
            new StaticEntityRepository([]new CustomerDefinition()),
            $pipe,
            $reader,
            $writer,
            $this->createMock(FileService::class),
        );

        $importExportService->method('getProgress')
            ->willReturnCallback(
                static fn () => new Progress($logEntity->getId()$logEntity->getState())
            );

        
$customerEntity->setGuest(false);

        $customerRepository = new StaticEntityRepository([
            new EntitySearchResult(
                'customer',
                1,
                new EntityCollection([$customerEntity]),
                null,
                new Criteria(),
                Context::createDefaultContext(),
            ),
        ]new CustomerDefinition());

        $definition = new DataValidationDefinition('address.create');

        $addressValidation = $this->createMock(DataValidationFactoryInterface::class);
        $addressValidation->method('create')->willReturn($definition);

        $dispatcher = $this->createMock(EventDispatcherInterface::class);
        $dispatcher->method('dispatch')->willReturnCallback(function D$event) use ($definition) {
            if ($event instanceof BuildValidationEvent && $event->getName() === 'framework.validation.address.create') {
                $definition->add('company', new NotBlank());
                $definition->set('zipcode', new CustomerZipCode(['countryId' => null]));

                
->request(
                'POST',
                '/store-api/account/register',
                [],
                [],
                ['CONTENT_TYPE' => 'application/json'],
                json_encode($registrationData, \JSON_THROW_ON_ERROR)
            );

        $response = json_decode((string) $this->browser->getResponse()->getContent(), true, 512, \JSON_THROW_ON_ERROR);

        $customerDefinition = new CustomerDefinition();
        static::assertArrayHasKey('accountType', $customerDefinition->getDefaults());
        static::assertSame($customerDefinition->getDefaults()['accountType']$response['accountType']);

        static::assertNotEmpty($this->browser->getResponse()->headers->get(PlatformRequest::HEADER_CONTEXT_TOKEN));

        $this->browser
            ->request(
                'POST',
                '/store-api/account/login',
                [],
                [],
                [
Home | Imprint | This part of the site doesn't use cookies.