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

MysqlTableDumperTest   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 22
dl 0
loc 33
rs 10
c 0
b 0
f 0
wmc 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A testDump() 0 31 1
1
<?php
2
3
namespace Graze\Sprout\Dump\Mysql;
4
5
use Graze\ParallelProcess\Pool;
6
use Graze\Sprout\Config\ConnectionConfigInterface;
7
use Graze\Sprout\Test\TestCase;
8
use Mockery;
9
use Symfony\Component\Process\Process;
10
11
/**
12
 * @runTestsInSeparateProcesses
13
 * @preserveGlobalState disabled
14
 */
15
class MysqlTableDumperTest extends TestCase
16
{
17
    public function testDump()
18
    {
19
        $process = Mockery::mock('overload:' . Process::class);
20
21
        $process->shouldReceive('setCommandLine')
22
                ->with(
23
                    'mysqldump -h\'some-host\' -u\'some-user\' -p\'some-pass\' --compress --compact --no-create-info' .
24
                    ' --extended-insert --quick --complete-insert \'some-schema\' \'some-table\'' .
25
                    '| sed \'s$VALUES ($VALUES\n($g\' | sed \'s$),($),\n($g\' > \'some-file\''
26
                )
27
                ->once();
28
29
        $config = Mockery::mock(ConnectionConfigInterface::class);
30
        $config->shouldReceive('getHost')
31
               ->andReturn('some-host');
32
        $config->shouldReceive('getUser')
33
               ->andReturn('some-user');
34
        $config->shouldReceive('getPassword')
35
               ->andReturn('some-pass');
36
37
        $pool = Mockery::mock(Pool::class);
38
39
        $pool->shouldReceive('add')
40
             ->with(
41
                 Mockery::type(Process::class),
42
                 ['dump', 'schema' => 'some-schema', 'table' => 'some-table']
43
             );
44
45
        $tableDumper = new MysqlTableDumper($pool, $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\Mysql\...leDumper::__construct(). ( Ignorable by Annotation )

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

45
        $tableDumper = new MysqlTableDumper($pool, /** @scrutinizer ignore-type */ $config);
Loading history...
Bug introduced by
$pool of type Mockery\MockInterface is incompatible with the type Graze\ParallelProcess\Pool expected by parameter $pool of Graze\Sprout\Dump\Mysql\...leDumper::__construct(). ( Ignorable by Annotation )

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

45
        $tableDumper = new MysqlTableDumper(/** @scrutinizer ignore-type */ $pool, $config);
Loading history...
46
47
        $tableDumper->dump('some-schema', 'some-table', 'some-file');
48
    }
49
}
50