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

testMysqlReturnsMysqlTableSeeder()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 14
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 8
nc 1
nop 0
dl 0
loc 14
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\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);
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\Seed\TableS...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
        $seederFactory = new TableSeederFactory(/** @scrutinizer ignore-type */ $processTable);
Loading history...
35
36
        $tableSeeder = $seederFactory->getSeeder($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\Seed\TableSeederFactory::getSeeder(). ( Ignorable by Annotation )

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

36
        $tableSeeder = $seederFactory->getSeeder(/** @scrutinizer ignore-type */ $config);
Loading history...
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);
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\Seed\TableS...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
        $seederFactory = new TableSeederFactory(/** @scrutinizer ignore-type */ $processTable);
Loading history...
54
55
        $seederFactory->getSeeder($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\Seed\TableSeederFactory::getSeeder(). ( Ignorable by Annotation )

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

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