Passed
Pull Request — master (#3)
by Harry
02:24
created

TableDumperFactoryTest::testLogging()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 20
Code Lines 13

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 13
nc 1
nop 0
dl 0
loc 20
rs 9.8333
c 0
b 0
f 0
1
<?php
2
3
namespace Graze\Sprout\Test\Unit\Dump;
4
5
use Graze\ParallelProcess\Pool;
6
use Graze\Sprout\Config\ConnectionConfigInterface;
7
use Graze\Sprout\Dump\Mysql\MysqlTableDumper;
8
use Graze\Sprout\Dump\TableDumperFactory;
9
use Graze\Sprout\Dump\TableDumperInterface;
10
use Graze\Sprout\Test\TestCase;
11
use Mockery;
12
use Psr\Log\LoggerInterface;
13
14
class TableDumperFactoryTest extends TestCase
15
{
16
    public function testMysqlReturnsMysqlTableDumper()
17
    {
18
        $pool = Mockery::mock(Pool::class);
19
20
        $config = Mockery::mock(ConnectionConfigInterface::class);
21
        $config->shouldReceive('getDriver')
22
               ->andReturn('mysql');
23
24
        $dumperFactory = new TableDumperFactory($pool);
0 ignored issues
show
Bug introduced by
$pool of type Mockery\MockInterface is incompatible with the type Graze\ParallelProcess\Pool expected by parameter $processPool of Graze\Sprout\Dump\TableD...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

24
        $dumperFactory = new TableDumperFactory(/** @scrutinizer ignore-type */ $pool);
Loading history...
25
26
        $tableDumper = $dumperFactory->getDumper($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\Dump\TableDumperFactory::getDumper(). ( Ignorable by Annotation )

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

26
        $tableDumper = $dumperFactory->getDumper(/** @scrutinizer ignore-type */ $config);
Loading history...
27
28
        $this->assertInstanceOf(TableDumperInterface::class, $tableDumper);
29
        $this->assertInstanceOf(MysqlTableDumper::class, $tableDumper);
30
    }
31
32
    /**
33
     * @expectedException \InvalidArgumentException
34
     */
35
    public function testUnknownThrowsException()
36
    {
37
        $pool = Mockery::mock(Pool::class);
38
39
        $config = Mockery::mock(ConnectionConfigInterface::class);
40
        $config->shouldReceive('getDriver')
41
               ->andReturn('pgsql');
42
43
        $dumperFactory = new TableDumperFactory($pool);
0 ignored issues
show
Bug introduced by
$pool of type Mockery\MockInterface is incompatible with the type Graze\ParallelProcess\Pool expected by parameter $processPool of Graze\Sprout\Dump\TableD...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

43
        $dumperFactory = new TableDumperFactory(/** @scrutinizer ignore-type */ $pool);
Loading history...
44
45
        $dumperFactory->getDumper($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\Dump\TableDumperFactory::getDumper(). ( Ignorable by Annotation )

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

45
        $dumperFactory->getDumper(/** @scrutinizer ignore-type */ $config);
Loading history...
46
    }
47
48
    public function testLogging()
49
    {
50
        $logger = Mockery::mock(LoggerInterface::class);
51
        $pool = Mockery::mock(Pool::class);
52
        $config = Mockery::mock(ConnectionConfigInterface::class);
53
        $config->shouldReceive('getDriver')
54
               ->andReturn('mysql');
55
56
        $dumperFactory = new TableDumperFactory($pool);
0 ignored issues
show
Bug introduced by
$pool of type Mockery\MockInterface is incompatible with the type Graze\ParallelProcess\Pool expected by parameter $processPool of Graze\Sprout\Dump\TableD...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

56
        $dumperFactory = new TableDumperFactory(/** @scrutinizer ignore-type */ $pool);
Loading history...
57
        $dumperFactory->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\Dump\TableDumperFactory::setLogger(). ( Ignorable by Annotation )

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

57
        $dumperFactory->setLogger(/** @scrutinizer ignore-type */ $logger);
Loading history...
58
59
        $logger->allows()
60
               ->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

60
               ->/** @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

60
               ->/** @scrutinizer ignore-call */ debug(
Loading history...
61
                   "getDumper: using mysql dumper for driver: mysql",
62
                   ['driver' => 'mysql']
63
               );
64
65
        $tableDumper = $dumperFactory->getDumper($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\Dump\TableDumperFactory::getDumper(). ( Ignorable by Annotation )

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

65
        $tableDumper = $dumperFactory->getDumper(/** @scrutinizer ignore-type */ $config);
Loading history...
66
67
        $this->assertInstanceOf(TableDumperInterface::class, $tableDumper);
68
    }
69
}
70