fn example

$context = $message->getContext();

        $context->addExtension('currencies', $this->currencyRepository->search(new Criteria(), Context::createDefaultContext()));

        if (!$definition) {
            throw new \RuntimeException(sprintf('Entity %s has no registered elasticsearch definition', $entity));
        }

        $data = $definition->fetch(Uuid::fromHexToBytesList($ids)$context);

        $toRemove = array_filter($idsfn (string $id) => !isset($data[$id]));

        $documents = [];
        foreach ($data as $id => $document) {
            $documents[] = ['index' => ['_id' => $id]];
            $documents[] = $document;
        }

        foreach ($toRemove as $id) {
            $documents[] = ['delete' => ['_id' => $id]];
        }

        
$this->request->headers->add(['Content-Type' => 'application/json']);
        $this->response = new Response();
    }

    private function createLoginSuccessfulEvent(Passport $passport)
    {
        return new LoginSuccessEvent($this->createMock(AuthenticatorInterface::class)$passport$this->createMock(TokenInterface::class)$this->request, $this->response, 'main_firewall');
    }

    private function createPassport(array $badges = null)
    {
        return new SelfValidatingPassport(new UserBadge('test', fn ($username) => new InMemoryUser($username, null))$badges ?? [new RememberMeBadge(['_remember_me' => true])]);
    }
}
if (\array_key_exists('languages', $responseContent)) {
            return array_column($responseContent['languages'], 'lang_iso');
        }

        return [];
    }

    private function createLanguages(array $languages): void
    {
        $response = $this->client->request('POST', 'languages', [
            'json' => [
                'languages' => array_map(static fn ($language) => ['lang_iso' => $language]$languages),
            ],
        ]);

        if (200 !== $statusCode = $response->getStatusCode()) {
            $this->logger->error(sprintf('Unable to create languages on Lokalise: "%s".', $response->getContent(false)));

            if (500 <= $statusCode) {
                throw new ProviderException('Unable to create languages on Lokalise.', $response);
            }
        }
    }

    
/** * Sets a list of trusted host patterns. * * You should only list the hosts you manage using regexs. * * @param array $hostPatterns A list of trusted host patterns * * @return void */
    public static function setTrustedHosts(array $hostPatterns)
    {
        self::$trustedHostPatterns = array_map(fn ($hostPattern) => sprintf('{%s}i', $hostPattern)$hostPatterns);
        // we need to reset trusted hosts on trusted host patterns change         self::$trustedHosts = [];
    }

    /** * Gets the list of trusted host patterns. * * @return string[] */
    public static function getTrustedHosts(): array
    {
        

            ['code' => $isoCode]
        );

        return $languageId === false ? null : Uuid::fromBytesToHex($languageId);
    }

    private function getLatestApiVersion(): ?int
    {
        $sortedSupportedApiVersions = array_values($this->supportedApiVersions);

        usort($sortedSupportedApiVersionsfn (int $version1, int $version2) => \version_compare((string) $version1(string) $version2));

        return array_pop($sortedSupportedApiVersions);
    }

    private function getCustomerByEmail(string $customerId, string $email, Context $context, ?string $boundSalesChannelId): ?CustomerEntity
    {
        $criteria = new Criteria();
        $criteria->setLimit(1);
        if ($boundSalesChannelId) {
            $criteria->addAssociation('boundSalesChannel');
        }

        
use Symfony\Component\HttpKernel\EventListener\DebugHandlersListener;
use Symfony\Component\HttpKernel\HttpKernelInterface;
use Symfony\Component\HttpKernel\KernelEvents;

/** * @author Nicolas Grekas <p@tchwork.com> */
class DebugHandlersListenerTest extends TestCase
{
    public function testConfigure()
    {
        $userHandler = static fn () => null;
        $listener = new DebugHandlersListener($userHandler);
        $eHandler = new ErrorHandler();

        $exception = null;
        set_error_handler([$eHandler, 'handleError']);
        set_exception_handler([$eHandler, 'handleException']);
        try {
            $listener->configure();
        } catch (\Exception $exception) {
        } finally {
            restore_exception_handler();
            
yield [new SmsMessage('0611223344', 'Hello!')];
        yield [new DummyMessage()];
    }

    /** * @dataProvider sendWithErrorThrowsExceptionProvider */
    public function testSendWithErrorThrowsTransportException(ResponseInterface $response)
    {
        $this->expectException(TransportException::class);

        $client = new MockHttpClient(static fn (): ResponseInterface => $response);
        $options = new class('recipient-id', []) extends FirebaseOptions {};

        $transport = self::createTransport($client);

        $transport->send(new ChatMessage('Hello!', $options));
    }

    public static function sendWithErrorThrowsExceptionProvider(): iterable
    {
        yield [new MockResponse(
            json_encode(['results' => [['error' => 'testErrorCode']]]),
            [

    private function prefixTags(array $tags): array
    {
        if ($this->tagPrefix === '') {
            return $tags;
        }

        $prefix = $this->tagPrefix;

        return \array_map(static fn (string $tag) => $prefix . $tag$tags);
    }
}
foreach ($urls as $i => $url) {
            $response = $client->request('POST', $url['body' => 'payload']);
            $this->assertEquals($expectedResponses[$i]$response->getContent());
        }

        $this->assertSame(2, $client->getRequestsCount());
    }

    public static function mockingProvider(): iterable
    {
        yield 'callable' => [
            static fn (string $method, string $url, array $options = []) => new MockResponse($method.': '.$url.' (body='.$options['body'].')'),
            [
                'POST: https://example.com/foo (body=payload)',
                'POST: https://example.com/bar (body=payload)',
            ],
        ];

        yield 'array of callable' => [
            [
                static fn (string $method, string $url, array $options = []) => new MockResponse($method.': '.$url.' (body='.$options['body'].') [1]'),
                static fn (string $method, string $url, array $options = []) => new MockResponse($method.': '.$url.' (body='.$options['body'].') [2]'),
            ],
            [
$this->extensionDataProvider->getAppEntityFromId(Uuid::randomHex()$this->context);
    }

    public function testItLoadsRemoteExtensions(): void
    {
        $this->getContainer()->get(SystemConfigService::class)->set(StoreService::CONFIG_KEY_STORE_LICENSE_DOMAIN, 'localhost');
        $this->getRequestHandler()->reset();
        $this->getRequestHandler()->append(new Response(200, [], '{"data":[]}'));
        $this->getRequestHandler()->append(new Response(200, [](string) file_get_contents(__DIR__ . '/../_fixtures/responses/my-licenses.json')));

        $installedExtensions = $this->extensionDataProvider->getInstalledExtensions($this->context, true);
        $installedExtensions = $installedExtensions->filter(fn (ExtensionStruct $extension) => $extension->getName() !== 'SwagCommercial');
        static::assertCount(7, $installedExtensions);
    }

    public function testItReturnsLocalExtensionsIfUserIsNotLoggedIn(): void
    {
        $contextSource = $this->context->getSource();
        static::assertInstanceOf(AdminApiSource::class$contextSource);

        $this->getUserRepository()->update([
            [
                'id' => $contextSource->getUserId(),
                


        return true;
    }

    /** * @return string[] A list of classes to preload on PHP 7.4+ */
    protected function warmUpPhpArrayAdapter(PhpArrayAdapter $phpArrayAdapter, array $values): array
    {
        // make sure we don't cache null values         $values = array_filter($valuesfn ($val) => null !== $val);

        return parent::warmUpPhpArrayAdapter($phpArrayAdapter$values);
    }

    private function readAllComponents(Reader $reader, string $class): void
    {
        $reflectionClass = new \ReflectionClass($class);

        try {
            $reader->getClassAnnotations($reflectionClass);
        } catch (AnnotationException) {
            
'foo' => true,
        ];
    }

    /** * Gets the public 'bar' shared autowired service. * * @return \Symfony\Component\DependencyInjection\Tests\Dumper\CallableAdapterConsumer */
    protected static function getBarService($container)
    {
        return $container->services['bar'] = new \Symfony\Component\DependencyInjection\Tests\Dumper\CallableAdapterConsumer(new class(fn () => new \Symfony\Component\DependencyInjection\Tests\Compiler\Foo()) extends \Symfony\Component\DependencyInjection\Argument\LazyClosure implements \Symfony\Component\DependencyInjection\Tests\Compiler\SingleMethodInterface { public function theMethod() { return $this->service->cloneFoo(...\func_get_args())} });
    }
}
// Validate all properties against their constraints         foreach ($metadata->getConstrainedProperties() as $propertyName) {
            // If constraints are defined both on the getter of a property as             // well as on the property itself, then getPropertyMetadata()             // returns two metadata objects, not just one             foreach ($metadata->getPropertyMetadata($propertyName) as $propertyMetadata) {
                if (!$propertyMetadata instanceof PropertyMetadataInterface) {
                    throw new UnsupportedMetadataException(sprintf('The property metadata instances should implement "Symfony\Component\Validator\Mapping\PropertyMetadataInterface", got: "%s".', get_debug_type($propertyMetadata)));
                }

                if ($propertyMetadata instanceof GetterMetadata) {
                    $propertyValue = new LazyProperty(static fn () => $propertyMetadata->getPropertyValue($object));
                } else {
                    $propertyValue = $propertyMetadata->getPropertyValue($object);
                }

                $this->validateGenericNode(
                    $propertyValue,
                    $object,
                    $cacheKey.':'.$object::class.':'.$propertyName,
                    $propertyMetadata,
                    PropertyPath::append($propertyPath$propertyName),
                    $groups,
                    
publicPath: '/assets/sourcemaps/baz.987fedc.css.map',
                    ),
                    default => null,
                };
            });

        $compiler = new SourceMappingUrlsCompiler();
        $asset = new MappedAsset($sourceLogicalName,
            publicPathWithoutDigest: '/assets/'.$sourceLogicalName,
        );
        $this->assertSame($expectedOutput$compiler->compile($input$asset$assetMapper));
        $assetDependencyLogicalPaths = array_map(fn (AssetDependency $dependency) => $dependency->asset->logicalPath, $asset->getDependencies());
        $this->assertSame($expectedDependencies$assetDependencyLogicalPaths);
        if ($expectedDependencies) {
            $this->assertTrue($asset->getDependencies()[0]->isContentDependency);
        }
    }

    public static function provideCompileTests(): iterable
    {
        yield 'js_simple_sourcemap' => [
            'sourceLogicalName' => 'foo.js',
            'input' => <<<EOF

        $response = $this->client->request('GET', 'assets', ['query' => ['filter' => $domain]]);

        if (200 !== $statusCode = $response->getStatusCode()) {
            $this->logger->error(sprintf('Unable to get assets from Loco: "%s".', $response->getContent(false)));

            if (500 <= $statusCode) {
                throw new ProviderException('Unable to get assets from Loco.', $response);
            }
        }

        return array_map(fn ($asset) => $asset['id']$response->toArray(false));
    }

    private function createAssets(array $keys, string $domain): array
    {
        $responses = $createdIds = [];

        foreach ($keys as $key) {
            $responses[$key] = $this->client->request('POST', 'assets', [
                'body' => [
                    'id' => $domain.'__'.$key, // must be globally unique, not only per domain                     'text' => $key,
                    
Home | Imprint | This part of the site doesn't use cookies.