Skip to content

Commit efc55a4

Browse files
committed
Make "run" default action if missing in config
1 parent 26d67e4 commit efc55a4

File tree

4 files changed

+27
-2
lines changed

4 files changed

+27
-2
lines changed

src/Config/BaseConfig.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ public function getAuthorization(): array
136136
*/
137137
public function getAction(): string
138138
{
139-
return $this->getValue(['action'], '');
139+
return $this->getValue(['action'], 'run');
140140
}
141141

142142
/**

tests/BaseComponentTest.php

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,29 @@ protected function run(): void
102102
$this->assertTrue($handler->hasAlert('Log message from run'));
103103
}
104104

105+
public function testWillNotFailWithEmptyConfigAction(): void
106+
{
107+
$logger = $this->getLogger();
108+
$handler = new TestHandler();
109+
$logger->setHandlers([$handler]);
110+
putenv(sprintf(
111+
'KBC_DATADIR=%s',
112+
__DIR__ . '/fixtures/base-component-data-dir/empty-config-file'
113+
));
114+
$baseComponent = new class ($logger) extends BaseComponent
115+
{
116+
protected function run(): void
117+
{
118+
echo 'Shitty output';
119+
$this->getLogger()->alert('Log message from run');
120+
}
121+
};
122+
$this->expectOutputString('Shitty output');
123+
$baseComponent->execute();
124+
125+
$this->assertTrue($handler->hasAlert('Log message from run'));
126+
}
127+
105128
public function testLoadInputStateFileEmptyThrowsException(): void
106129
{
107130
putenv(sprintf(

tests/Config/BaseConfigTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ public function testGettersWillNotFailIfKeyIsMissing(): void
108108
],
109109
]);
110110
$this->assertSame([], $config->getParameters());
111-
$this->assertSame('', $config->getAction());
111+
$this->assertSame('run', $config->getAction());
112112
$this->assertSame([], $config->getAuthorization());
113113
$this->assertSame('', $config->getOAuthApiAppKey());
114114
$this->assertSame('', $config->getOAuthApiAppSecret());
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
{
2+
}

0 commit comments

Comments
 (0)