Dsn example

public static function incompleteDsnProvider(): iterable
    {
        yield ['lokalise://default'];
    }

    public function testBaseUri()
    {
        $response = new MockResponse(json_encode(['files' => []]));
        $httpClient = new MockHttpClient([$response]);
        $factory = new LokaliseProviderFactory($httpClient$this->getLogger()$this->getDefaultLocale()$this->getLoader());
        $provider = $factory->create(new Dsn('lokalise://PROJECT_ID:API_KEY@default'));

        // Make a real HTTP request.         $provider->read(['messages']['en']);

        $this->assertMatchesRegularExpression('/https:\/\/api.lokalise.com\/api2\/projects\/PROJECT_ID\/*/', $response->getRequestUrl());
    }

    public function createFactory(): ProviderFactoryInterface
    {
        return new LokaliseProviderFactory($this->getClient()$this->getLogger()$this->getDefaultLocale()$this->getLoader());
    }
}

        return [];
    }

    /** * @dataProvider supportsProvider */
    public function testSupports(bool $expected, string $dsn)
    {
        $factory = $this->createFactory();

        $this->assertSame($expected$factory->supports(new Dsn($dsn)));
    }

    /** * @dataProvider createProvider */
    public function testCreate(string $expected, string $dsn)
    {
        $factory = $this->createFactory();
        $transport = $factory->create(new Dsn($dsn));

        $this->assertSame($expected(string) $transport);
    }
class BrevoTransportFactoryTest extends TransportFactoryTestCase
{
    public function getFactory(): TransportFactoryInterface
    {
        return new BrevoTransportFactory(null, new MockHttpClient()new NullLogger());
    }

    public static function supportsProvider(): iterable
    {
        yield [
            new Dsn('brevo', 'default'),
            true,
        ];

        yield [
            new Dsn('brevo+smtp', 'default'),
            true,
        ];

        yield [
            new Dsn('brevo+smtp', 'example.com'),
            true,
        ];

        $this->nullTransportFactory = new NullTransportFactory(
            $this->createMock(EventDispatcherInterface::class),
            $this->createMock(HttpClientInterface::class)
        );
    }

    public function testCreateThrowsUnsupportedSchemeException()
    {
        $this->expectException(UnsupportedSchemeException::class);

        $this->nullTransportFactory->create(new Dsn('foo://localhost'));
    }

    public function testCreate()
    {
        $this->assertInstanceOf(
            NullTransport::class,
            $this->nullTransportFactory->create(new Dsn('null://null'))
        );
    }
}
CrowdinProviderFactory::class => false,
            LocoProviderFactory::class => false,
            LokaliseProviderFactory::class => false,
        ]);
    }

    /** * @dataProvider messageWhereSchemeIsPartOfSchemeToPackageMapProvider */
    public function testMessageWhereSchemeIsPartOfSchemeToPackageMap(string $scheme, string $package)
    {
        $dsn = new Dsn(sprintf('%s://localhost', $scheme));

        $this->assertSame(
            sprintf('Unable to synchronize translations via "%s" as the provider is not installed. Try running "composer require %s".', $scheme$package),
            (new UnsupportedSchemeException($dsn))->getMessage()
        );
    }

    public static function messageWhereSchemeIsPartOfSchemeToPackageMapProvider(): \Generator
    {
        yield ['crowdin', 'symfony/crowdin-translation-provider'];
        yield ['loco', 'symfony/loco-translation-provider'];
        
class MailerSendTransportFactoryTest extends TransportFactoryTestCase
{
    public function getFactory(): TransportFactoryInterface
    {
        return new MailerSendTransportFactory(null, new MockHttpClient()new NullLogger());
    }

    public static function supportsProvider(): iterable
    {
        yield [
            new Dsn('mailersend', 'default'),
            true,
        ];

        yield [
            new Dsn('mailersend+smtp', 'default'),
            true,
        ];

        yield [
            new Dsn('mailersend+smtp', 'example.com'),
            true,
        ];
class SendgridTransportFactoryTest extends TransportFactoryTestCase
{
    public function getFactory(): TransportFactoryInterface
    {
        return new SendgridTransportFactory(null, new MockHttpClient()new NullLogger());
    }

    public static function supportsProvider(): iterable
    {
        yield [
            new Dsn('sendgrid+api', 'default'),
            true,
        ];

        yield [
            new Dsn('sendgrid', 'default'),
            true,
        ];

        yield [
            new Dsn('sendgrid+smtp', 'default'),
            true,
        ];
yield ['somethingElse://hubId?topic=topic'];
    }

    public function testNotFoundHubThrows()
    {
        $hub = $this->createMock(HubInterface::class);
        $hubRegistry = new HubRegistry($hub['hubId' => $hub, 'anotherHubId' => $hub]);
        $factory = new MercureTransportFactory($hubRegistry);

        $this->expectException(IncompleteDsnException::class);
        $this->expectExceptionMessage('Hub "wrongHubId" not found. Did you mean one of: "hubId", "anotherHubId"?');
        $factory->create(new Dsn('mercure://wrongHubId'));
    }
}
use Symfony\Component\Notifier\Exception\InvalidArgumentException;
use Symfony\Component\Notifier\Exception\MissingRequiredOptionException;
use Symfony\Component\Notifier\Transport\Dsn;

final class DsnTest extends TestCase
{
    /** * @dataProvider constructProvider */
    public function testConstruct(string $dsnString, string $scheme, string $host, string $user = null, string $password = null, int $port = null, array $options = [], string $path = null)
    {
        $dsn = new Dsn($dsnString);
        $this->assertSame($dsnString$dsn->getOriginalDsn());

        $this->assertSame($scheme$dsn->getScheme());
        $this->assertSame($host$dsn->getHost());
        $this->assertSame($user$dsn->getUser());
        $this->assertSame($password$dsn->getPassword());
        $this->assertSame($port$dsn->getPort());
        $this->assertSame($path$dsn->getPath());
        $this->assertSame($options$dsn->getOptions());
    }

    
class GmailTransportFactoryTest extends TransportFactoryTestCase
{
    public function getFactory(): TransportFactoryInterface
    {
        return new GmailTransportFactory(null, new MockHttpClient()new NullLogger());
    }

    public static function supportsProvider(): iterable
    {
        yield [
            new Dsn('gmail', 'default'),
            true,
        ];

        yield [
            new Dsn('gmail+smtp', 'default'),
            true,
        ];

        yield [
            new Dsn('gmail+smtps', 'default'),
            true,
        ];
use Symfony\Component\Translation\Exception\InvalidArgumentException;
use Symfony\Component\Translation\Exception\MissingRequiredOptionException;
use Symfony\Component\Translation\Provider\Dsn;

final class DsnTest extends TestCase
{
    /** * @dataProvider constructProvider */
    public function testConstruct(string $dsnString, string $scheme, string $host, string $user = null, string $password = null, int $port = null, array $options = [], string $path = null)
    {
        $dsn = new Dsn($dsnString);
        $this->assertSame($dsnString$dsn->getOriginalDsn());

        $this->assertSame($scheme$dsn->getScheme());
        $this->assertSame($host$dsn->getHost());
        $this->assertSame($user$dsn->getUser());
        $this->assertSame($password$dsn->getPassword());
        $this->assertSame($port$dsn->getPort());
        $this->assertSame($path$dsn->getPath());
        $this->assertSame($options$dsn->getOptions());
    }

    
class MandrillTransportFactoryTest extends TransportFactoryTestCase
{
    public function getFactory(): TransportFactoryInterface
    {
        return new MandrillTransportFactory(null, new MockHttpClient()new NullLogger());
    }

    public static function supportsProvider(): iterable
    {
        yield [
            new Dsn('mandrill', 'default'),
            true,
        ];

        yield [
            new Dsn('mandrill+api', 'default'),
            true,
        ];

        yield [
            new Dsn('mandrill+https', 'default'),
            true,
        ];
/** * @dataProvider fromStringProvider */
    public function testFromString(string $string, Dsn $dsn)
    {
        $this->assertEquals($dsn, Dsn::fromString($string));
    }

    public function testGetOption()
    {
        $options = ['with_value' => 'some value', 'nullable' => null];
        $dsn = new Dsn('smtp', 'example.com', null, null, null, $options);

        $this->assertSame('some value', $dsn->getOption('with_value'));
        $this->assertSame('default', $dsn->getOption('nullable', 'default'));
        $this->assertSame('default', $dsn->getOption('not_existent_property', 'default'));
    }

    /** * @dataProvider invalidDsnProvider */
    public function testInvalidDsn(string $dsn, string $exceptionMessage)
    {
        
class ScalewayTransportFactoryTest extends TransportFactoryTestCase
{
    public function getFactory(): TransportFactoryInterface
    {
        return new ScalewayTransportFactory(null, new MockHttpClient()new NullLogger());
    }

    public static function supportsProvider(): iterable
    {
        yield [
            new Dsn('scaleway+api', 'default'),
            true,
        ];

        yield [
            new Dsn('scaleway', 'default'),
            true,
        ];

        yield [
            new Dsn('scaleway+smtp', 'default'),
            true,
        ];
final class MailPaceTransportFactoryTest extends TransportFactoryTestCase
{
    public function getFactory(): TransportFactoryInterface
    {
        return new MailPaceTransportFactory(null, new MockHttpClient()new NullLogger());
    }

    public static function supportsProvider(): iterable
    {
        yield [
            new Dsn('mailpace+api', 'default'),
            true,
        ];

        yield [
            new Dsn('mailpace', 'default'),
            true,
        ];

        yield [
            new Dsn('mailpace+smtp', 'default'),
            true,
        ];
Home | Imprint | This part of the site doesn't use cookies.