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
29 changes: 28 additions & 1 deletion behat.yml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,13 @@ imports:

default:
extensions:
Behat\MinkExtension:
base_url: http://127.0.0.1:8080
javascript_session: selenium2
browser_name: 'chrome'
selenium2:
capabilities: { "browserName": "chrome", "browser": "chrome", "version": "62", 'chrome': {'switches':['--no-sandbox', '--headless']}}

FriendsOfBehat\ContextServiceExtension:
imports:
- vendor/sylius/sylius/src/Sylius/Behat/Resources/config/services.xml
Expand All @@ -18,4 +25,24 @@ default:
Lakion\Behat\MinkDebugExtension:
directory: etc/build
clean_start: false
screenshot: true
screenshot: false


javascript:
extensions:
Lakion\Behat\MinkDebugExtension:
directory: etc/build
clean_start: false
screenshot: false

Behat\MinkExtension:
base_url: http://127.0.0.1:8080
javascript_session: selenium2
browser_name: chrome
show_auto: false
selenium2:
capabilities: { "marionette": null, "browserName": "chrome", "browser": "chrome", "version": "63", 'chrome': {'switches':['--no-sandbox', '--headless', 'start-maximized']}}

gherkin:
filters:
tags: "@javascript"
Empty file modified etc/build/.gitkeep
100644 → 100755
Empty file.
15 changes: 15 additions & 0 deletions features/store/managing_stores/adding_store.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
@managing_stores
Feature: Adding a new store
As an Administrator
I want to add a new store to the registry

Background:
And the store is available in "English (United States)"
And I am logged in as an administrator
When I want to create a new store

@ui @javascript
Scenario: Adding a new store
And I specify its code as "bunny_store"
And I name it "Bunny Store" in "English (United States)"
And I define it for the "United States" zone
16 changes: 16 additions & 0 deletions features/store/managing_stores/browsing_stores.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
@managing_stores
Feature: Browsing stores
In order to have a overview of all defined stores
As an Administrator
I want to be able to browse list of them

Background:
Given I am logged in as an administrator
Given the store has "Dragon Store" store location
Given the store has "Bunny Store" store location

@ui
Scenario: Browsing defined stores
When I want to browse stores
Then I should see 2 stores in the list
And the store "Bunny Store" should be in the registry
16 changes: 16 additions & 0 deletions features/store/managing_stores/deleteing_store.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
@managing_stores
Feature: Deleting a store
In order to remove test, obsolete or incorrect stores
As an Administrator
I want to be able to delete a store

Background:
Given the store has "Dragon Store" store location
Given the store has "Bunny Store" store location
And I am logged in as an administrator

@ui
Scenario: Deleted store should disappear from the registry
When I delete store "Dragon Store"
Then I should see 1 stores in the list
And the store "Bunny Store" should be in the registry
40 changes: 40 additions & 0 deletions tests/Behat/Context/Transform/StoreContext.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<?php
namespace Tests\Locastic\SyliusStoreLocatorPlugin\Behat\Context\Transform;

use Behat\Behat\Context\Context;
use Liip\ImagineBundle\Exception\Config\Filter\NotFoundException;
use Locastic\SyliusStoreLocatorPlugin\Repository\StoreRepositoryInterface;
use Sylius\Component\Core\Formatter\StringInflector;

final class StoreContext implements Context
{
/**
* @var StoreRepositoryInterface
*/
private $storeRepository;

/**
* @param StoreRepositoryInterface $storeRepository
*/
public function __construct(StoreRepositoryInterface $storeRepository)
{
$this->storeRepository = $storeRepository;
}

/**
* @Transform /^store "([^"]+)"$/
* @Transform /^"([^"]+)" store/
* @Transform /^store to "([^"]+)"$/
* @Transform :store
*/
public function getStoreByName($storeName)
{
$store = $this->storeRepository->findOneByCode(StringInflector::nameToCode(strtolower($storeName)));

if($store === null){
throw new NotFoundException('Store with name '.$storeName.' not found"');
}

return $store;
}
}
104 changes: 104 additions & 0 deletions tests/Behat/Context/Ui/Admin/ManagingStoresContext.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
<?php
namespace Tests\Locastic\SyliusStoreLocatorPlugin\Behat\Context\Ui\Admin;

use Behat\Behat\Context\Context;
use Behat\Mink\Driver\Selenium2Driver;
use Behat\Mink\Exception\UnsupportedDriverActionException;
use Behat\MinkExtension\Context\MinkContext;
use Locastic\SyliusStoreLocatorPlugin\Entity\StoreInterface;
use Sylius\Behat\Page\Admin\Crud\IndexPageInterface;
use Tests\Locastic\SyliusStoreLocatorPlugin\Behat\Page\Admin\Store\CreatePageInterface;
use Tests\Locastic\SyliusStoreLocatorPlugin\Behat\Page\Admin\Store\UpdatePageInterface;
use Webmozart\Assert\Assert;

final class ManagingStoresContext extends MinkContext implements Context
{
/**
* @var IndexPageInterface
*/
private $indexPage;

/**
* @var CreatePageInterface
*/
private $createPage;

/**
* @var UpdatePageInterface
*/
private $updatePage;

/**
* @param IndexPageInterface $indexPage
* @param CreatePageInterface $createPage
* @param UpdatePageInterface $updatePage
*/
public function __construct(
IndexPageInterface $indexPage,
CreatePageInterface $createPage,
UpdatePageInterface $updatePage
) {
$this->indexPage = $indexPage;
$this->createPage = $createPage;
$this->updatePage = $updatePage;
}

/**
* @When /^I want to browse stores$/
*/
public function iWantToBrowseStores()
{
$this->indexPage->open();
}

/**
* @Then /^I should see (\d+) stores in the list$/
*/
public function iShouldSeeStoresInTheList(int $numberOfStores)
{
Assert::same($this->indexPage->countItems(), $numberOfStores);
}

/**
* @Given /^the store "([^"]*)" should be in the registry$/
*/
public function theStoreShouldBeInTheRegistry($storeName)
{
$this->iWantToBrowseStores();

Assert::true($this->indexPage->isSingleResourceOnPage(['name' => $storeName]));
}

/**
* @When /^I delete (store "[^"]+")$/
*/
public function iDeleteStore(StoreInterface $store)
{
$this->indexPage->open();
$this->indexPage->deleteResourceOnPage(['code' => $store->getCode()]);
}

/**
* @When /^I want to create a new store$/
*/
public function iWantToCreateANewStore()
{
$driver = $this->getSession()->getDriver();

if (!$driver instanceof Selenium2Driver) {
throw new UnsupportedDriverActionException('Selenium2Driver not installed.');

return;
}

$this->createPage->open();
}

/**
* @When I specify its code as :storeCode
*/
public function iSpecifyItsCodeAs($storeCode)
{
$this->createPage->specifyCode($storeCode);
}
}
32 changes: 32 additions & 0 deletions tests/Behat/Page/Admin/Store/CreatePage.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?php

namespace Tests\Locastic\SyliusStoreLocatorPlugin\Behat\Page\Admin\Store;

use Sylius\Behat\Page\Admin\Crud\CreatePage as BaseCreatePage;

class CreatePage extends BaseCreatePage implements CreatePageInterface
{

/**
* {@inheritdoc}
*/
public function getRouteName()
{
return 'locastic_sylius_store_locator_plugin_admin_store_create';
}

/**
* {@inheritdoc}
*/
public function specifyCode($code)
{
$this->getDocument()->fillField('Code', $code);
}

/*public function open(array $urlParameters = [])
{
dump($this->getUrl($urlParameters));
$this->getSession()->visit($this->getUrl($urlParameters));
}*/

}
9 changes: 9 additions & 0 deletions tests/Behat/Page/Admin/Store/CreatePageInterface.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?php
namespace Tests\Locastic\SyliusStoreLocatorPlugin\Behat\Page\Admin\Store;

use Sylius\Behat\Page\Admin\Crud\CreatePageInterface as BaseCreatePageInterface;

interface CreatePageInterface extends BaseCreatePageInterface
{

}
14 changes: 14 additions & 0 deletions tests/Behat/Page/Admin/Store/UpdatePage.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?php
namespace Tests\Locastic\SyliusStoreLocatorPlugin\Behat\Page\Admin\Store;
use Sylius\Behat\Page\Admin\Crud\UpdatePage as BaseUpdatePage;

class UpdatePage extends BaseUpdatePage implements UpdatePageInterface
{
/**
* {@inheritdoc}
*/
public function getRouteName()
{
return 'locastic_sylius_store_locator_plugin_admin_store_update';
}
}
9 changes: 9 additions & 0 deletions tests/Behat/Page/Admin/Store/UpdatePageInterface.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?php
namespace Tests\Locastic\SyliusStoreLocatorPlugin\Behat\Page\Admin\Store;

use Sylius\Behat\Page\Admin\Crud\UpdatePageInterface as BaseUpdatePageInterface;

interface UpdatePageInterface extends BaseUpdatePageInterface
{

}
41 changes: 41 additions & 0 deletions tests/Behat/Resources/services.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
parameters:
sylius.behat.page.admin.store.index.class: "%sylius.behat.page.admin.crud.index.class%"

services:
#shop

Expand All @@ -18,7 +21,16 @@ services:
tags:
- fob.context_service

# admin

locastic_sylius_store_locator.context.ui.admin.managing_stores:
class: Tests\Locastic\SyliusStoreLocatorPlugin\Behat\Context\Ui\Admin\ManagingStoresContext
arguments:
- "@locastic_sylius_store_locator.page.admin.store_index"
- "@locastic_sylius_store_locator.page.admin.store_create"
- "@locastic_sylius_store_locator.page.admin.store_update"
tags:
- fob.context_service
#setup

locastic_sylius_store_locator.behat.context.setup.shipping:
Expand All @@ -39,6 +51,14 @@ services:
tags:
- fob.context_service

#transform
locastic_sylius_store_locator.behat.context.transform.store:
class: Tests\Locastic\SyliusStoreLocatorPlugin\Behat\Context\Transform\StoreContext
arguments:
- "@__symfony__.locastic_sylius_store_locator_plugin.repository.store"
tags:
- fob.context_service

#pages

locastic_sylius_store_locator.page.shop.select_shipping:
Expand All @@ -55,3 +75,24 @@ services:
class: Tests\Locastic\SyliusStoreLocatorPlugin\Behat\Page\Shop\Store\StoreShowPage
public: false
parent: sylius.behat.symfony_page

locastic_sylius_store_locator.page.admin.store_index:
class: '%sylius.behat.page.admin.store.index.class%'
public: true
parent: sylius.behat.page.admin.crud.index
arguments:
- "locastic_sylius_store_locator_plugin_admin_store_index"

locastic_sylius_store_locator.page.admin.store_create:
class: Tests\Locastic\SyliusStoreLocatorPlugin\Behat\Page\Admin\Store\CreatePage
public: true
parent: sylius.behat.page.admin.crud.create
arguments:
- "locastic_sylius_store_locator_plugin_admin_store_create"

locastic_sylius_store_locator.page.admin.store_update:
class: Tests\Locastic\SyliusStoreLocatorPlugin\Behat\Page\Admin\Store\UpdatePage
public: true
parent: sylius.behat.page.admin.crud.update
arguments:
- "locastic_sylius_store_locator_plugin_admin_store_update"
Loading