1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* This file is part of graze/sprout. |
4
|
|
|
* |
5
|
|
|
* Copyright (c) 2017 Nature Delivered Ltd. <https://www.graze.com> |
6
|
|
|
* |
7
|
|
|
* For the full copyright and license information, please view the LICENSE |
8
|
|
|
* file that was distributed with this source code. |
9
|
|
|
* |
10
|
|
|
* @license https://github.com/graze/sprout/blob/master/LICENSE.md |
11
|
|
|
* @link https://github.com/graze/sprout |
12
|
|
|
*/ |
13
|
|
|
|
14
|
|
|
namespace Graze\Sprout\Test\Unit\Seed; |
15
|
|
|
|
16
|
|
|
use Graze\ParallelProcess\Pool; |
17
|
|
|
use Graze\Sprout\Config\ConnectionConfigInterface; |
18
|
|
|
use Graze\Sprout\Seed\Mysql\MysqlTableSeeder; |
19
|
|
|
use Graze\Sprout\Seed\TableSeederFactory; |
20
|
|
|
use Graze\Sprout\Seed\TableSeederInterface; |
21
|
|
|
use Graze\Sprout\Test\TestCase; |
22
|
|
|
use Mockery; |
23
|
|
|
|
24
|
|
|
class TableSeederFactoryTest extends TestCase |
25
|
|
|
{ |
26
|
|
|
public function testMysqlReturnsMysqlTableSeeder() |
27
|
|
|
{ |
28
|
|
|
$processTable = Mockery::mock(Pool::class); |
29
|
|
|
|
30
|
|
|
$config = Mockery::mock(ConnectionConfigInterface::class); |
31
|
|
|
$config->shouldReceive('getDriver') |
32
|
|
|
->andReturn('mysql'); |
33
|
|
|
|
34
|
|
|
$seederFactory = new TableSeederFactory($processTable); |
|
|
|
|
35
|
|
|
|
36
|
|
|
$tableSeeder = $seederFactory->getSeeder($config); |
|
|
|
|
37
|
|
|
|
38
|
|
|
$this->assertInstanceOf(TableSeederInterface::class, $tableSeeder); |
39
|
|
|
$this->assertInstanceOf(MysqlTableSeeder::class, $tableSeeder); |
40
|
|
|
} |
41
|
|
|
|
42
|
|
|
/** |
43
|
|
|
* @expectedException \InvalidArgumentException |
44
|
|
|
*/ |
45
|
|
|
public function testUnknownThrowsException() |
46
|
|
|
{ |
47
|
|
|
$processTable = Mockery::mock(Pool::class); |
48
|
|
|
|
49
|
|
|
$config = Mockery::mock(ConnectionConfigInterface::class); |
50
|
|
|
$config->shouldReceive('getDriver') |
51
|
|
|
->andReturn('pgsql'); |
52
|
|
|
|
53
|
|
|
$seederFactory = new TableSeederFactory($processTable); |
|
|
|
|
54
|
|
|
|
55
|
|
|
$seederFactory->getSeeder($config); |
|
|
|
|
56
|
|
|
} |
57
|
|
|
} |
58
|
|
|
|