Skip to content

Commit

Permalink
Create method to setup a integration with shopify for test
Browse files Browse the repository at this point in the history
  • Loading branch information
arfenis committed Sep 13, 2024
1 parent 90d8c28 commit 5bd4e8a
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions tests/Connectors/Traits/HasShopifyConfiguration.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,17 @@
namespace Tests\Connectors\Traits;

use Exception;
use Kanvas\Apps\Models\Apps;
use Kanvas\Connectors\Shopify\DataTransferObject\Shopify;
use Kanvas\Connectors\Shopify\Services\ShopifyConfigurationService;
use Kanvas\Inventory\Products\Models\Products;
use Kanvas\Inventory\Regions\Models\Regions;
use Kanvas\Inventory\Warehouses\Models\Warehouses;
use Kanvas\Workflow\Enums\StatusEnum;
use Kanvas\Workflow\Integrations\Actions\CreateIntegrationCompanyAction;
use Kanvas\Workflow\Integrations\DataTransferObject\IntegrationsCompany;
use Kanvas\Workflow\Integrations\Models\Status;
use Kanvas\Workflow\Models\Integrations;

trait HasShopifyConfiguration
{
Expand All @@ -28,4 +34,29 @@ public function setupShopifyConfiguration(Products $product, Warehouses $warehou
getenv('TEST_SHOPIFY_SHOP_URL')
));
}

public function setupShopifyIntegration(Products $product, Regions $region)
{
$credentials = [
'client_id' => getenv('TEST_SHOPIFY_API_KEY'),
'client_secret' => getenv('TEST_SHOPIFY_API_SECRET'),
'shop_url' => getenv('TEST_SHOPIFY_SHOP_URL'),
];

$integration = Integrations::where('name', 'kanvas')->firstOrFail();

$integrationDto = new IntegrationsCompany(
integration: $integration,
region: $region,
company: $product->company,
config: $credentials,
app: app(Apps::class)
);

$status = Status::where('slug', StatusEnum::ACTIVE->value)
->where('apps_id', 0)
->first();

(new CreateIntegrationCompanyAction($integrationDto, auth()->user(), $status))->execute();
}
}

0 comments on commit 5bd4e8a

Please sign in to comment.