|
| 1 | +<?php declare(strict_types=1); |
| 2 | + |
| 3 | +namespace de\codenamephp\deployer\crontab\test\Task; |
| 4 | + |
| 5 | +use de\codenamephp\deployer\command\runner\iRunner; |
| 6 | +use de\codenamephp\deployer\command\runner\WithDeployerFunctions; |
| 7 | +use de\codenamephp\deployer\crontab\Command\CrontabCommandFactoryInterface; |
| 8 | +use de\codenamephp\deployer\crontab\Command\WithBinaryFromDeployer; |
| 9 | +use de\codenamephp\deployer\crontab\Task\Install; |
| 10 | +use PHPUnit\Framework\TestCase; |
| 11 | + |
| 12 | +final class InstallTest extends TestCase { |
| 13 | + |
| 14 | + public function testGetName() : void { |
| 15 | + self::assertSame(Install::NAME, (new Install())->getName()); |
| 16 | + } |
| 17 | + |
| 18 | + public function testGetOptions() : void { |
| 19 | + self::assertSame(['some file'], (new Install('some file'))->getOptions()); |
| 20 | + } |
| 21 | + |
| 22 | + public function testGetDescription() : void { |
| 23 | + self::assertSame('Installs the given crontab file.', (new Install())->getDescription()); |
| 24 | + } |
| 25 | + |
| 26 | + public function test__construct() : void { |
| 27 | + $sut = new Install(); |
| 28 | + |
| 29 | + self::assertSame('{{release_or_current_path}}/crontab', $sut->file); |
| 30 | + self::assertNull($sut->user); |
| 31 | + self::assertInstanceOf(WithBinaryFromDeployer::class, $sut->crontabCommandFactory); |
| 32 | + self::assertInstanceOf(WithDeployerFunctions::class, $sut->commandRunner); |
| 33 | + } |
| 34 | + public function test__construct_WithOptionalArguments() : void { |
| 35 | + $commandFactory = $this->createMock(CrontabCommandFactoryInterface::class); |
| 36 | + $commandRunner = $this->createMock(iRunner::class); |
| 37 | + |
| 38 | + $sut = new Install('some file', 'some user', $commandFactory, $commandRunner); |
| 39 | + |
| 40 | + self::assertSame('some file', $sut->file); |
| 41 | + self::assertSame('some user', $sut->user); |
| 42 | + self::assertSame($commandFactory, $sut->crontabCommandFactory); |
| 43 | + self::assertSame($commandRunner, $sut->commandRunner); |
| 44 | + } |
| 45 | +} |
0 commit comments