-
Notifications
You must be signed in to change notification settings - Fork 158
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
23 changed files
with
867 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
@managing_templates | ||
Feature: Adding cms templates | ||
In order to create templates | ||
As an Administrator | ||
I want to be able to add new templates | ||
|
||
Background: | ||
Given the store operates on a single channel in "United States" | ||
And I am logged in as an administrator | ||
|
||
@ui | ||
Scenario: Creating template | ||
When I go to the create template page | ||
And I fill the name with "Test template" | ||
And I choose "Page" in Type field | ||
And I add it | ||
Then I should be notified that the template has been created | ||
|
||
@ui @javascript | ||
Scenario: Creating template with content elements | ||
When I go to the create template page | ||
And I fill the name with "Test template" | ||
And I choose "Page" in Type field | ||
And I click on Add button in Content elements section | ||
And I select "Textarea" content element | ||
And I click on Add button in Content elements section | ||
And I select "Single media" content element | ||
And I add it | ||
Then I should be notified that the template has been created | ||
And I should see newly created "Textarea" content element in Content elements section | ||
And I should see newly created "Single media" content element in Content elements section | ||
|
||
@ui | ||
Scenario: Trying to add template with existing name | ||
Given there is a template in the store with "New template" name | ||
When I go to the create template page | ||
And I fill the name with "New template" | ||
And I try to add it | ||
Then I should be notified that there is already existing template with provided name | ||
|
||
@ui | ||
Scenario: Adding new template with blank data | ||
When I go to the create template page | ||
And I add it | ||
And I should be notified that "Name" field cannot be blank | ||
|
||
@ui | ||
Scenario: Trying to add a template with too short data | ||
When I go to the create template page | ||
And I fill the name with "X" | ||
And I try to add it | ||
Then I should be notified that "Name" field is too short | ||
|
||
@ui | ||
Scenario: Trying to add a template with too long data | ||
When I go to the create template page | ||
And I fill "Name" field with 251 characters | ||
And I try to add it | ||
Then I should be notified that "Name" field is too long |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
@managing_templates | ||
Feature: Managing cms templates | ||
In order to manage existing templates | ||
As an Administrator | ||
I want to be able to edit and remove existing templates | ||
|
||
Background: | ||
Given the store operates on a single channel in "United States" | ||
And I am logged in as an administrator | ||
|
||
@ui | ||
Scenario: Deleting template | ||
Given there is a template in the store with "Test template" name | ||
When I go to the templates page | ||
And I delete this template | ||
Then I should be notified that the template has been deleted | ||
And I should see empty list of templates | ||
|
||
@ui | ||
Scenario: Updating template | ||
Given there is a template in the store with "Test template" name | ||
When I go to the update "Test template" template page | ||
And I fill the name with "New template" | ||
And I update it | ||
Then I should be notified that the template has been successfully updated | ||
|
||
@ui @javascript | ||
Scenario: Updating template with content elements | ||
Given there is a template in the store with "Test template" name | ||
And there are "Textarea" and "Single media" content elements in this template | ||
When I go to the update "Test template" template page | ||
And I delete "Textarea" content element | ||
And I update it | ||
Then I should be notified that the template has been successfully updated | ||
And I should see only "Single media" content element in Content elements section |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
<?php | ||
|
||
/* | ||
* This file was created by developers working at BitBag | ||
* Do you need more information about us and what we do? Visit our https://bitbag.io website! | ||
* We are hiring developers from all over the world. Join us and start your new, exciting adventure and become part of us: https://bitbag.io/career | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Tests\BitBag\SyliusCmsPlugin\Behat\Context\Setup; | ||
|
||
use Behat\Behat\Context\Context; | ||
use BitBag\SyliusCmsPlugin\Entity\TemplateInterface; | ||
use BitBag\SyliusCmsPlugin\Repository\TemplateRepositoryInterface; | ||
use Sylius\Behat\Service\SharedStorageInterface; | ||
use Sylius\Component\Resource\Factory\FactoryInterface; | ||
use Tests\BitBag\SyliusCmsPlugin\Behat\Helpers\ContentElementHelper; | ||
|
||
final class TemplateContext implements Context | ||
{ | ||
public function __construct( | ||
private FactoryInterface $templateFactory, | ||
private SharedStorageInterface $sharedStorage, | ||
private TemplateRepositoryInterface $templateRepository, | ||
) { | ||
} | ||
|
||
/** | ||
* @Given there is a template in the store with :name name | ||
* @Given there is a template in the store with :name name and :type type | ||
*/ | ||
public function thereIsATemplate(string $name, ?string $type): void | ||
{ | ||
$template = $this->createTemplate($name, $type); | ||
|
||
$this->saveTemplate($template); | ||
} | ||
|
||
/** | ||
* @Given there are :firstContentElement and :secondContentElement content elements in this template | ||
*/ | ||
public function thereAreContentElementsInThisTemplate(string $firstContentElement, string $secondContentElement): void | ||
{ | ||
/** @var TemplateInterface $template */ | ||
$template = $this->sharedStorage->get('template'); | ||
$template->setContentElements([ | ||
['type' => ContentElementHelper::getContentElementValueByName($firstContentElement)], | ||
['type' => ContentElementHelper::getContentElementValueByName($secondContentElement)], | ||
]); | ||
|
||
$this->saveTemplate($template); | ||
} | ||
|
||
/** | ||
* @Given there is an existing template named :templateName with :type type that contains :contentElements content elements | ||
*/ | ||
public function thereIsAnExistingTemplateThatContainsContentElements(string $templateName, string $type, string $contentElements): void | ||
{ | ||
$template = $this->createTemplate($templateName, $type); | ||
|
||
$contentElements = explode(', ', $contentElements); | ||
|
||
$contentElementsArray = []; | ||
foreach ($contentElements as $contentElement) { | ||
$contentElementsArray[] = ['type' => ContentElementHelper::getContentElementValueByName($contentElement)]; | ||
} | ||
|
||
$template->setContentElements($contentElementsArray); | ||
|
||
$this->saveTemplate($template); | ||
} | ||
|
||
private function createTemplate(string $name, ?string $type = null): TemplateInterface | ||
{ | ||
/** @var TemplateInterface $template */ | ||
$template = $this->templateFactory->createNew(); | ||
$template->setName($name); | ||
|
||
if (null !== $type) { | ||
$template->setType($type); | ||
} | ||
|
||
return $template; | ||
} | ||
|
||
private function saveTemplate(TemplateInterface $template): void | ||
{ | ||
$this->templateRepository->add($template); | ||
$this->sharedStorage->set('template', $template); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.