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\Chop; |
15
|
|
|
|
16
|
|
|
use Graze\ParallelProcess\Pool; |
17
|
|
|
use Graze\Sprout\Chop\Mysql\MysqlTableChopper; |
18
|
|
|
use Graze\Sprout\Chop\TableChopperFactory; |
19
|
|
|
use Graze\Sprout\Chop\TableChopperInterface; |
20
|
|
|
use Graze\Sprout\Config\ConnectionConfigInterface; |
21
|
|
|
use Graze\Sprout\Test\TestCase; |
22
|
|
|
use Mockery; |
23
|
|
|
|
24
|
|
|
class TableChopperFactoryTest extends TestCase |
25
|
|
|
{ |
26
|
|
|
public function testMysqlReturnsMysqlTableChopper() |
27
|
|
|
{ |
28
|
|
|
$processTable = Mockery::mock(Pool::class); |
29
|
|
|
|
30
|
|
|
$config = Mockery::mock(ConnectionConfigInterface::class); |
31
|
|
|
$config->shouldReceive('getDriver') |
32
|
|
|
->andReturn('mysql'); |
33
|
|
|
|
34
|
|
|
$chopperFactory = new TableChopperFactory($processTable); |
|
|
|
|
35
|
|
|
|
36
|
|
|
$tableChopper = $chopperFactory->getChopper($config); |
|
|
|
|
37
|
|
|
|
38
|
|
|
$this->assertInstanceOf(TableChopperInterface::class, $tableChopper); |
39
|
|
|
$this->assertInstanceOf(MysqlTableChopper::class, $tableChopper); |
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
|
|
|
$chopperFactory = new TableChopperFactory($processTable); |
|
|
|
|
54
|
|
|
|
55
|
|
|
$chopperFactory->getChopper($config); |
|
|
|
|
56
|
|
|
} |
57
|
|
|
} |
58
|
|
|
|