|
| 1 | +<?php declare(strict_types=1); |
| 2 | + |
| 3 | +namespace de\codenamephp\deployer\flow\test\task\node; |
| 4 | + |
| 5 | +use de\codenamephp\deployer\command\runner\iRunner; |
| 6 | +use de\codenamephp\deployer\command\runner\WithDeployerFunctions; |
| 7 | +use de\codenamephp\deployer\flow\command\factory\iFlowCommandFactory; |
| 8 | +use de\codenamephp\deployer\flow\command\factory\WithBinaryFromDeployer; |
| 9 | +use de\codenamephp\deployer\flow\task\node\Repair; |
| 10 | +use PHPUnit\Framework\TestCase; |
| 11 | + |
| 12 | +final class RepairTest extends TestCase { |
| 13 | + |
| 14 | + private Repair $sut; |
| 15 | + |
| 16 | + protected function setUp() : void { |
| 17 | + parent::setUp(); |
| 18 | + |
| 19 | + $this->sut = new Repair(); |
| 20 | + } |
| 21 | + |
| 22 | + public function testGetArguments() : void { |
| 23 | + self::assertEquals([], $this->sut->getArguments()); |
| 24 | + } |
| 25 | + |
| 26 | + public function testGetArguments_withNonDefaultValues() : void { |
| 27 | + $this->sut->nodeType = 'some node type'; |
| 28 | + $this->sut->workspace = 'some workspace'; |
| 29 | + $this->sut->dryRun = true; |
| 30 | + $this->sut->skipCleanup = true; |
| 31 | + $this->sut->skipChecks = ['check1', 'check2']; |
| 32 | + $this->sut->onlyChecks = ['check3', 'check4']; |
| 33 | + |
| 34 | + self::assertEquals([ |
| 35 | + '--node-type some node type', |
| 36 | + '--workspace some workspace', |
| 37 | + '--dry-run', |
| 38 | + '--cleanup', |
| 39 | + '--skip check1,check2', |
| 40 | + '--only check3,check4', |
| 41 | + ], $this->sut->getArguments()); |
| 42 | + } |
| 43 | + |
| 44 | + public function testGetCommand() : void { |
| 45 | + self::assertEquals('node:repair', $this->sut->getCommand()); |
| 46 | + } |
| 47 | + |
| 48 | + public function testGetName() : void { |
| 49 | + self::assertEquals(Repair::NAME, $this->sut->getName()); |
| 50 | + } |
| 51 | + |
| 52 | + public function test__construct() : void { |
| 53 | + $this->sut = new Repair(); |
| 54 | + |
| 55 | + self::assertSame('', $this->sut->nodeType); |
| 56 | + self::assertSame('', $this->sut->workspace); |
| 57 | + self::assertFalse($this->sut->dryRun); |
| 58 | + self::assertFalse($this->sut->skipCleanup); |
| 59 | + self::assertSame([], $this->sut->skipChecks); |
| 60 | + self::assertSame([], $this->sut->onlyChecks); |
| 61 | + self::assertInstanceOf(WithBinaryFromDeployer::class, $this->sut->commandFactory); |
| 62 | + self::assertInstanceOf(WithDeployerFunctions::class, $this->sut->commandRunner); |
| 63 | + } |
| 64 | + |
| 65 | + public function test__construct_withoutOptionalArguments() : void { |
| 66 | + $commandFactory = $this->createMock(iFlowCommandFactory::class); |
| 67 | + $commandRunner = $this->createMock(iRunner::class); |
| 68 | + |
| 69 | + $this->sut = new Repair('some node type', 'some workspace', true, true, ['check1', 'check2'], ['check3', 'check4'], $commandFactory, $commandRunner); |
| 70 | + |
| 71 | + self::assertSame('some node type', $this->sut->nodeType); |
| 72 | + self::assertSame('some workspace', $this->sut->workspace); |
| 73 | + self::assertTrue($this->sut->dryRun); |
| 74 | + self::assertTrue($this->sut->skipCleanup); |
| 75 | + self::assertSame(['check1', 'check2'], $this->sut->skipChecks); |
| 76 | + self::assertSame(['check3', 'check4'], $this->sut->onlyChecks); |
| 77 | + self::assertSame($commandFactory, $this->sut->commandFactory); |
| 78 | + self::assertSame($commandRunner, $this->sut->commandRunner); |
| 79 | + } |
| 80 | + |
| 81 | + public function testGetDescription() : void { |
| 82 | + self::assertSame('Repair inconsistent nodes', $this->sut->getDescription()); |
| 83 | + } |
| 84 | +} |
0 commit comments