|
24 | 24 | use de\codenamephp\deployer\base\task\media\Copy; |
25 | 25 | use de\codenamephp\deployer\base\transferable\iTransferable; |
26 | 26 | use Deployer\Host\Host; |
| 27 | +use Mockery\Adapter\Phpunit\MockeryPHPUnitIntegration; |
27 | 28 | use PHPUnit\Framework\TestCase; |
28 | 29 |
|
29 | 30 | final class CopyTest extends TestCase { |
30 | 31 |
|
| 32 | + use MockeryPHPUnitIntegration; |
| 33 | + |
31 | 34 | private Copy $sut; |
32 | 35 |
|
33 | 36 | protected function setUp() : void { |
@@ -83,27 +86,16 @@ public function test__invoke() : void { |
83 | 86 | $transferable2->expects(self::once())->method('getConfig')->willReturn(['options' => ['options2_1', 'options2_2']]); |
84 | 87 | $this->sut->setTransferables($transferable1, $transferable2); |
85 | 88 |
|
86 | | - $deployerFunctions = $this->createMock(iAll::class); |
87 | | - $deployerFunctions->expects(self::once())->method('getOption')->with(Copy::OPTION_SOURCE_HOST)->willReturn(1234); |
88 | | - $deployerFunctions->expects(self::once())->method('firstHost')->with('1234')->willReturn($sourceHost); |
89 | | - $deployerFunctions->expects(self::once())->method('currentHost')->willReturn($targetHost); |
90 | | - $deployerFunctions |
91 | | - ->expects(self::exactly(4)) |
92 | | - ->method('parseOnHost') |
93 | | - ->withConsecutive( |
94 | | - [$sourceHost, 'source_path_1'], |
95 | | - [$targetHost, 'target_path_1'], |
96 | | - [$sourceHost, 'source_path_2'], |
97 | | - [$targetHost, 'target_path_2'], |
98 | | - ) |
99 | | - ->willReturnOnConsecutiveCalls('parsed_source_path_1', 'parsed_target_path_1', 'parsed_source_path_2', 'parsed_target_path_2'); |
100 | | - $deployerFunctions |
101 | | - ->expects(self::exactly(2)) |
102 | | - ->method('runLocally') |
103 | | - ->withConsecutive( |
104 | | - ['ssh source_ssh_arguments source_connection_string "rsync -e \'ssh -o StrictHostKeyChecking=no target_ssh_arguments\' -azP options1_1 options1_2 parsed_source_path_1 target_connection_string:parsed_target_path_1"'], |
105 | | - ['ssh source_ssh_arguments source_connection_string "rsync -e \'ssh -o StrictHostKeyChecking=no target_ssh_arguments\' -azP options2_1 options2_2 parsed_source_path_2 target_connection_string:parsed_target_path_2"'] |
106 | | - ); |
| 89 | + $deployerFunctions = \Mockery::mock(iAll::class); |
| 90 | + $deployerFunctions->allows('getOption')->once()->with(Copy::OPTION_SOURCE_HOST)->andReturn(1234); |
| 91 | + $deployerFunctions->allows('firstHost')->once()->with('1234')->andReturn($sourceHost); |
| 92 | + $deployerFunctions->allows('currentHost')->once()->andReturn($targetHost); |
| 93 | + $deployerFunctions->allows('parseOnHost')->once()->ordered()->with($sourceHost, 'source_path_1')->andReturn('parsed_source_path_1'); |
| 94 | + $deployerFunctions->allows('parseOnHost')->once()->ordered()->with($targetHost, 'target_path_1')->andReturn('parsed_target_path_1'); |
| 95 | + $deployerFunctions->allows('runLocally')->once()->ordered()->with('ssh source_ssh_arguments source_connection_string "rsync -e \'ssh -o StrictHostKeyChecking=no target_ssh_arguments\' -azP options1_1 options1_2 parsed_source_path_1 target_connection_string:parsed_target_path_1"'); |
| 96 | + $deployerFunctions->allows('parseOnHost')->once()->ordered()->with($sourceHost, 'source_path_2')->andReturn('parsed_source_path_2'); |
| 97 | + $deployerFunctions->allows('parseOnHost')->once()->ordered()->with($targetHost, 'target_path_2')->andReturn('parsed_target_path_2'); |
| 98 | + $deployerFunctions->allows('runLocally')->once()->ordered()->with('ssh source_ssh_arguments source_connection_string "rsync -e \'ssh -o StrictHostKeyChecking=no target_ssh_arguments\' -azP options2_1 options2_2 parsed_source_path_2 target_connection_string:parsed_target_path_2"'); |
107 | 99 | $this->sut->deployerFunctions = $deployerFunctions; |
108 | 100 |
|
109 | 101 | $this->sut->__invoke(); |
|
0 commit comments