Passed
Pull Request — master (#1)
by Harry
02:11
created

testUnknownThrowsException()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 11
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 6
nc 1
nop 0
dl 0
loc 11
rs 10
c 0
b 0
f 0
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);
0 ignored issues
show
Bug introduced by
$processTable of type Mockery\MockInterface is incompatible with the type Graze\ParallelProcess\Pool expected by parameter $processPool of Graze\Sprout\Chop\TableC...rFactory::__construct(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

34
        $chopperFactory = new TableChopperFactory(/** @scrutinizer ignore-type */ $processTable);
Loading history...
35
36
        $tableChopper = $chopperFactory->getChopper($config);
0 ignored issues
show
Bug introduced by
$config of type Mockery\MockInterface is incompatible with the type Graze\Sprout\Config\ConnectionConfigInterface expected by parameter $connection of Graze\Sprout\Chop\TableC...erFactory::getChopper(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

36
        $tableChopper = $chopperFactory->getChopper(/** @scrutinizer ignore-type */ $config);
Loading history...
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);
0 ignored issues
show
Bug introduced by
$processTable of type Mockery\MockInterface is incompatible with the type Graze\ParallelProcess\Pool expected by parameter $processPool of Graze\Sprout\Chop\TableC...rFactory::__construct(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

53
        $chopperFactory = new TableChopperFactory(/** @scrutinizer ignore-type */ $processTable);
Loading history...
54
55
        $chopperFactory->getChopper($config);
0 ignored issues
show
Bug introduced by
$config of type Mockery\MockInterface is incompatible with the type Graze\Sprout\Config\ConnectionConfigInterface expected by parameter $connection of Graze\Sprout\Chop\TableC...erFactory::getChopper(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

55
        $chopperFactory->getChopper(/** @scrutinizer ignore-type */ $config);
Loading history...
56
    }
57
}
58