Skip to content

Commit

Permalink
Merge pull request #46 from kastahov/feature/prototype-bootloader
Browse files Browse the repository at this point in the history
Add prototyping
  • Loading branch information
butschster committed Nov 8, 2022
2 parents 5b7c2a4 + 0bf84f3 commit dd29cdb
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 0 deletions.
23 changes: 23 additions & 0 deletions src/Bootloader/PrototypeBootloader.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?php

declare(strict_types=1);

namespace Spiral\TemporalBridge\Bootloader;

use Spiral\Boot\Bootloader\Bootloader;
use Spiral\Prototype\Bootloader\PrototypeBootloader as BasePrototypeBootloader;
use Spiral\TemporalBridge\WorkflowManagerInterface;
use Temporal\Client\WorkflowClientInterface;

class PrototypeBootloader extends Bootloader
{
protected const DEPENDENCIES = [
BasePrototypeBootloader::class,
];

public function boot(BasePrototypeBootloader $prototype): void
{
$prototype->bindProperty('workflow', WorkflowClientInterface::class);
$prototype->bindProperty('workflowManager', WorkflowManagerInterface::class);
}
}
30 changes: 30 additions & 0 deletions tests/src/Bootloader/PrototypeBootloaderTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?php

declare(strict_types=1);

namespace Spiral\TemporalBridge\Tests\Bootloader;

use Spiral\Prototype\PrototypeRegistry;
use Spiral\TemporalBridge\Tests\TestCase;
use Spiral\TemporalBridge\WorkflowManagerInterface;
use Temporal\Client\WorkflowClientInterface;

class PrototypeBootloaderTest extends TestCase
{
/** @dataProvider propertiesDataProvider */
public function testBindProperties(string $expected, string $property): void
{
$registry = $this->getContainer()->get(PrototypeRegistry::class);

$this->assertInstanceOf(
$expected,
$this->getContainer()->get($registry->resolveProperty($property)->type->name())
);
}

public function propertiesDataProvider(): \Traversable
{
yield [WorkflowClientInterface::class, 'workflow'];
yield [WorkflowManagerInterface::class, 'workflowManager'];
}
}
1 change: 1 addition & 0 deletions tests/src/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ public function defineBootloaders(): array
\Spiral\Boot\Bootloader\ConfigurationBootloader::class,
\Spiral\Bootloader\Attributes\AttributesBootloader::class,
\Spiral\TemporalBridge\Bootloader\TemporalBridgeBootloader::class,
\Spiral\TemporalBridge\Bootloader\PrototypeBootloader::class,
// ...
];
}
Expand Down

0 comments on commit dd29cdb

Please sign in to comment.