DriverRequiredTest.php 795 Bytes
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
<?php

declare(strict_types=1);

namespace Doctrine\Tests\DBAL\Exception;

use Doctrine\DBAL\DBALException;
use Doctrine\DBAL\Exception\DriverRequired;
use PHPUnit\Framework\TestCase;
use function sprintf;

class DriverRequiredTest extends TestCase
{
    public function testDriverRequiredWithUrl() : void
    {
        $url       = 'mysql://localhost';
        $exception = DriverRequired::new($url);

        self::assertInstanceOf(DBALException::class, $exception);
        self::assertSame(
            sprintf(
22 23
                'The options "driver" or "driverClass" are mandatory if a connection URL without scheme ' .
                'is given to DriverManager::getConnection(). Given URL "%s".',
24 25 26 27 28 29
                $url
            ),
            $exception->getMessage()
        );
    }
}