Skip to content
Open
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
22 changes: 13 additions & 9 deletions tests/Acceptance/App/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@

use Google\Protobuf\Timestamp;
use PHPUnit\Framework\SkippedTest;
use PHPUnit\Framework\SkippedWithMessageException;
use PHPUnit\Framework\TestStatus\Skipped;
use Psr\Log\LoggerInterface;
use Spiral\Core\Container;
use Spiral\Core\Scope;
Expand Down Expand Up @@ -36,16 +34,16 @@ protected function setUp(): void

protected function runTest(): mixed
{
$c = ContainerFacade::$container;
$container = ContainerFacade::$container;
/** @var State $runtime */
$runtime = $c->get(State::class);
$runtime = $container->get(State::class);
$feature = $runtime->getFeatureByTestCase(static::class);

// Configure client logger
$logger = LoggerFactory::createClientLogger($feature->taskQueue);
$logger->clear();

return $c->runScope(
return $container->runScope(
new Scope(name: 'feature', bindings: [
Feature::class => $feature,
static::class => $this,
Expand All @@ -62,7 +60,15 @@ function (Container $container): mixed {
return parent::runTest();
} catch (\Throwable $e) {
if ($e instanceof TemporalException) {
echo "\n=== Workflow history for failed test {$this->name()} ===\n";
echo \sprintf(
"\n=== En error occurred while testing %s: %s (%s) ===\n",
static::class . '::' . $this->name(),
$e->getMessage(),
$e::class,
);
echo "\n=== Stack trace ===\n";
echo $e->getTraceAsString();
echo "\n=== Workflow history ===\n";
$this->printWorkflowHistory($container->get(WorkflowClientInterface::class), $args);

$logRecords = $container->get(ClientLogger::class)->getRecords();
Expand Down Expand Up @@ -117,9 +123,7 @@ private function printWorkflowHistory(WorkflowClientInterface $workflowClient, a
? 0
: $ts->getSeconds() + \round($ts->getNanos() / 1_000_000_000, 6);

foreach ($workflowClient->getWorkflowHistory(
$arg->getExecution(),
) as $event) {
foreach ($workflowClient->getWorkflowHistory($arg->getExecution()) as $event) {
$start ??= $fnTime($event->getEventTime());
echo "\n" . \str_pad((string) $event->getEventId(), 3, ' ', STR_PAD_LEFT) . ' ';
# Calculate delta time
Expand Down
Loading