Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ If any constraint of config definition is not met a `UserException` is thrown. T

## Migration from version 6 to version 7

The default entrypoint of component (in `index.php`) changed from `BaseComponent::run()` to `BaseComponent::execute()`. While running the component via `run` method is still supported, you need to use `execute()` if you want to take advantage of sync action support.
The default entrypoint of component (in `index.php`) changed from `BaseComponent::run()` to `BaseComponent::execute()`. Please also note, that the `run` method can no longer be public and can only be called from inside the component now.

## More reading

Expand Down
2 changes: 1 addition & 1 deletion src/Config/BaseConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ public function getAuthorization(): array
*/
public function getAction(): string
{
return $this->getValue(['action'], '');
return $this->getValue(['action'], 'run');
}

/**
Expand Down
23 changes: 23 additions & 0 deletions tests/BaseComponentTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,29 @@ protected function run(): void
$this->assertTrue($handler->hasAlert('Log message from run'));
}

public function testWillNotFailWithEmptyConfigAction(): void
{
$logger = $this->getLogger();
$handler = new TestHandler();
$logger->setHandlers([$handler]);
putenv(sprintf(
'KBC_DATADIR=%s',
__DIR__ . '/fixtures/base-component-data-dir/empty-config-file'
));
$baseComponent = new class ($logger) extends BaseComponent
{
protected function run(): void
{
echo 'Shitty output';
$this->getLogger()->alert('Log message from run');
}
};
$this->expectOutputString('Shitty output');
$baseComponent->execute();

$this->assertTrue($handler->hasAlert('Log message from run'));
}

public function testLoadInputStateFileEmptyThrowsException(): void
{
putenv(sprintf(
Expand Down
2 changes: 1 addition & 1 deletion tests/Config/BaseConfigTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ public function testGettersWillNotFailIfKeyIsMissing(): void
],
]);
$this->assertSame([], $config->getParameters());
$this->assertSame('', $config->getAction());
$this->assertSame('run', $config->getAction());
$this->assertSame([], $config->getAuthorization());
$this->assertSame('', $config->getOAuthApiAppKey());
$this->assertSame('', $config->getOAuthApiAppSecret());
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
{
}