|
1
|
|
|
<?php |
|
2
|
|
|
/* |
|
3
|
|
|
* @author Tom Klingenberg <https://github.com/ktomk> |
|
4
|
|
|
*/ |
|
5
|
|
|
|
|
6
|
|
|
namespace N98\Magento\Command\Database; |
|
7
|
|
|
|
|
8
|
|
|
use N98\Magento\Command\Database\Compressor\AbstractCompressor; |
|
9
|
|
|
use N98\Magento\Command\Database\Compressor\Uncompressed; |
|
10
|
|
|
|
|
11
|
|
|
/** |
|
12
|
|
|
* Class ExecsTest |
|
13
|
|
|
* |
|
14
|
|
|
* @covers N98\Magento\Command\Database\Execs |
|
15
|
|
|
* @package N98\Magento\Command\Database |
|
16
|
|
|
*/ |
|
17
|
|
|
class ExecsTest extends \PHPUnit_Framework_TestCase |
|
18
|
|
|
{ |
|
19
|
|
|
/** |
|
20
|
|
|
* @test |
|
21
|
|
|
*/ |
|
22
|
|
|
public function creation() |
|
23
|
|
|
{ |
|
24
|
|
|
$execs = new Execs(); |
|
25
|
|
|
$this->assertInstanceOf(Execs::class, $execs); |
|
26
|
|
|
} |
|
27
|
|
|
|
|
28
|
|
|
/** |
|
29
|
|
|
* @test |
|
30
|
|
|
*/ |
|
31
|
|
|
public function facade() |
|
32
|
|
|
{ |
|
33
|
|
|
$execs = new Execs('foo'); |
|
34
|
|
|
$this->assertInstanceOf(Uncompressed::class, $execs->getCompressor()); |
|
35
|
|
|
$execs->setCompression('gzip'); |
|
36
|
|
|
$this->assertInstanceOf(AbstractCompressor::class, $execs->getCompressor()); |
|
37
|
|
|
$this->assertNull($execs->getFileName()); |
|
38
|
|
|
$execs->setFileName('output.sql'); |
|
39
|
|
|
$this->assertNotNull($execs->getFileName()); |
|
40
|
|
|
$this->assertSame('output.sql', $execs->getFileName()); |
|
41
|
|
|
$this->assertSame('foo | gzip -c > \'output.sql\'', $execs->getBaseCommand()); |
|
42
|
|
|
$execs->addOptions(' --bar=box --flux '); |
|
43
|
|
|
$this->assertSame('foo --bar=box --flux | gzip -c > \'output.sql\'', $execs->getBaseCommand()); |
|
44
|
|
|
$this->assertCount(1, $execs->getCommands()); |
|
45
|
|
|
$this->assertEquals( |
|
46
|
|
|
['foo --bar=box --flux | gzip -c > \'output.sql\''], |
|
47
|
|
|
$execs->getCommands() |
|
48
|
|
|
); |
|
49
|
|
|
$execs->add('--muxbux'); |
|
50
|
|
|
$execs->add('--maxbax'); |
|
51
|
|
|
$this->assertCount(2, $execs->getCommands()); |
|
52
|
|
|
$this->assertEquals( |
|
53
|
|
|
[ |
|
54
|
|
|
'foo --bar=box --flux --muxbux | gzip -c > \'output.sql\'', |
|
55
|
|
|
'foo --bar=box --flux --maxbax | gzip -c >> \'output.sql\'', |
|
56
|
|
|
], |
|
57
|
|
|
$execs->getCommands() |
|
58
|
|
|
); |
|
59
|
|
|
} |
|
60
|
|
|
} |
|
61
|
|
|
|