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

MysqlTableChopperTest   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 19
dl 0
loc 29
rs 10
c 0
b 0
f 0
wmc 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A testChop() 0 27 1
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\Chop\Mysql;
15
16
use Graze\ParallelProcess\Pool;
17
use Graze\Sprout\Config\ConnectionConfigInterface;
18
use Graze\Sprout\Test\TestCase;
19
use Mockery;
20
use Symfony\Component\Process\Process;
21
22
/**
23
 * @runTestsInSeparateProcesses
24
 * @preserveGlobalState disabled
25
 */
26
class MysqlTableChopperTest extends TestCase
27
{
28
    public function testChop()
29
    {
30
        $process = Mockery::mock('overload:' . Process::class);
31
32
        $process->shouldReceive('setCommandLine')
33
                ->with('mysql -h\'some-host\' -u\'some-user\' -p\'some-pass\' --default-character-set=utf8 --execute=\'TRUNCATE `some-table`\' \'some-schema\'')
34
                ->once();
35
36
        $config = Mockery::mock(ConnectionConfigInterface::class);
37
        $config->shouldReceive('getHost')
38
               ->andReturn('some-host');
39
        $config->shouldReceive('getUser')
40
               ->andReturn('some-user');
41
        $config->shouldReceive('getPassword')
42
               ->andReturn('some-pass');
43
44
        $pool = Mockery::mock(Pool::class);
45
46
        $pool->shouldReceive('add')
47
             ->with(
48
                 Mockery::type(Process::class),
49
                 ['chop', 'schema' => 'some-schema', 'table' => 'some-table']
50
             );
51
52
        $tableChopper = new MysqlTableChopper($pool, $config);
0 ignored issues
show
Bug introduced by
$pool of type Mockery\MockInterface is incompatible with the type Graze\ParallelProcess\Pool expected by parameter $pool of Graze\Sprout\Chop\Mysql\...eChopper::__construct(). ( Ignorable by Annotation )

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

52
        $tableChopper = new MysqlTableChopper(/** @scrutinizer ignore-type */ $pool, $config);
Loading history...
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\Mysql\...eChopper::__construct(). ( Ignorable by Annotation )

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

52
        $tableChopper = new MysqlTableChopper($pool, /** @scrutinizer ignore-type */ $config);
Loading history...
53
54
        $tableChopper->chop('some-schema', 'some-table');
55
    }
56
}
57