Repository navigation
Expand file tree
/
Copy pathMongodbConnectionFactoryTest.php
More file actions
72 lines (57 loc) · 1.98 KB
/
Copy pathMongodbConnectionFactoryTest.php
File metadata and controls
72 lines (57 loc) · 1.98 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
72
<?php
namespace Enqueue\Mongodb\Tests;
use Enqueue\Mongodb\MongodbConnectionFactory;
use Enqueue\Mongodb\MongodbContext;
use Enqueue\Test\ClassExtensionTrait;
use Enqueue\Test\ReadAttributeTrait;
use Interop\Queue\ConnectionFactory;
use PHPUnit\Framework\TestCase;
/**
* @group mongodb
*/
class MongodbConnectionFactoryTest extends TestCase
{
use ClassExtensionTrait;
use ReadAttributeTrait;
public function testShouldImplementConnectionFactoryInterface()
{
$this->assertClassImplements(ConnectionFactory::class, MongodbConnectionFactory::class);
}
public function testCouldBeConstructedWithEmptyConfiguration()
{
$params = [
'dsn' => 'mongodb://127.0.0.1/',
'dbname' => 'enqueue',
'collection_name' => 'enqueue',
];
$factory = new MongodbConnectionFactory();
$this->assertAttributeEquals($params, 'config', $factory);
}
public function testCouldBeConstructedWithCustomConfiguration()
{
$params = [
'dsn' => 'mongodb://127.0.0.3/',
'dbname' => 'enqueue',
'collection_name' => 'enqueue',
];
$factory = new MongodbConnectionFactory($params);
$this->assertAttributeEquals($params, 'config', $factory);
}
public function testCouldBeConstructedWithCustomConfigurationFromDsn()
{
$params = [
'dsn' => 'mongodb://127.0.0.3/test-db-name?enqueue_collection=collection-name&polling_interval=3000',
'dbname' => 'test-db-name',
'collection_name' => 'collection-name',
'polling_interval' => 3000,
];
$factory = new MongodbConnectionFactory($params['dsn']);
$this->assertAttributeEquals($params, 'config', $factory);
}
public function testShouldCreateContext()
{
$factory = new MongodbConnectionFactory();
$context = $factory->createContext();
$this->assertInstanceOf(MongodbContext::class, $context);
}
}