WIP: Attempt to fix behat tests

This commit is contained in:
Kristian Løvstrøm 2015-02-03 19:06:30 +06:00 committed by michalmarcinkowski
parent 71da427644
commit e15a94c8d6
77 changed files with 289 additions and 16 deletions

View file

@ -356,6 +356,21 @@ default:
- Sylius\Bundle\MoneyBundle\Behat\MoneyContext
filters:
tags: "@search_orm_only"
channels:
contexts:
- Behat\MinkExtension\Context\MinkContext
- Sylius\Bundle\CoreBundle\Behat\HookContext
- Sylius\Bundle\CoreBundle\Behat\CoreContext
- Sylius\Bundle\ResourceBundle\Behat\BaseContext
- Sylius\Bundle\AddressingBundle\Behat\AddressingContext
- Sylius\Bundle\PromotionBundle\Behat\PromotionContext
- Sylius\Bundle\ShippingBundle\Behat\ShippingContext
- Sylius\Bundle\TaxonomyBundle\Behat\TaxonomyContext
- Sylius\Bundle\PaymentBundle\Behat\PaymentContext
- Sylius\Bundle\WebBundle\Behat\WebContext
- Sylius\Bundle\MoneyBundle\Behat\MoneyContext
filters:
tags: "@channels && ~@javascript"
emails:
contexts:

View file

@ -6,6 +6,7 @@ Feature: Countries and provinces
Background:
Given there is default currency configured
And there is default channel configured
And there are following locales configured:
| code | enabled |
| en_US | yes |

View file

@ -6,6 +6,7 @@ Feature: Store dashboard
Background:
Given there is default currency configured
And there is default channel configured
And I am logged in as administrator
And the following zones are defined:
| name | type | members |

View file

@ -11,6 +11,7 @@ Feature: General settings
| GBP | 1.16998 | no |
| EUR | 1.00000 | yes |
| AUD | 0.73986 | yes |
And there is default channel configured
And I am logged in as administrator
Scenario: Accessing the settings form

View file

@ -6,6 +6,7 @@ Feature: User groups management
Background:
Given there is default currency configured
And there is default channel configured
And I am logged in as administrator
And the following zones are defined:
| name | type | members |

View file

@ -6,6 +6,7 @@ Feature: Inventory tracking
Background:
Given there is default currency configured
And there is default channel configured
And I am logged in as administrator
And there are following options:
| name | presentation | values |

View file

@ -6,6 +6,7 @@ Feature: Orders management
Background:
Given there is default currency configured
And there is default channel configured
And I am logged in as administrator
And the following zones are defined:
| name | type | members |

View file

@ -6,6 +6,7 @@ Feature: Payment methods
Background:
Given there is default currency configured
And there is default channel configured
And I am logged in as administrator
And the following payment methods exist:
| name | gateway |

View file

@ -6,6 +6,7 @@ Feature: Product archetypes
Background:
Given there is default currency configured
And there is default channel configured
And there are following locales configured:
| code | enabled |
| en_US | yes |

View file

@ -6,6 +6,7 @@ Feature: Product archetype translations
Background:
Given there is default currency configured
And there is default channel configured
And there are following locales configured:
| code | enabled |
| en_US | yes |

View file

@ -6,6 +6,7 @@ Feature: Product attributes
Background:
Given there is default currency configured
And there is default channel configured
And there are following locales configured:
| code | enabled |
| en_US | yes |

View file

@ -6,6 +6,7 @@ Feature: Product options
Background:
Given there is default currency configured
And there is default channel configured
And there are following locales configured:
| code | enabled |
| en_US | yes |

View file

@ -6,6 +6,7 @@ Feature: Browsing products by taxonomies
Background:
Given there is default currency configured
And there is default channel configured
And I am logged in as administrator
And there are following taxonomies defined:
| name |

View file

@ -6,6 +6,7 @@ Feature: Product variants
Background:
Given there is default currency configured
And there is default channel configured
And I am logged in as administrator
And there are following locales configured:
| code | enabled |

View file

@ -6,6 +6,7 @@ Feature: Products
Background:
Given there is default currency configured
And there is default channel configured
And there are following locales configured:
| code | enabled |
| en_US | yes |

View file

@ -6,6 +6,7 @@ Feature: Products filter
Background:
Given there is default currency configured
And there is default channel configured
And I am logged in as administrator
And the following products exist:
| name | price | sku |

View file

@ -6,6 +6,7 @@ Feature: Products
Background:
Given there is default currency configured
And there is default channel configured
And I am logged in as administrator
And there are following locales configured:
| code | enabled |

View file

@ -6,6 +6,7 @@ Feature: Promotions
Background:
Given there is default currency configured
And there is default channel configured
And I am logged in as administrator
And the following promotions exist:
| name | description | usage limit | used | starts | ends |

View file

@ -6,6 +6,7 @@ Feature: Orm indexer event listener
Background:
Given there is default currency configured
And there is default channel configured
And I am logged in as administrator
And there are following locales configured:
| code | enabled |

View file

@ -6,6 +6,7 @@ Feature: Shipments
Background:
Given there is default currency configured
And there is default channel configured
And I am logged in as administrator
And the following zones are defined:
| name | type | members |

View file

@ -6,6 +6,7 @@ Feature: Shipping categories
Background:
Given there is default currency configured
And there is default channel configured
And I am logged in as administrator
And there are following shipping categories:
| name |

View file

@ -6,6 +6,7 @@ Feature: Shipping methods
Background:
Given there is default currency configured
And there is default channel configured
And I am logged in as administrator
And there are following locales configured:
| code | enabled |

View file

@ -6,6 +6,7 @@ Feature: Tax categories
Background:
Given there is default currency configured
And there is default channel configured
And I am logged in as administrator
And there are following tax categories:
| name |

View file

@ -6,6 +6,7 @@ Feature: Tax rates
Background:
Given there is default currency configured
And there is default channel configured
And I am logged in as administrator
And the following zones are defined:
| name | type | members |

View file

@ -6,6 +6,7 @@ Feature: Taxation settings
Background:
Given there is default currency configured
And there is default channel configured
And I am logged in as administrator
And the following zones are defined:
| name | type | members |

View file

@ -6,6 +6,7 @@ Feature: taxonomies
Background:
Given there is default currency configured
And there is default channel configured
And there are following locales configured:
| code | enabled |
| en_US | yes |

View file

@ -6,6 +6,7 @@ Feature: Users management
Background:
Given there is default currency configured
And there is default channel configured
And I am logged in as administrator
And there are products:
| name | price |

View file

@ -6,6 +6,7 @@ Feature: Zones
Background:
Given there is default currency configured
And there is default channel configured
And I am logged in as administrator
And there are following zones:
| name | type | members | scope |

View file

@ -5,7 +5,9 @@ Feature: Channel management
I want to configure channels
Background:
Given I am logged in as administrator
Given there is default currency configured
And there is default channel configured
And I am logged in as administrator
And the following zones are defined:
| name | type | members |
| USA | country | USA |
@ -45,7 +47,7 @@ Feature: Channel management
Given I am on the dashboard page
When I follow "Channels"
Then I should be on the channel index page
And I should see 2 channels in the list
And I should see 3 channels in the list
Scenario: Channel codes are visible in the grid
Given I am on the dashboard page
@ -56,21 +58,22 @@ Feature: Channel management
Scenario: Seeing empty index of channels
Given there are no channels
When I am on the channel index page
Then I should see "There are no channels to display."
Then I should see "There are no channels configured."
Scenario: Accessing the channel creation form
Given I am on the dashboard page
When I follow "Channels"
And I follow "Create channel"
And I follow "Add channel"
Then I should be on the channel creation page
Scenario: Creating new channel
Given I am on the channel creation page
And I fill in "Code" with "MOBILE-US"
And I select "en_US" from "Locales"
And I fill in "Name" with "Mobile US"
And I select "English (United States)" from "Locales"
And I select "USD" from "Currencies"
And I select "Stripe" from "Payment methods"
And I select "FedEx" from "Shipping methods"
And I select "PayPal" from "Payment Methods"
And I select "FedEx" from "Shipping Methods"
When I press "Create"
Then I should be on the channel index page
And I should see "Channel has been successfully created."

View file

@ -6,6 +6,7 @@ Feature: Contact requests management
Background:
Given there is default currency configured
And there is default channel configured
And there are following contact topics:
| title |
| Order return |

View file

@ -6,6 +6,7 @@ Feature: Contact requesting
Background:
Given there is default currency configured
And there is default channel configured
And there are following contact topics:
| title |
| Order return |

View file

@ -6,6 +6,7 @@ Feature: Contact topics management
Background:
Given there is default currency configured
And there is default channel configured
And there are following contact topics:
| title |
| Order return |

View file

@ -11,6 +11,7 @@ Feature: Currency management
| GBP | 1.16998 | no |
| EUR | 1.00000 | yes |
| AUD | 0.73986 | yes |
And there is default channel configured
And I am logged in as administrator
Scenario: Browsing all configured currencies

View file

@ -19,6 +19,10 @@ Feature: Currency selection
| USD | 0.76496 | yes |
| GBP | 1.13986 | yes |
| PLN | 1.01447 | no |
And there are following channels configured:
| code | name | currencies | locales | url |
| DEFAULT-WEB | Defautl Channel | EUR, GBP, USD | en_US | localhost |
And all products assigned to "DEFAULT-WEB" channel
Scenario: Only enabled currencies are visible to the user

View file

@ -6,6 +6,7 @@ Feature: User account addresses page
Background:
Given there is default currency configured
And there is default channel configured
And I am logged in user
And the following countries exist:
| name |

View file

@ -4,13 +4,16 @@ Feature: User account homepage
As a logged user
I want to be able to see my account homepage
Background:
Given there is default currency configured
And there is default channel configured
Scenario: Displaying the my account section only to logged users
Given I am on the store homepage
Then I should not see "My account"
Scenario: Viewing the homepage of my account
Given I am on the store homepage
And there is default currency configured
And I am logged in user
When I follow "My account"
Then I should be on my account homepage

View file

@ -6,6 +6,7 @@ Feature: User account orders page
Background:
Given there is default currency configured
And there is default channel configured
And I am logged in user
And I am on my account homepage
And the following zones are defined:
@ -27,6 +28,7 @@ Feature: User account orders page
| Mug | 5.99 | 456 |
| Sticker | 10.00 | 213 |
| Book | 22.50 | 948 |
And all products assigned to "DEFAULT-WEB" channel
And the following orders exist:
| user | shipment | address |
| sylius@example.com | UPS, shipped, DTBHH380HG | Théophile Morel, 17 avenue Jean Portalis, 33000, Bordeaux, France |

View file

@ -6,6 +6,7 @@ Feature: User account password change
Background:
Given there is default currency configured
And there is default channel configured
And I am logged in user
And I am on my account homepage

View file

@ -6,6 +6,7 @@ Feature: User account profile edition
Background:
Given there is default currency configured
And there is default channel configured
And I am logged in user
And I am on my account homepage

View file

@ -22,10 +22,12 @@ Feature: Cart
| Git T-Shirt | 29.99 | T-Shirt size | PHP T-Shirts | match |
| PHP Top | 5.99 | | PHP T-Shirts | |
| iShirt | 18.99 | | T-Shirts | |
And all products assigned to "DEFAULT-WEB" channel
And product "Super T-Shirt" is available in all variations
And product "Git T-Shirt" is available in all variations
And product "Black T-Shirt" is available in all variations
And there is default currency configured
And there is default channel configured
Scenario: Seeing empty cart
Given I am on the store homepage

View file

@ -11,6 +11,7 @@ Feature: Tax included in price
And taxonomy "Category" has following taxons:
| Clothing > PHP T-Shirts |
And there is default currency configured
And there is default channel configured
And the following zones are defined:
| name | type | members |
| Germany | country | Germany |
@ -23,6 +24,7 @@ Feature: Tax included in price
And the following products exist:
| name | price | taxons | tax category |
| PHP Top | 85 | PHP T-Shirts | Taxable Goods |
And all products assigned to "DEFAULT-WEB" channel
And the default tax zone is "Germany"
Scenario: Correct amounts are displayed for inclusive taxes

View file

@ -30,6 +30,8 @@ Feature: Checkout promotions with multiple rules and actions
| Etch | 20 | Debian T-Shirts |
| Lenny | 15 | Debian T-Shirts |
And there is default currency configured
And there is default channel configured
And all products assigned to "DEFAULT-WEB" channel
Scenario: Several discounts are applied when a promotion has several
actions and the cart fulfills all the rules

View file

@ -41,6 +41,8 @@ Feature: Checkout coupon promotions
| Etch | 20 | Debian T-Shirts |
| Lenny | 1 | Debian T-Shirts |
And there is default currency configured
And there is default channel configured
And all products assigned to "DEFAULT-WEB" channel
Scenario: Promotion with coupons is applied when the customer
has added a valid coupon

View file

@ -33,6 +33,8 @@ Feature: Checkout limited time promotions
| Etch | 20 | Debian T-Shirts |
| Lenny | 15 | Debian T-Shirts |
And there is default currency configured
And there is default channel configured
And all products assigned to "DEFAULT-WEB" channel
Scenario: Promotion is applied when the order date corresponds
with promotion dates

View file

@ -6,6 +6,7 @@ Feature: Checkout fixed discount promotions
Background:
Given there is default currency configured
And there is default channel configured
And I am logged in as user "klaus@example.com"
And the following countries exist:
| name |
@ -33,6 +34,8 @@ Feature: Checkout fixed discount promotions
| Shipping to Germany | Discount for orders with shipping country Germany |
| Ubuntu T-Shirts | Discount for Ubuntu T-Shirts |
| 3rd order | Discount for 3rd order |
And all products assigned to "DEFAULT-WEB" channel
And all promotions assigned to "DEFAULT-WEB" channel
And promotion "3 items" has following rules defined:
| type | configuration |
| Item count | Count: 3,Equal: true |

View file

@ -35,6 +35,9 @@ Feature: Checkout percentage discount promotions
| Etch | 20 | Debian T-Shirts |
| Lenny | 15 | Debian T-Shirts |
And there is default currency configured
And there is default channel configured
And all products assigned to "DEFAULT-WEB" channel
And all promotions assigned to "DEFAULT-WEB" channel
Scenario: Fixed discount promotion is applied when the cart
has the required amount

View file

@ -24,6 +24,9 @@ Feature: Checkout product promotion
| type | configuration |
| Add product | variant:Ubu,quantity:1,price:10 |
And there is default currency configured
And there is default channel configured
And all products assigned to "DEFAULT-WEB" channel
And all promotions assigned to "DEFAULT-WEB" channel
Scenario: Free product is not applied when the cart
has not the required amount

View file

@ -35,6 +35,9 @@ Feature: Checkout usage limited promotions
| Etch | 20 | Debian T-Shirts |
| Lenny | 15 | Debian T-Shirts |
And there is default currency configured
And there is default channel configured
And all products assigned to "DEFAULT-WEB" channel
And all promotions assigned to "DEFAULT-WEB" channel
Scenario: Promotion with usage limit is applied when the
number of usage is not reached

View file

@ -27,6 +27,9 @@ Feature: Tax categories
| PHP Top | 50 | PHP T-Shirts | Clothing |
| Golden Apple | 120 | Food | Food |
And there is default currency configured
And there is default channel configured
And all products assigned to "DEFAULT-WEB" channel
And all promotions assigned to "DEFAULT-WEB" channel
Scenario: Correct taxes are applied for one item
Given the default tax zone is "UK"

View file

@ -25,6 +25,8 @@ Feature: Cart taxation
| name | price | taxons | tax category |
| PHP Top | 50 | PHP T-Shirts | Taxable Goods |
And there is default currency configured
And there is default channel configured
And all products assigned to "DEFAULT-WEB" channel
Scenario: No taxes are applied for unknown billing address
when default tax zone is not configured

View file

@ -32,6 +32,8 @@ Feature: Checkout addressing
| UK + Germany | DHL Express | Flat rate | Amount: 5000 |
| USA | FedEx | Flat rate | Amount: 6500 |
And there is default currency configured
And there is default channel configured
And all products assigned to "DEFAULT-WEB" channel
Scenario: Filling the shipping address
Given I am logged in user

View file

@ -28,6 +28,8 @@ Feature: Checkout addressing in preferred language
| UK + Germany | DHL Express | Flat rate | Amount: 5000 |
| USA | FedEx | Flat rate | Amount: 6500 |
And there is default currency configured
And there is default channel configured
And all products assigned to "DEFAULT-WEB" channel
And there are following locales configured:
| code | enabled |
| en_US | yes |

View file

@ -23,6 +23,8 @@ Feature: Checkout finalization
| name | gateway | enabled |
| Dummy | dummy | yes |
And there is default currency configured
And there is default channel configured
And all products assigned to "DEFAULT-WEB" channel
Scenario: Placing the order
Given I am logged in user

View file

@ -24,6 +24,8 @@ Feature: Checkout inventory
| name | gateway | enabled |
| Credit Card | dummy | yes |
And there is default currency configured
And there is default channel configured
And all products assigned to "DEFAULT-WEB" channel
And I am logged in as administrator
Scenario: Inventory is updated after buying products

View file

@ -6,6 +6,7 @@ Feature: Checkout Payment
Background:
Given there is default currency configured
And there is default channel configured
And there are following taxonomies defined:
| name |
| Category |
@ -25,6 +26,7 @@ Feature: Checkout Payment
| Credit Card | stripe | yes |
| PayPal | paypal | yes |
| PayPal PRO | paypal_pro | no |
And all products assigned to "DEFAULT-WEB" channel
And I am logged in user
And I added product "PHP Top" to cart
And I go to the checkout start page

View file

@ -6,6 +6,7 @@ Feature: Checkout security
Background:
Given there is default currency configured
And there is default channel configured
And there are following taxonomies defined:
| name |
| Category |
@ -27,6 +28,7 @@ Feature: Checkout security
And the following payment methods exist:
| name | gateway | enabled |
| Dummy | dummy | yes |
And all products assigned to "DEFAULT-WEB" channel
And I added product "PHP Top" to cart
And I go to the checkout start page

View file

@ -33,6 +33,8 @@ Feature: Checkout shipping
| name | gateway | enabled |
| Dummy | dummy | yes |
And there is default currency configured
And there is default channel configured
And all products assigned to "DEFAULT-WEB" channel
And I am logged in user
And I added product "PHP Top" to cart

View file

@ -27,6 +27,8 @@ Feature: Checkout shipping in preferred language
| USA | FedEx | Flat rate | Amount: 6500 | yes |
| UK + Germany | UPS Ground | Flat rate | Amount: 20000 | yes |
And there is default currency configured
And there is default channel configured
And all products assigned to "DEFAULT-WEB" channel
And there are following locales configured:
| code | enabled |
| en_US | yes |

View file

@ -20,6 +20,8 @@ Feature: Checkout starting
| PHP Top | 5.99 | | PHP T-Shirts | |
And product "Super T-Shirt" is available in all variations
And there is default currency configured
And there is default channel configured
And all products assigned to "DEFAULT-WEB" channel
Scenario: There is no checkout for empty cart
Given I am on the store homepage

View file

@ -29,6 +29,8 @@ Feature: Checkout taxation
| name | gateway | enabled |
| Dummy | dummy | yes |
And there is default currency configured
And there is default channel configured
And all products assigned to "DEFAULT-WEB" channel
And I am logged in user
And I added product "PHP Top" to cart
And I go to the checkout start page

View file

@ -6,6 +6,7 @@ Feature: Store homepage
Scenario: Viewing the homepage at website root
Given there is default currency configured
And there is default channel configured
When I go to the website root
Then I should be on the homepage
And I should see "Modern ecommerce for Symfony2"

View file

@ -6,6 +6,7 @@ Feature: Products
Background:
Given there is default currency configured
And there is default channel configured
And there are following taxonomies defined:
| name |
| Category |
@ -20,6 +21,7 @@ Feature: Products
| Sylius Tee | 12.99 | PHP T-Shirts |
| Symfony T-Shirt | 15.00 | PHP T-Shirts |
| Doctrine T-Shirt | 15.00 | PHP T-Shirts |
And all products assigned to "DEFAULT-WEB" channel
Scenario: Browsing products by taxon
Given I am on the store homepage

View file

@ -6,6 +6,7 @@ Feature: Browse products, categories, attributes and options in preferred langua
Background:
Given there is default currency configured
And there is default channel configured
And there are following taxonomies defined:
| name |
| Category |
@ -43,6 +44,7 @@ Feature: Browse products, categories, attributes and options in preferred langua
And the following option translations exist
| option | presentation | locale |
| T-Shirt size | Talla | es |
And all products assigned to "DEFAULT-WEB" channel
Scenario: Seeing translated product, taxonomy and taxon name
Given I am on the store homepage

View file

@ -6,6 +6,7 @@ Feature: Search products
Background:
Given there is default currency configured
And there is default channel configured
And there are following taxonomies defined:
| name |
| Category |
@ -20,8 +21,10 @@ Feature: Search products
| Sylius Tee | 12.99 | PHP T-Shirts | a very nice php t-shirt |
| Symfony T-Shirt | 15.00 | PHP T-Shirts | symfony t-shirt |
| Doctrine T-Shirt | 15.00 | PHP T-Shirts | doctrine t-shirt |
And all products assigned to "DEFAULT-WEB" channel
And I populate the index
Scenario: Search homepage is accessible
Given I am on homepage
Then I should see "Login"

View file

@ -9,6 +9,7 @@ Feature: Sign in to the store
| email | password | enabled |
| bar@foo.com | foo | yes |
And there is default currency configured
And there is default channel configured
Scenario: Log in with username and password
Given I am on the store homepage

View file

@ -6,6 +6,7 @@ Feature: Sign in to the store via OAuth
Background:
Given there is default currency configured
And there is default channel configured
And I am not logged in
And I am on the store homepage

View file

@ -9,6 +9,7 @@ Feature: User registration
| email | password |
| bar@bar.com | foo |
And there is default currency configured
And there is default channel configured
Scenario: Successfully creating account in store
Given I am on the store homepage

View file

@ -8,6 +8,7 @@ Feature: Managing locales
Given there are following currencies configured:
| code | exchange rate | enabled |
| EUR | 1.00000 | yes |
And there is default channel configured
And there are following locales configured:
| code | activated |
| de_DE | yes |

View file

@ -12,6 +12,9 @@ Feature: Locale selection
| fr_FR | no |
| pl_PL | yes |
And there is default currency configured
And there are following channels configured:
| code | name | currencies | locales | url |
| DEFAULT-WEB | Defautl Channel | EUR | de, en, pl | localhost |
Scenario: Only enabled locales are visible to the user
Given I am on the store homepage

View file

@ -6,6 +6,7 @@ Feature: Group based pricing
Background:
Given there is default currency configured
And there is default channel configured
And there are following taxonomies defined:
| name |
| Category |
@ -37,6 +38,7 @@ Feature: Group based pricing
| group | price |
| Wholesale Customers | 39.49 |
| Retail Customers | 45.99 |
And all products assigned to "DEFAULT-WEB" channel
Scenario: Default price is used when user is not logged in
Given I am on the store homepage

View file

@ -6,6 +6,7 @@ Feature: Standard pricing
Background:
Given there is default currency configured
And there is default channel configured
And there are following taxonomies defined:
| name |
| Category |
@ -25,6 +26,7 @@ Feature: Standard pricing
| name | price | taxons | tax category |
| PHP Top | 49.99 | PHP T-Shirts | Taxable Goods |
| Symfony Tee | 69.00 | PHP T-Shirts | Taxable Goods |
And all products assigned to "DEFAULT-WEB" channel
Scenario: Flat price is calculated for products
Given I am on the store homepage

View file

@ -6,6 +6,7 @@ Feature: Volume based pricing
Background:
Given there is default currency configured
And there is default channel configured
And there are following taxonomies defined:
| name |
| Category |
@ -30,6 +31,7 @@ Feature: Volume based pricing
| 10-19 | 65.00 |
| 20-29 | 60.00 |
| 30+ | 55.99 |
And all products assigned to "DEFAULT-WEB" channel
Scenario: Volume-based pricing has priority over price attribute
Given I am on the store homepage

View file

@ -15,6 +15,8 @@ use Behat\Gherkin\Node\TableNode;
use Sylius\Bundle\ResourceBundle\Behat\DefaultContext;
use Sylius\Component\Addressing\Model\AddressInterface;
use Sylius\Component\Cart\SyliusCartEvents;
use Sylius\Component\Channel\Model\ChannelsAwareInterface;
use Sylius\Component\Core\Model\ChannelInterface;
use Sylius\Component\Core\Model\OrderInterface;
use Sylius\Component\Core\Model\OrderItemInterface;
use Sylius\Component\Core\Model\PaymentInterface;
@ -552,4 +554,142 @@ class CoreContext extends DefaultContext
$this->fillField('Password', 'sylius');
$this->pressButton('login');
}
/**
* @Given /^all products assigned to "([^""]*)" channel$/
*/
public function assignChannelToProducts($code)
{
/** @var ChannelInterface $channel */
$channel = $this->getRepository('channel')->findOneBy(array('code' => $code));
/** @var ProductInterface[] $products */
$products = $this->getRepository('product')->findAll();
foreach ($products as $product) {
$product->addChannel($channel);
}
$this->getEntityManager()->flush();
}
/**
* @Given /^all promotions assigned to "([^""]*)" channel$/
*/
public function assignChannelToPromotions($code)
{
/** @var ChannelInterface $channel */
$channel = $this->getRepository('channel')->findOneBy(array('code' => $code));
/** @var ChannelsAwareInterface[] $promotions */
$promotions = $this->getRepository('promotion')->findAll();
foreach ($promotions as $promotion) {
$promotion->addChannel($channel);
}
$this->getEntityManager()->flush();
}
/**
* @Given /^there is default channel configured$/
*/
public function setupDefaultChannel()
{
$this->thereIsChannel('DEFAULT-WEB', "Default", "localhost");
}
/**
* @Given /^there are following channels configured:$/
*/
public function thereAreFollowingChannels(TableNode $table)
{
foreach ($table->getHash() as $data) {
$this->thereIsChannel(
$data['code'],
$data['name'],
isset($data['url']) ? $data['url'] : null,
isset($data['locales']) ? $data['locales'] : null,
isset($data['currencies']) ? $data['currencies'] : null,
isset($data['shipping']) ? $data['shipping'] : null,
isset($data['payments']) ? $data['payments'] : null,
false
);
}
$this->getEntityManager()->flush();
}
/**
* @Given /^channel "([^""]*)" has following configuration:$/
*/
public function channelHasFollowingConfiguration($code, TableNode $table)
{
$channel = $this->getRepository('channel')->findOneBy(array('code' => $code));
foreach ($table->getHash() as $data) {
$this->configureChannel(
$channel,
isset($data['locales']) ? $data['locales'] : null,
isset($data['currencies']) ? $data['currencies'] : null,
isset($data['shipping']) ? $data['shipping'] : null,
isset($data['payment']) ? $data['shipping'] : null
);
}
$this->getEntityManager()->flush();
}
/**
* @Given /^There is channel "([^""]*)" named "([^""]*)" for url "([^""]*)"$/
*/
public function thereIsChannel($code, $name, $url, $locales = null, $currencies = "EUR", $shippingMethods = null, $paymentMethos = null, $flush = true)
{
/* @var $channel ChannelInterface */
$channel = $this->getRepository('channel')->createNew();
$channel->setCode($code);
$channel->setName($name);
$channel->setUrl($url);
$this->configureChannel($channel, $locales, $currencies, $shippingMethods, $paymentMethos);
$manager = $this->getEntityManager();
$manager->persist($channel);
if ($flush) {
$manager->flush();
}
return $channel;
}
private function configureChannel(ChannelInterface $channel, $localeCodes = null, $currencyCodes = null, $shippingMethodNames = null, $paymentMethodNames = null)
{
if ($shippingMethodNames) {
$shippingMethodNames = array_map('trim', explode(',', $shippingMethodNames));
foreach ($shippingMethodNames as $shippingMethodName) {
$shippingMethod = $shippingMethods = $this->getRepository('shipping_method')->findOneBy(array('name' => $shippingMethodName));
$channel->addShippingMethod($shippingMethod);
}
}
if ($paymentMethodNames) {
$paymentMethodNames = array_map('trim', explode(',', $paymentMethodNames));
$paymentMethods = $this->getRepository('payment_method')->findBy(array('name' => $paymentMethodNames));
foreach ($paymentMethods as $paymentMethod) {
$channel->addPaymentMethod($paymentMethod);
}
}
if ($localeCodes) {
$localeCodes = array_map('trim', explode(',', $localeCodes));
$locales = $this->getRepository('locale')->findBy(array('code' => $localeCodes));
foreach($locales as $locale) {
$channel->addLocale($locale);
}
}
if ($currencyCodes) {
$currencyCodes = array_map('trim', explode(',', $currencyCodes));
$currencies = $this->getRepository('currency')->findBy(array('code' => $currencyCodes));
foreach ($currencies as $currency) {
$channel->addCurrency($currency);
}
}
}
}

View file

@ -88,7 +88,7 @@ class ItemResolverSpec extends ObjectBehavior
$request->isMethod('POST')->willReturn(true);
$request->get('id')->willReturn(5);
$productRepository->findOneBy(['id' => 5, 'channel' => null])->willReturn(null);
$productRepository->findOneBy(array('id' => 5, 'channel' => null))->willReturn(null);
$this
->shouldThrow('Sylius\Component\Cart\Resolver\ItemResolvingException')

View file

@ -27,10 +27,11 @@ class LoadChannelsData extends DataFixture
*/
public function load(ObjectManager $manager)
{
$manager->persist($this->createChannel('WEB-UK', 'UK Webstore', array('en_GB'), array('GBP'), array('DHL', 'UPS Ground'), array('Dummy', 'Stripe')));
$manager->persist($this->createChannel('WEB-DE', 'Germany Webstore', array('de_DE'), array('EUR'), array('DHL', 'UPS Ground'), array('Dummy', 'Stripe')));
$manager->persist($this->createChannel('WEB-US', 'United States Webstore', array('en_US'), array('USD'), array('FedEx', 'FedEx World Shipping'), array('Dummy', 'Stripe')));
$manager->persist($this->createChannel('MOBILE', 'Mobile Store', array('en_GB', 'de_DE'), array('GBP', 'USD', 'EUR'), array('DHL', 'UPS Ground', 'FedEx'), array('Dummy', 'Stripe')));
$url = $this->container->getParameter('router.request_context.host');
$manager->persist($this->createChannel('WEB-UK', 'UK Webstore', $url, array('en_GB'), array('GBP'), array('DHL', 'UPS Ground'), array('Dummy', 'Stripe')));
$manager->persist($this->createChannel('WEB-DE', 'Germany Webstore', null, array('de_DE'), array('EUR'), array('DHL', 'UPS Ground'), array('Dummy', 'Stripe')));
$manager->persist($this->createChannel('WEB-US', 'United States Webstore', null, array('en_US'), array('USD'), array('FedEx', 'FedEx World Shipping'), array('Dummy', 'Stripe')));
$manager->persist($this->createChannel('MOBILE', 'Mobile Store', null, array('en_GB', 'de_DE'), array('GBP', 'USD', 'EUR'), array('DHL', 'UPS Ground', 'FedEx'), array('Dummy', 'Stripe')));
$manager->flush();
}
@ -52,9 +53,11 @@ class LoadChannelsData extends DataFixture
*
* @return ChannelInterface
*/
protected function createChannel($code, $name, array $locales = array(), array $currencies = array(), array $shippingMethods = array(), array $paymentMethods = array())
protected function createChannel($code, $name, $url, array $locales = array(), array $currencies = array(), array $shippingMethods = array(), array $paymentMethods = array())
{
/** @var ChannelInterface $channel */
$channel = $this->getChannelRepository()->createNew();
$channel->setUrl($url);
$channel->setCode($code);
$channel->setName($name);
$channel->setColor($this->faker->randomElement(array('Red', 'Green', 'Blue', 'Orange', 'Pink')));

View file

@ -29,6 +29,7 @@ class MoneyContext extends DefaultContext
}
$manager->flush();
$manager->clear();
foreach ($table->getHash() as $data) {
$this->thereIsCurrency($data['code'], $data['exchange rate'], 'yes' === $data['enabled'], false);

View file

@ -74,7 +74,7 @@ class OrmFinder extends AbstractFinder
$channel = $this->channelContext->getChannel();
// First get ALL products from the taxon to get their ids
$paginator = $this->productRepository->createByTaxonPaginator($query->getTaxon(), array('channel' => $channel));
$paginator = $this->productRepository->createByTaxonPaginator($query->getTaxon(), array('channels' => $channel));
$ids = array();
$pages = $paginator->getNbPages();
@ -112,7 +112,7 @@ class OrmFinder extends AbstractFinder
$this->facets = $this->calculateNewFacets($facetsArray, $facetFilteredIds);
}
$this->paginator = $this->productRepository->createByTaxonPaginator($query->getTaxon(), array('id' => $idsFromAllFacets, 'channel' => $channel));
$this->paginator = $this->productRepository->createByTaxonPaginator($query->getTaxon(), array('id' => $idsFromAllFacets, 'channels' => $channel));
$this->filters = $query->getAppliedFilters();
return $this;