Skip to content

Commit cd3b490

Browse files
Merge pull request #10
Updated CI tools
2 parents 2947974 + 3c631cd commit cd3b490

16 files changed

Lines changed: 45352 additions & 50514 deletions

.idea/deployer.base.iml

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/php.xml

Lines changed: 3 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

composer.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
"symfony/console": "^6.1"
1616
},
1717
"require-dev": {
18+
"mockery/mockery": "^1.5",
1819
"roave/security-advisories": "dev-latest"
1920
},
2021
"autoload": {

phive.xml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@
1515
~ limitations under the License.
1616
-->
1717
<phive xmlns="https://phar.io/phive">
18-
<phar name="phpunit" version="^9.5" installed="9.5.27" location="./tools/phpunit.phar" copy="true"/>
19-
<phar name="psalm" version="^5.0" installed="5.2.0" location="./tools/psalm" copy="true"/>
20-
<phar name="composer-unused" version="^0.8" installed="0.8.5" location="./tools/composer-unused.phar" copy="true"/>
21-
<phar name="composer-require-checker" version="^4.1.0" installed="4.3.0" location="./tools/composer-require-checker" copy="true"/>
22-
<phar name="infection" version="^0.26" installed="0.26.16" location="./tools/infection" copy="true"/>
18+
<phar name="phpunit" version="^10.0" installed="10.0.15" location="./tools/phpunit.phar" copy="true"/>
19+
<phar name="psalm" version="^5.0" installed="5.8.0" location="./tools/psalm" copy="true"/>
20+
<phar name="composer-unused" version="^0.8" installed="0.8.6" location="./tools/composer-unused.phar" copy="true"/>
21+
<phar name="composer-require-checker" version="^4.0" installed="4.5.0" location="./tools/composer-require-checker" copy="true"/>
22+
<phar name="infection" version="^0.26" installed="0.26.19" location="./tools/infection" copy="true"/>
2323
</phive>

src/functions/All.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ public function host(string ...$hostname) : Host|array {
7272
/**
7373
* We need to hack a little since ObjectProxy doesn't expose the contained objects
7474
*
75-
* @psalm-suppress PossiblyInvalidFunctionCall,InaccessibleProperty
75+
* @psalm-suppress PossiblyInvalidFunctionCall,InaccessibleProperty,PossiblyNullFunctionCall
7676
*/
7777
$hostOrHosts = array_values(
7878
array_filter(
@@ -113,7 +113,7 @@ public function localhost(string ...$hostname) : Localhost|array {
113113
/**
114114
* We need to hack a little since ObjectProxy doesn't expose the contained objects
115115
*
116-
* @psalm-suppress PossiblyInvalidFunctionCall,InaccessibleProperty
116+
* @psalm-suppress PossiblyInvalidFunctionCall,InaccessibleProperty,PossiblyNullFunctionCall
117117
*/
118118
$localhost = array_values(
119119
array_filter(

test/phpunit.dist.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,10 @@
1616
-->
1717
<phpunit
1818
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
19-
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd"
19+
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.0/phpunit.xsd"
2020
colors="true"
2121
bootstrap="./bootstrap.php"
22+
cacheDirectory="../.cache/phpunit"
2223
>
2324
<coverage>
2425
<include>

test/task/deploy/updateCode/UploadTransferablesTest.php

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,14 @@
2121
use de\codenamephp\deployer\base\functions\iUpload;
2222
use de\codenamephp\deployer\base\task\deploy\updateCode\UploadTransferables;
2323
use de\codenamephp\deployer\base\transferable\iTransferable;
24+
use Mockery;
25+
use Mockery\Adapter\Phpunit\MockeryPHPUnitIntegration;
2426
use PHPUnit\Framework\TestCase;
2527

2628
final class UploadTransferablesTest extends TestCase {
2729

30+
use MockeryPHPUnitIntegration;
31+
2832
private UploadTransferables $sut;
2933

3034
protected function setUp() : void {
@@ -35,15 +39,10 @@ protected function setUp() : void {
3539
}
3640

3741
public function test__invoke() : void {
38-
$this->sut->deployerFunctions = $this->createMock(iUpload::class);
39-
$this->sut->deployerFunctions
40-
->expects(self::exactly(3))
41-
->method('upload')
42-
->withConsecutive(
43-
['local path 1', 'remote path 1', ['config 1']],
44-
['local path 2', 'remote path 2', ['config 2']],
45-
['local path 3', 'remote path 3', ['config 3']],
46-
);
42+
$this->sut->deployerFunctions = Mockery::mock(iUpload::class);
43+
$this->sut->deployerFunctions->allows('upload')->with('local path 1', 'remote path 1', ['config 1'])->once()->ordered();
44+
$this->sut->deployerFunctions->allows('upload')->with('local path 2', 'remote path 2', ['config 2'])->once()->ordered();
45+
$this->sut->deployerFunctions->allows('upload')->with('local path 3', 'remote path 3', ['config 3'])->once()->ordered();
4746

4847
$transferable1 = $this->createMock(iTransferable::class);
4948
$transferable1->expects(self::once())->method('getLocalPath')->willReturn('local path 1');

test/task/media/CopyTest.php

Lines changed: 13 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,13 @@
2424
use de\codenamephp\deployer\base\task\media\Copy;
2525
use de\codenamephp\deployer\base\transferable\iTransferable;
2626
use Deployer\Host\Host;
27+
use Mockery\Adapter\Phpunit\MockeryPHPUnitIntegration;
2728
use PHPUnit\Framework\TestCase;
2829

2930
final class CopyTest extends TestCase {
3031

32+
use MockeryPHPUnitIntegration;
33+
3134
private Copy $sut;
3235

3336
protected function setUp() : void {
@@ -83,27 +86,16 @@ public function test__invoke() : void {
8386
$transferable2->expects(self::once())->method('getConfig')->willReturn(['options' => ['options2_1', 'options2_2']]);
8487
$this->sut->setTransferables($transferable1, $transferable2);
8588

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"');
10799
$this->sut->deployerFunctions = $deployerFunctions;
108100

109101
$this->sut->__invoke();

test/task/media/PullTest.php

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,13 @@
2121
use de\codenamephp\deployer\base\functions\iDownload;
2222
use de\codenamephp\deployer\base\task\media\Pull;
2323
use de\codenamephp\deployer\base\transferable\iTransferable;
24+
use Mockery\Adapter\Phpunit\MockeryPHPUnitIntegration;
2425
use PHPUnit\Framework\TestCase;
2526

2627
final class PullTest extends TestCase {
2728

29+
use MockeryPHPUnitIntegration;
30+
2831
private Pull $sut;
2932

3033
protected function setUp() : void {
@@ -60,15 +63,10 @@ public function test__invoke() : void {
6063
$this->createConfiguredMock(iTransferable::class, ['getLocalPath' => 'local3', 'getRemotePath' => 'remote3', 'getConfig' => ['config3']]),
6164
);
6265

63-
$this->sut->deployerFunctions = $this->createMock(iDownload::class);
64-
$this->sut->deployerFunctions
65-
->expects(self::exactly(3))
66-
->method('download')
67-
->withConsecutive(
68-
['remote1', 'local1', ['config1']],
69-
['remote2', 'local2', ['config2']],
70-
['remote3', 'local3', ['config3']],
71-
);
66+
$this->sut->deployerFunctions = \Mockery::mock(iDownload::class);
67+
$this->sut->deployerFunctions->allows('download')->once()->ordered()->with('remote1', 'local1', ['config1']);
68+
$this->sut->deployerFunctions->allows('download')->once()->ordered()->with('remote2', 'local2', ['config2']);
69+
$this->sut->deployerFunctions->allows('download')->once()->ordered()->with('remote3', 'local3', ['config3']);
7270

7371
$this->sut->__invoke();
7472
}

test/task/media/PushTest.php

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,14 @@
2121
use de\codenamephp\deployer\base\hostCheck\iHostCheck;
2222
use de\codenamephp\deployer\base\task\media\Push;
2323
use de\codenamephp\deployer\base\transferable\iTransferable;
24+
use Mockery;
25+
use Mockery\Adapter\Phpunit\MockeryPHPUnitIntegration;
2426
use PHPUnit\Framework\TestCase;
2527

2628
final class PushTest extends TestCase {
2729

30+
use MockeryPHPUnitIntegration;
31+
2832
private Push $sut;
2933

3034
protected function setUp() : void {
@@ -59,15 +63,10 @@ public function test__invoke() : void {
5963
$this->sut->hostCheck = $this->createMock(iHostCheck::class);
6064
$this->sut->hostCheck->expects(self::once())->method('check');
6165

62-
$this->sut->deployerFunctions = $this->createMock(iUpload::class);
63-
$this->sut->deployerFunctions
64-
->expects(self::exactly(3))
65-
->method('upload')
66-
->withConsecutive(
67-
['local1', 'remote1', ['config1']],
68-
['local2', 'remote2', ['config2']],
69-
['local3', 'remote3', ['config3']],
70-
);
66+
$this->sut->deployerFunctions = Mockery::mock(iUpload::class);
67+
$this->sut->deployerFunctions->allows('upload')->once()->ordered()->with('local1', 'remote1', ['config1']);
68+
$this->sut->deployerFunctions->allows('upload')->once()->ordered()->with('local2', 'remote2', ['config2']);
69+
$this->sut->deployerFunctions->allows('upload')->once()->ordered()->with('local3', 'remote3', ['config3']);
7170

7271
$this->sut->__invoke();
7372
}

0 commit comments

Comments
 (0)