|
| 1 | +<?php |
| 2 | + |
| 3 | +declare(strict_types=1); |
| 4 | + |
| 5 | +namespace DrevOps\Vortex\Tests\Functional; |
| 6 | + |
| 7 | +use AlexSkrypnyk\File\File; |
| 8 | + |
| 9 | +/** |
| 10 | + * Tests workflow utilities. |
| 11 | + */ |
| 12 | +class WorkflowUtilitiesTest extends FunctionalTestCase { |
| 13 | + |
| 14 | + protected function setUp(): void { |
| 15 | + static::logSection('TEST START | ' . $this->name(), double_border: TRUE); |
| 16 | + |
| 17 | + parent::setUp(); |
| 18 | + |
| 19 | + chdir(static::$sut); |
| 20 | + |
| 21 | + $this->stepPrepareSut(); |
| 22 | + } |
| 23 | + |
| 24 | + protected function tearDown(): void { |
| 25 | + parent::tearDown(); |
| 26 | + |
| 27 | + static::logSection('TEST DONE | ' . $this->name(), double_border: TRUE); |
| 28 | + } |
| 29 | + |
| 30 | + /** |
| 31 | + * Test local Ahoy commands functionality. |
| 32 | + */ |
| 33 | + public function testLocalAhoyCommands(): void { |
| 34 | + $this->logSubstep('Assert calling local commands without local file does not throw error'); |
| 35 | + $this->processRun('ahoy --version'); |
| 36 | + $this->assertProcessSuccessful(); |
| 37 | + $this->assertProcessOutputNotContains('[fatal]'); |
| 38 | + |
| 39 | + $this->logSubstep('Assert calling local commands with local file path specified and file is present works correctly'); |
| 40 | + File::copy('.ahoy.local.example.yml', '.ahoy.local.yml'); |
| 41 | + $this->processRun('ahoy local help'); |
| 42 | + $this->assertProcessSuccessful(); |
| 43 | + $this->assertProcessOutputContains('Custom local commands'); |
| 44 | + $this->assertProcessOutputNotContains('[fatal]'); |
| 45 | + |
| 46 | + $this->logSubstep('Assert calling local commands with local file path specified and file is present and file return non-zero exit code'); |
| 47 | + $local_command_content = <<<YAML |
| 48 | +
|
| 49 | + mylocalcommand: |
| 50 | + cmd: | |
| 51 | + echo 'expected failure' |
| 52 | + exit 1 |
| 53 | +YAML; |
| 54 | + $existing_content = File::read('.ahoy.local.yml'); |
| 55 | + $this->assertNotEmpty($existing_content, 'Failed to read .ahoy.local.yml'); |
| 56 | + |
| 57 | + File::dump('.ahoy.local.yml', $existing_content . $local_command_content); |
| 58 | + |
| 59 | + $this->processRun('ahoy local mylocalcommand'); |
| 60 | + $this->assertProcessFailed(); |
| 61 | + $this->assertProcessOutputContains('expected failure'); |
| 62 | + $this->assertProcessOutputNotContains('[fatal]'); |
| 63 | + } |
| 64 | + |
| 65 | + /** |
| 66 | + * Test doctor info command. |
| 67 | + */ |
| 68 | + public function testDoctorInfo(): void { |
| 69 | + $this->logSubstep('Run ahoy doctor info'); |
| 70 | + $this->processRun('ahoy doctor info'); |
| 71 | + $this->assertProcessSuccessful(); |
| 72 | + $this->assertProcessOutputContains('System information report'); |
| 73 | + $this->assertProcessOutputContains('OPERATING SYSTEM'); |
| 74 | + $this->assertProcessOutputContains('DOCKER'); |
| 75 | + $this->assertProcessOutputContains('DOCKER COMPOSE'); |
| 76 | + $this->assertProcessOutputContains('PYGMY'); |
| 77 | + $this->assertProcessOutputContains('AHOY'); |
| 78 | + } |
| 79 | + |
| 80 | +} |
0 commit comments