-
Notifications
You must be signed in to change notification settings - Fork 431
Expand file tree
/
Copy pathDoctrineConnectionFactoryFactoryTest.php
More file actions
71 lines (57 loc) · 1.97 KB
/
Copy pathDoctrineConnectionFactoryFactoryTest.php
File metadata and controls
71 lines (57 loc) · 1.97 KB
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
60
61
62
63
64
65
66
67
68
69
70
71
<?php
declare(strict_types=1);
namespace Enqueue\Tests;
use Doctrine\Persistence\ManagerRegistry;
use Enqueue\ConnectionFactoryFactoryInterface;
use Enqueue\Dbal\ManagerRegistryConnectionFactory;
use Enqueue\Doctrine\DoctrineConnectionFactoryFactory;
use PHPUnit\Framework\TestCase;
use Prophecy\PhpUnit\ProphecyTrait;
class DoctrineConnectionFactoryFactoryTest extends TestCase
{
use ProphecyTrait;
/**
* @var ManagerRegistry|\Prophecy\Prophecy\ObjectProphecy
*/
private $registry;
/**
* @var ConnectionFactoryFactoryInterface|\Prophecy\Prophecy\ObjectProphecy
*/
private $fallbackFactory;
/**
* @var DoctrineConnectionFactoryFactory
*/
private $factory;
protected function setUp(): void
{
$this->registry = $this->prophesize(ManagerRegistry::class);
$this->fallbackFactory = $this->prophesize(ConnectionFactoryFactoryInterface::class);
$this->factory = new DoctrineConnectionFactoryFactory($this->registry->reveal(), $this->fallbackFactory->reveal());
}
public function testCreateWithoutArray()
{
$this->expectException(\InvalidArgumentException::class);
$this->expectExceptionMessage('The config must be either array or DSN string.');
$this->factory->create(true);
}
public function testCreateWithoutDsn()
{
$this->expectExceptionMessage(\InvalidArgumentException::class);
$this->expectExceptionMessage('The config must have dsn key set.');
$this->factory->create(['foo' => 'bar']);
}
public function testCreateWithDoctrineSchema()
{
$this->assertInstanceOf(
ManagerRegistryConnectionFactory::class,
$this->factory->create('doctrine://localhost:3306')
);
}
public function testCreateFallback()
{
$this->fallbackFactory
->create(['dsn' => 'fallback://'])
->shouldBeCalled();
$this->factory->create(['dsn' => 'fallback://']);
}
}