-
-
Notifications
You must be signed in to change notification settings - Fork 52
/
TenantiManagerTest.php
71 lines (60 loc) · 1.66 KB
/
TenantiManagerTest.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
60
61
62
63
64
65
66
67
68
69
70
71
<?php namespace Orchestra\Tenanti\TestCase;
use Mockery as m;
use Illuminate\Container\Container;
use Orchestra\Tenanti\TenantiManager;
class TenantiManagerTest extends \PHPUnit_Framework_TestCase
{
/**
* Teardown the test environment.
*/
public function tearDown()
{
m::close();
}
/**
* Test Orchestra\Tenanti\TenantiManager::driver() method.
*
* @test
*/
public function testDriverMethod()
{
$app = new Container();
$config = [
'drivers' => ['user' => ['model' => 'User']],
'chunk' => 100,
];
$stub = new TenantiManager($app);
$stub->setConfig($config);
$resolver = $stub->driver('user');
$this->assertInstanceOf('\Orchestra\Tenanti\Migrator\Factory', $resolver);
}
/**
* Test Orchestra\Tenanti\TenantiManager::driver() method
* when driver is not available.
*
* @test
* @expectedException \InvalidArgumentException
* @expectedMessage Driver [user] not supported.
*/
public function testDriverMethodGivenDriverNotAvailable()
{
$app = new Container();
$config = [
'drivers' => [],
'chunk' => 100,
];
with(new TenantiManager($app))->setConfig($config)->driver('user');
}
/**
* Test Orchestra\Tenanti\TenantiManager::getDefaultDriver()
* is not implemented.
*
* @test
* @expectedException \InvalidArgumentException
* @expectedMessage Default driver not implemented.
*/
public function testGetDefaultDriverIsNotImplemented()
{
(new TenantiManager(null))->driver();
}
}