Skip to content

Commit

Permalink
Merge 'origin/release/0.10.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
wfajczyk committed Sep 14, 2020
2 parents 3b6cb59 + 0dbb7e0 commit 05c8dd5
Show file tree
Hide file tree
Showing 110 changed files with 3,178 additions and 2,101 deletions.
12 changes: 6 additions & 6 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@
"require": {
"php": "^7.4",
"doctrine/dbal": "^2.10",
"ergonode/api": "^0.9.0",
"ergonode/attribute": "^0.9.0",
"ergonode/core": "^0.9.0",
"ergonode/grid": "^0.9.0",
"ergonode/exporter": "^0.9.0",
"ergonode/shared-kernel": "^0.9.0",
"ergonode/api": "^0.10.0",
"ergonode/attribute": "^0.10.0",
"ergonode/core": "^0.10.0",
"ergonode/grid": "^0.10.0",
"ergonode/exporter": "^0.10.0",
"ergonode/shared-kernel": "^0.10.0",
"jms/serializer": "^3.4",
"nelmio/api-doc-bundle": "^3.6",
"ramsey/uuid": "^3.8",
Expand Down
9 changes: 9 additions & 0 deletions features/channel-privileges.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
Feature: channel module

Scenario: Create channel (not authorized)
When I send a POST request to "/api/v1/en_GB/channels"
Then the response status code should be 401

Scenario: Get channels (not authorized)
When I send a GET request to "/api/v1/en_GB/channels"
Then the response status code should be 401
185 changes: 12 additions & 173 deletions features/channel.feature
Original file line number Diff line number Diff line change
@@ -1,191 +1,30 @@
Feature: channel module
## todo To be checked with the export profile
Scenario: Create channel
Given I am Authenticated as "test@ergonode.com"
And I add "Content-Type" header equal to "application/json"
And I add "Accept" header equal to "application/json"
When I send a POST request to "/api/v1/en/channels" with body:
"""
{
"export_profile_id": "",
"name": "Test pl_PL"
}
"""
Then the response status code should be 400

Scenario: Create channel (not authorized)
When I send a POST request to "/api/v1/en/channels"
Then the response status code should be 401

Scenario: Create channel (no Name)
Given I am Authenticated as "test@ergonode.com"
And I add "Content-Type" header equal to "application/json"
And I add "Accept" header equal to "application/json"
When I send a POST request to "/api/v1/en/channels" with body:
"""
{
"export_profile_id": ""
}
"""
Then the response status code should be 400

Scenario: Create channel (empty Name)
Given I am Authenticated as "test@ergonode.com"
And I add "Content-Type" header equal to "application/json"
And I add "Accept" header equal to "application/json"
When I send a POST request to "/api/v1/en/channels" with body:
"""
{
"export_profile_id": "",
"name": ""
}
"""
Then the response status code should be 400

Scenario: Create channel (name with language with empty string value)
Given I am Authenticated as "test@ergonode.com"
And I add "Content-Type" header equal to "application/json"
And I add "Accept" header equal to "application/json"
When I send a POST request to "/api/v1/en/channels" with body:
"""
{
"name": "Test pl_PL"
}
"""
Then the response status code should be 400

# Scenario: Update channel
# Given I am Authenticated as "test@ergonode.com"
# And I add "Content-Type" header equal to "application/json"
# And I add "Accept" header equal to "application/json"
# When I send a PUT request to "/api/v1/en/channels/@channel@" with body:
# """
# {
# "export_profile_id": "",
# "name": "Test de"
# }
# """
# Then the response status code should be 204
#
# Scenario: Update channel (not authorized)
# When I send a PUT request to "/api/v1/en/channels/@channel@"
# Then the response status code should be 401

Scenario: Update channel (not found)
Given I am Authenticated as "test@ergonode.com"
And I add "Content-Type" header equal to "application/json"
And I add "Accept" header equal to "application/json"
When I send a PUT request to "/api/v1/en/channels/@@static_uuid@@"
Then the response status code should be 404

# Scenario: Update channel (empty name)
# Given I am Authenticated as "test@ergonode.com"
# And I add "Content-Type" header equal to "application/json"
# And I add "Accept" header equal to "application/json"
# When I send a PUT request to "/api/v1/en/channels/@channel@" with body:
# """
# {
# "name": ""
# }
# """
# Then the response status code should be 400
#
# Scenario: Update channel (wrong parameter)
# Given I am Authenticated as "test@ergonode.com"
# And I add "Content-Type" header equal to "application/json"
# And I add "Accept" header equal to "application/json"
# When I send a PUT request to "/api/v1/en/channels/@channel@" with body:
# """
# {
# "test": {
# }
# }
# """
# Then the response status code should be 400

# Scenario: Update channel (empty translation)
# Given I am Authenticated as "test@ergonode.com"
# And I add "Content-Type" header equal to "application/json"
# And I add "Accept" header equal to "application/json"
# When I send a PUT request to "/api/v1/en/channels/@channel@" with body:
# """
# {
# "name": "Test pl_PL (changed)"
# }
# """
# Then the response status code should be 400

# Scenario: Get channel
# Given I am Authenticated as "test@ergonode.com"
# And I add "Content-Type" header equal to "application/json"
# And I add "Accept" header equal to "application/json"
# When I send a GET request to "/api/v1/pl_PL/channels/@channel@"
# Then the response status code should be 200
#
# Scenario: Get channel (not authorized)
# When I send a GET request to "/api/v1/en/channels/@channel@"
# Then the response status code should be 401

Scenario: Get channel (not found)
Background:
Given I am Authenticated as "test@ergonode.com"
And I add "Content-Type" header equal to "application/json"
And I add "Accept" header equal to "application/json"
When I send a GET request to "/api/v1/en/channels/@@static_uuid@@"
Then the response status code should be 404

# Scenario: Delete channel (not authorized)
# When I send a DELETE request to "/api/v1/en/channels/@channel@"
# Then the response status code should be 401

Scenario: Delete channel (not found)
Given I am Authenticated as "test@ergonode.com"
And I add "Content-Type" header equal to "application/json"
And I add "Accept" header equal to "application/json"
When I send a DELETE request to "/api/v1/en/channels/@@static_uuid@@"
Then the response status code should be 404

# Scenario: Delete channel
# Given I am Authenticated as "test@ergonode.com"
# And I add "Content-Type" header equal to "application/json"
# And I add "Accept" header equal to "application/json"
# When I send a DELETE request to "/api/v1/en/channels/@channel@"
# Then the response status code should be 204

Scenario: Get channels (order by name)
Given I am Authenticated as "test@ergonode.com"
And I add "Content-Type" header equal to "application/json"
And I add "Accept" header equal to "application/json"
When I send a GET request to "/api/v1/en/channels?field=name"
Then the JSON should be valid according to the schema "module/grid/features/gridSchema.json"
Scenario: Get channel type dictionary
When I send a GET request to "/api/v1/en_GB/dictionary/channels"
Then the response status code should be 200

Scenario: Get channels (order ASC)
Given I am Authenticated as "test@ergonode.com"
And I add "Content-Type" header equal to "application/json"
And I add "Accept" header equal to "application/json"
When I send a GET request to "/api/v1/en/channels?field=name&order=ASC"
When I send a GET request to "/api/v1/en_GB/channels?field=name&order=ASC"
Then the JSON should be valid according to the schema "module/grid/features/gridSchema.json"
And the response status code should be 200

Scenario: Get channels (order DESC)
Given I am Authenticated as "test@ergonode.com"
And I add "Content-Type" header equal to "application/json"
And I add "Accept" header equal to "application/json"
When I send a GET request to "/api/v1/en/channels?field=name&order=DESC"
When I send a GET request to "/api/v1/en_GB/channels?field=name&order=DESC"
Then the JSON should be valid according to the schema "module/grid/features/gridSchema.json"
And the response status code should be 200

Scenario: Get channels (filter by name)
Given I am Authenticated as "test@ergonode.com"
And I add "Content-Type" header equal to "application/json"
And I add "Accept" header equal to "application/json"
When I send a GET request to "/api/v1/en/channels?limit=25&offset=0&filter=name%3Dasd"
When I send a GET request to "/api/v1/en_GB/channels?limit=25&offset=0&filter=name%3Dasd"
Then the JSON should be valid according to the schema "module/grid/features/gridSchema.json"
And the response status code should be 200

Scenario: Get channels (filter by code)
Given I am Authenticated as "test@ergonode.com"
And I add "Content-Type" header equal to "application/json"
And I add "Accept" header equal to "application/json"
When I send a GET request to "/api/v1/en/channels?limit=25&offset=0&filter=code%3DCAT"
When I send a GET request to "/api/v1/en_GB/channels?limit=25&offset=0&filter=code%3DCAT"
Then the JSON should be valid according to the schema "module/grid/features/gridSchema.json"

Scenario: Get channels (not authorized)
When I send a GET request to "/api/v1/en/channels"
Then the response status code should be 401
And the response status code should be 200
4 changes: 2 additions & 2 deletions features/notification.feature
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ Feature: channel module profile notification
And I add "Accept" header equal to "application/json"

Scenario: Get export info
When I send a GET request to "/api/v1/en/profile/exports"
Then the response status code should be 200
When I send a GET request to "/api/v1/en_GB/profile/exports"
Then the response status code should be 200
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

/**
*/
final class Version20181120151840 extends AbstractErgonodeMigration
final class Version20191120151840 extends AbstractErgonodeMigration
{
/**
* @param Schema $schema
Expand All @@ -23,18 +23,41 @@ public function up(Schema $schema): void
'CREATE TABLE exporter.channel(
id uuid NOT NULL,
name VARCHAR(255) NOT NULL,
export_profile_id UUID NOT NULL,
type VARCHAR(255) NOT NULL,
class VARCHAR(255) NOT NULL,
configuration JSONB not null,
created_at timestamp without time zone NOT NULL,
updated_at timestamp without time zone DEFAULT NULL,
PRIMARY KEY (id)
)'
);

$this->addSql(
'CREATE TABLE exporter.scheduler(
id uuid NOT NULL,
active boolean NOT NULL,
start timestamp without time zone DEFAULT NULL,
last timestamp without time zone DEFAULT NULL,
hour integer DEFAULT NULL,
minute integer DEFAULT NULL,
PRIMARY KEY (id)
)'
);
$this->addSql(
'ALTER TABLE exporter.scheduler
ADD CONSTRAINT scheduler_channel_fk FOREIGN KEY (id)
REFERENCES exporter.channel ON UPDATE CASCADE ON DELETE CASCADE'
);

$this->createPrivileges([
'CHANNEL_CREATE' => 'Channel',
'CHANNEL_READ' => 'Channel',
'CHANNEL_UPDATE' => 'Channel',
'CHANNEL_DELETE' => 'Channel',
]);

$this->addSql('INSERT INTO privileges_group (area) VALUES (?)', ['Channel']);

$this->createEventStoreEvents([
'Ergonode\Channel\Domain\Event\ChannelCreatedEvent' => 'Channel created',
'Ergonode\Channel\Domain\Event\ChannelDeletedEvent' => 'Channel deleted',
Expand Down
56 changes: 56 additions & 0 deletions src/Application/Command/ChannelExportScheduleConsoleCommand.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
<?php

/**
* Copyright © Ergonode Sp. z o.o. All rights reserved.
* See license.txt for license details.
*/

declare(strict_types = 1);

namespace Ergonode\Channel\Application\Command;

use Ergonode\EventSourcing\Infrastructure\Bus\CommandBusInterface;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Ergonode\Channel\Domain\Command\Schedule\ScheduleCommand;

/**
*/
class ChannelExportScheduleConsoleCommand extends Command
{
private const NAME = 'channel:export:schedule';

/**
* @var CommandBusInterface
*/
private CommandBusInterface $commandBus;

/**
* @param CommandBusInterface $commandBus
*/
public function __construct(CommandBusInterface $commandBus)
{
parent::__construct(static::NAME);

$this->commandBus = $commandBus;
}

/**
* @param InputInterface $input
* @param OutputInterface $output
*
* @return int
*/
public function execute(InputInterface $input, OutputInterface $output): int
{
$time = new \DateTime();

$output->writeln(sprintf('Run schedule for %s', $time->format('Y-m-d H:i:s')));

$command = new ScheduleCommand($time);
$this->commandBus->dispatch($command, true);

return 0;
}
}

0 comments on commit 05c8dd5

Please sign in to comment.