getOriginalDsn example


    abstract protected function getSupportedSchemes(): array;

    protected function getUser(Dsn $dsn): string
    {
        return $dsn->getUser() ?? throw new IncompleteDsnException('User is not set.', $dsn->getScheme().'://'.$dsn->getHost());
    }

    protected function getPassword(Dsn $dsn): string
    {
        return $dsn->getPassword() ?? throw new IncompleteDsnException('Password is not set.', $dsn->getOriginalDsn());
    }
}
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());
    }

    public static function constructProvider(): iterable
    {

    abstract protected function getSupportedSchemes(): array;

    protected function getUser(Dsn $dsn): string
    {
        return $dsn->getUser() ?? throw new IncompleteDsnException('User is not set.', $dsn->getScheme().'://'.$dsn->getHost());
    }

    protected function getPassword(Dsn $dsn): string
    {
        return $dsn->getPassword() ?? throw new IncompleteDsnException('Password is not set.', $dsn->getOriginalDsn());
    }
}
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());
    }

    public static function constructProvider(): iterable
    {
Home | Imprint | This part of the site doesn't use cookies.