Skip to content
Open
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
17 changes: 13 additions & 4 deletions src/Cloud/Pipeline.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,20 @@ public static function fromLegacyConfiguration(array $configuration): DTO\Pipeli
$code = $stepConfig['code'] ?? sprintf('step%d', $order);
unset($stepConfig['name'], $stepConfig['code']);

array_walk_recursive($stepConfig, function (&$value): void {
if ($value instanceof Expression) {
$value = '@='.$value;
array_walk_recursive(
$stepConfig,
function (&$value, $key) {
if ($value instanceof Expression && $key === 'expression') {
$value = (string) $value;
}

if ($value instanceof Expression) {
$value = '@=' . $value;
}

return $value;
}
});
);

return new DTO\Step(
$name,
Expand Down
34 changes: 26 additions & 8 deletions src/Cloud/Workflow.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,20 @@ function (array $config, int $order) {
$code = $config['pipeline']['code'] ?? sprintf('pipeline%d', $order);
unset($config['pipeline']['name'], $config['pipeline']['code']);

array_walk_recursive($config, function (&$value): void {
if ($value instanceof Expression) {
$value = '@='.$value;
array_walk_recursive(
$config,
function (&$value, $key) {
if ($value instanceof Expression && $key === 'expression') {
$value = (string) $value;
}

if ($value instanceof Expression) {
$value = '@=' . $value;
}

return $value;
}
});
);

return new DTO\Workflow\Pipeline(
$name,
Expand All @@ -70,11 +79,20 @@ function (array $config, int $order) {
$code = $config['action']['code'] ?? sprintf('action%d', $order);
unset($config['action']['name'], $config['action']['code']);

array_walk_recursive($config, function (&$value): void {
if ($value instanceof Expression) {
$value = '@='.$value;
array_walk_recursive(
$config,
function (&$value, $key) {
if ($value instanceof Expression && $key === 'expression') {
$value = (string) $value;
}

if ($value instanceof Expression) {
$value = '@=' . $value;
}

return $value;
}
});
);

$configuration = $config['action'];
unset($config['action']);
Expand Down
19 changes: 19 additions & 0 deletions tests/unit/Cloud/Client/GetWorkflowItem.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?php

namespace unit\Kiboko\Component\Satellite\Cloud\CLient;

use Gyroscops;
use Gyroscops\Api\Model\WorkflowRead;

class GetWorkflowItem extends Gyroscops\Api\Client
{
public function getWorkflowItem(string $id, string $fetch = self::FETCH_OBJECT, array $accept = []): WorkflowRead
{
$workflowRead = new WorkflowRead();
$workflowRead->setId($id);
$workflowRead->setLabel('Extract data from Akeneo');
$workflowRead->setCode('from_akeneo');

return $workflowRead;
}
}
14 changes: 14 additions & 0 deletions tests/unit/Cloud/Client/GetWorkflowItemThrowNotFoundException.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?php

namespace unit\Kiboko\Component\Satellite\Cloud\CLient;

use Gyroscops\Api\Client;
use Gyroscops\Api\Exception\GetWorkflowItemNotFoundException;

class GetWorkflowItemThrowNotFoundException extends Client
{
public function getWorkflowItem($id, string $fetch = self::FETCH_OBJECT, array $accept = [])
{
throw new GetWorkflowItemNotFoundException();
}
}
32 changes: 32 additions & 0 deletions tests/unit/Cloud/DummyContext.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?php

declare(strict_types=1);

namespace unit\Kiboko\Component\Satellite\Cloud;

use Kiboko\Component\Satellite\Cloud\ContextInterface;
use Kiboko\Component\Satellite\Cloud\DTO\OrganizationId;
use Kiboko\Component\Satellite\Cloud\DTO\WorkspaceId;

final readonly class DummyContext implements ContextInterface
{
public function changeOrganization(OrganizationId $organization): void
{
// Todo: write this method
}

public function organization(): OrganizationId
{
return new OrganizationId('93af28a3-c7f9-4392-a013-b4ece257ecf5');
}

public function changeWorkspace(WorkspaceId $workspace): void
{
// Todo: write this method
}

public function workspace(): WorkspaceId
{
return new WorkspaceId('eb6ed674-5198-4be2-a8b9-8ef5d5292be4');
}
}
Loading