-
Notifications
You must be signed in to change notification settings - Fork 440
/
Copy pathDbalConnectionFactoryTest.php
59 lines (43 loc) · 1.82 KB
/
DbalConnectionFactoryTest.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
<?php
namespace Enqueue\Dbal\Tests;
use Enqueue\Dbal\DbalConnectionFactory;
use Enqueue\Dbal\DbalContext;
use Enqueue\Test\ClassExtensionTrait;
use Interop\Queue\ConnectionFactory;
use PHPUnit\Framework\TestCase;
class DbalConnectionFactoryTest extends TestCase
{
use ClassExtensionTrait;
public function testShouldImplementConnectionFactoryInterface()
{
$this->assertClassImplements(ConnectionFactory::class, DbalConnectionFactory::class);
}
public function testShouldCreateLazyContext()
{
$factory = new DbalConnectionFactory(['lazy' => true]);
$context = $factory->createContext();
$this->assertInstanceOf(DbalContext::class, $context);
$this->assertAttributeEquals(null, 'connection', $context);
$this->assertAttributeInternalType('callable', 'connectionFactory', $context);
}
public function testShouldParseGenericDSN()
{
$factory = new DbalConnectionFactory('pgsql+pdo://foo@bar');
$context = $factory->createContext();
$this->assertInstanceOf(DbalContext::class, $context);
$config = $context->getConfig();
$this->assertArrayHasKey('connection', $config);
$this->assertArrayHasKey('url', $config['connection']);
$this->assertEquals('pdo_pgsql://foo@bar', $config['connection']['url']);
}
public function testShouldParseSqliteAbsolutePathDSN()
{
$factory = new DbalConnectionFactory('sqlite+pdo:////tmp/some.sq3');
$context = $factory->createContext();
$this->assertInstanceOf(DbalContext::class, $context);
$config = $context->getConfig();
$this->assertArrayHasKey('connection', $config);
$this->assertArrayHasKey('url', $config['connection']);
$this->assertEquals('pdo_sqlite:////tmp/some.sq3', $config['connection']['url']);
}
}