TableSeederFactoryTest   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 60
Duplicated Lines 0 %

Importance

Changes 4
Bugs 0 Features 0
Metric Value
eloc 31
c 4
b 0
f 0
dl 0
loc 60
rs 10
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A testUnknownThrowsException() 0 13 1
A testMysqlReturnsMysqlTableSeeder() 0 16 1
A testLogging() 0 22 1
1
<?php
2
/**
3
 * This file is part of graze/sprout.
4
 *
5
 * Copyright © 2018 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\Db\Mysql\MysqlTableSeeder;
19
use Graze\Sprout\Seed\TableSeederFactory;
20
use Graze\Sprout\Seed\TableSeederInterface;
21
use Graze\Sprout\Test\TestCase;
22
use League\Flysystem\AdapterInterface;
23
use Mockery;
24
use Psr\Log\LoggerInterface;
25
26
class TableSeederFactoryTest extends TestCase
27
{
28
    public function testMysqlReturnsMysqlTableSeeder()
29
    {
30
        $processTable = Mockery::mock(Pool::class);
31
32
        $config = Mockery::mock(ConnectionConfigInterface::class);
33
        $config->shouldReceive('getDriver')
34
               ->andReturn('mysql');
35
36
        $fileSystem = Mockery::mock(AdapterInterface::class);
37
38
        $seederFactory = new TableSeederFactory($processTable, $fileSystem);
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

38
        $seederFactory = new TableSeederFactory(/** @scrutinizer ignore-type */ $processTable, $fileSystem);
Loading history...
Bug introduced by
$fileSystem of type Mockery\MockInterface is incompatible with the type League\Flysystem\AdapterInterface expected by parameter $filesystem 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

38
        $seederFactory = new TableSeederFactory($processTable, /** @scrutinizer ignore-type */ $fileSystem);
Loading history...
39
40
        $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

40
        $tableSeeder = $seederFactory->getSeeder(/** @scrutinizer ignore-type */ $config);
Loading history...
41
42
        $this->assertInstanceOf(TableSeederInterface::class, $tableSeeder);
43
        $this->assertInstanceOf(MysqlTableSeeder::class, $tableSeeder);
44
    }
45
46
    /**
47
     * @expectedException \InvalidArgumentException
48
     */
49
    public function testUnknownThrowsException()
50
    {
51
        $processTable = Mockery::mock(Pool::class);
52
53
        $config = Mockery::mock(ConnectionConfigInterface::class);
54
        $config->shouldReceive('getDriver')
55
               ->andReturn('pgsql');
56
57
        $fileSystem = Mockery::mock(AdapterInterface::class);
58
59
        $seederFactory = new TableSeederFactory($processTable, $fileSystem);
0 ignored issues
show
Bug introduced by
$fileSystem of type Mockery\MockInterface is incompatible with the type League\Flysystem\AdapterInterface expected by parameter $filesystem 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

59
        $seederFactory = new TableSeederFactory($processTable, /** @scrutinizer ignore-type */ $fileSystem);
Loading history...
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

59
        $seederFactory = new TableSeederFactory(/** @scrutinizer ignore-type */ $processTable, $fileSystem);
Loading history...
60
61
        $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

61
        $seederFactory->getSeeder(/** @scrutinizer ignore-type */ $config);
Loading history...
62
    }
63
64
    public function testLogging()
65
    {
66
        $logger = Mockery::mock(LoggerInterface::class);
67
        $pool = Mockery::mock(Pool::class);
68
        $config = Mockery::mock(ConnectionConfigInterface::class);
69
        $config->shouldReceive('getDriver')
70
               ->andReturn('mysql');
71
72
        $fileSystem = Mockery::mock(AdapterInterface::class);
73
74
        $seederFactory = new TableSeederFactory($pool, $fileSystem);
0 ignored issues
show
Bug introduced by
$fileSystem of type Mockery\MockInterface is incompatible with the type League\Flysystem\AdapterInterface expected by parameter $filesystem 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

74
        $seederFactory = new TableSeederFactory($pool, /** @scrutinizer ignore-type */ $fileSystem);
Loading history...
Bug introduced by
$pool 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

74
        $seederFactory = new TableSeederFactory(/** @scrutinizer ignore-type */ $pool, $fileSystem);
Loading history...
75
        $seederFactory->setLogger($logger);
0 ignored issues
show
Bug introduced by
$logger of type Mockery\MockInterface is incompatible with the type Psr\Log\LoggerInterface expected by parameter $logger of Graze\Sprout\Seed\TableSeederFactory::setLogger(). ( Ignorable by Annotation )

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

75
        $seederFactory->setLogger(/** @scrutinizer ignore-type */ $logger);
Loading history...
76
77
        $logger->allows()
78
               ->debug(
0 ignored issues
show
Bug introduced by
The method debug() does not exist on Mockery\Expectation. ( Ignorable by Annotation )

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

78
               ->/** @scrutinizer ignore-call */ debug(

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
Bug introduced by
The method debug() does not exist on Mockery\ExpectationInterface. It seems like you code against a sub-type of Mockery\ExpectationInterface such as Mockery\CompositeExpectation. ( Ignorable by Annotation )

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

78
               ->/** @scrutinizer ignore-call */ debug(
Loading history...
79
                   "getSeeder: using mysql seeder for driver: mysql",
80
                   ['driver' => 'mysql']
81
               );
82
83
        $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

83
        $tableSeeder = $seederFactory->getSeeder(/** @scrutinizer ignore-type */ $config);
Loading history...
84
85
        $this->assertInstanceOf(TableSeederInterface::class, $tableSeeder);
86
    }
87
}
88