|
| 1 | +<?php declare(strict_types=1); |
| 2 | +/* |
| 3 | + * Copyright 2023 Bastian Schwarz <[email protected]>. |
| 4 | + * |
| 5 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 | + * you may not use this file except in compliance with the License. |
| 7 | + * You may obtain a copy of the License at |
| 8 | + * |
| 9 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | + * |
| 11 | + * Unless required by applicable law or agreed to in writing, software |
| 12 | + * distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | + * See the License for the specific language governing permissions and |
| 15 | + * limitations under the License. |
| 16 | + */ |
| 17 | + |
| 18 | +namespace de\codenamephp\deployer\base\test\task\deploy\releaseInfo\Revision; |
| 19 | + |
| 20 | +use de\codenamephp\deployer\base\functions\All; |
| 21 | +use de\codenamephp\deployer\base\functions\iRun; |
| 22 | +use de\codenamephp\deployer\base\task\deploy\releaseInfo\Revision\FromConfig; |
| 23 | +use PHPUnit\Framework\TestCase; |
| 24 | + |
| 25 | +final class FromConfigTest extends TestCase { |
| 26 | + |
| 27 | + public function test__invoke() : void { |
| 28 | + $run = $this->createMock(iRun::class); |
| 29 | + $run->expects(self::once())->method('run')->with("echo '{{some key}}' > 'some path'"); |
| 30 | + |
| 31 | + $sut = new FromConfig('some key', 'some path', $run); |
| 32 | + |
| 33 | + $sut(); |
| 34 | + } |
| 35 | + |
| 36 | + public function testGetDescription() : void { |
| 37 | + self::assertSame("Creates a revision file from a config value that can be used to identify the release, e.g. in a sentry client. Set the value with -o releaseInfo.revision='your revision' on the command line or in the config file.", (new FromConfig())->getDescription()); |
| 38 | + } |
| 39 | + |
| 40 | + public function test__construct() : void { |
| 41 | + $sut = new FromConfig(); |
| 42 | + |
| 43 | + self::assertSame('releaseInfo.revision', $sut->configKey); |
| 44 | + self::assertSame('{{release_or_current_path}}/REVISION', $sut->revisionFile); |
| 45 | + self::assertInstanceOf(All::class, $sut->run); |
| 46 | + } |
| 47 | + |
| 48 | + public function test__construct_withOptionalArguments() : void { |
| 49 | + $run = $this->createMock(iRun::class); |
| 50 | + |
| 51 | + $sut = new FromConfig('some key', 'some path', $run); |
| 52 | + |
| 53 | + self::assertSame('some key', $sut->configKey); |
| 54 | + self::assertSame('some path', $sut->revisionFile); |
| 55 | + self::assertSame($run, $sut->run); |
| 56 | + } |
| 57 | + |
| 58 | + public function testGetName() : void { |
| 59 | + self::assertSame(FromConfig::NAME, (new FromConfig())->getName()); |
| 60 | + } |
| 61 | +} |
0 commit comments