mirror of
https://github.com/Sylius/Sylius.git
synced 2026-07-14 17:10:53 +00:00
[Taxonomy] Introduce code for taxon
[TaxonomyBundle] Add AddCodeFormSubscriber to TaxonType and TaxonomyType
This commit is contained in:
parent
88d8feb9c8
commit
b4929c9026
55 changed files with 355 additions and 163 deletions
36
app/migrations/Version20151216125201.php
Normal file
36
app/migrations/Version20151216125201.php
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
<?php
|
||||
|
||||
namespace Sylius\Migrations;
|
||||
|
||||
use Doctrine\DBAL\Migrations\AbstractMigration;
|
||||
use Doctrine\DBAL\Schema\Schema;
|
||||
|
||||
/**
|
||||
* Auto-generated Migration: Please modify to your needs!
|
||||
*/
|
||||
class Version20151216125201 extends AbstractMigration
|
||||
{
|
||||
/**
|
||||
* @param Schema $schema
|
||||
*/
|
||||
public function up(Schema $schema)
|
||||
{
|
||||
// this up() migration is auto-generated, please modify it to your needs
|
||||
$this->abortIf($this->connection->getDatabasePlatform()->getName() != 'mysql', 'Migration can only be executed safely on \'mysql\'.');
|
||||
|
||||
$this->addSql('ALTER TABLE sylius_taxon ADD code VARCHAR(255) NOT NULL');
|
||||
$this->addSql('CREATE UNIQUE INDEX UNIQ_CFD811CA77153098 ON sylius_taxon (code)');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Schema $schema
|
||||
*/
|
||||
public function down(Schema $schema)
|
||||
{
|
||||
// this down() migration is auto-generated, please modify it to your needs
|
||||
$this->abortIf($this->connection->getDatabasePlatform()->getName() != 'mysql', 'Migration can only be executed safely on \'mysql\'.');
|
||||
|
||||
$this->addSql('DROP INDEX UNIQ_CFD811CA77153098 ON sylius_taxon');
|
||||
$this->addSql('ALTER TABLE sylius_taxon DROP code');
|
||||
}
|
||||
}
|
||||
|
|
@ -7,15 +7,15 @@ Feature: Browsing products by taxonomies
|
|||
Background:
|
||||
Given store has default configuration
|
||||
And there are following taxonomies defined:
|
||||
| name |
|
||||
| Category |
|
||||
| Special |
|
||||
| code | name |
|
||||
| TRX1 | Category |
|
||||
| TRX2 | Special |
|
||||
And taxonomy "Category" has following taxons:
|
||||
| Clothing > T-Shirts |
|
||||
| Clothing > Shorts |
|
||||
| Clothing[TX1] > T-Shirts[TX2] |
|
||||
| Clothing[TX1] > Shorts[TX3] |
|
||||
And taxonomy "Special" has following taxons:
|
||||
| Featured |
|
||||
| New |
|
||||
| Featured[TX4] |
|
||||
| New[TX5] |
|
||||
And the following products exist:
|
||||
| name | price | taxons |
|
||||
| Super T-Shirt | 19.99 | T-Shirts |
|
||||
|
|
|
|||
|
|
@ -29,15 +29,15 @@ Feature: Products
|
|||
| TC2 | Electronics |
|
||||
| TC3 | Print |
|
||||
And there are following taxonomies defined:
|
||||
| name |
|
||||
| Category |
|
||||
| Special |
|
||||
| code | name |
|
||||
| RTX1 | Category |
|
||||
| RTX2 | Special |
|
||||
And taxonomy "Category" has following taxons:
|
||||
| Clothing > T-Shirts |
|
||||
| Clothing > Premium T-Shirts |
|
||||
| Clothing[TX1] > T-Shirts[TX2] |
|
||||
| Clothing[TX1] > Premium T-Shirts[TX3] |
|
||||
And taxonomy "Special" has following taxons:
|
||||
| Featured |
|
||||
| New |
|
||||
| Featured[TX4] |
|
||||
| New[TX5] |
|
||||
And product "Sticker" has main taxon "New"
|
||||
And I am logged in as administrator
|
||||
|
||||
|
|
|
|||
|
|
@ -7,12 +7,12 @@ Feature: Orm indexer event listener
|
|||
Background:
|
||||
Given store has default configuration
|
||||
And there are following taxonomies defined:
|
||||
| name |
|
||||
| Category |
|
||||
| code | name |
|
||||
| TRX1 | Category |
|
||||
And taxonomy "Category" has following taxons:
|
||||
| Clothing > T-Shirts |
|
||||
| Clothing > PHP T-Shirts |
|
||||
| Clothing > Gloves |
|
||||
| Clothing[TX1] > T-Shirts[TX2] |
|
||||
| Clothing[TX1] > PHP T-Shirts[TX3] |
|
||||
| Clothing[TX1] > Gloves[TX4] |
|
||||
And the following products exist:
|
||||
| name | price | taxons | description |
|
||||
| Super T-Shirt | 19.99 | T-Shirts | super black t-shirt |
|
||||
|
|
|
|||
|
|
@ -7,15 +7,15 @@ Feature: taxonomies
|
|||
Background:
|
||||
Given store has default configuration
|
||||
And there are following taxonomies defined:
|
||||
| name |
|
||||
| Category |
|
||||
| Brand |
|
||||
| code | name |
|
||||
| RTX1 | Category |
|
||||
| RTX2 | Brand |
|
||||
And taxonomy "Category" has following taxons:
|
||||
| Electronics > Featured |
|
||||
| Electronics > Mac > iMac |
|
||||
| Electronics > Mac > MBP |
|
||||
| Clothing > Gloves |
|
||||
| Clothing > Hats |
|
||||
| Electronics[TX1] > Featured[TX3] |
|
||||
| Electronics[TX1] > Mac[TX4] > iMac[TX5] |
|
||||
| Electronics[TX1] > Mac[TX4] > MBP[TX6] |
|
||||
| Clothing[TX2] > Gloves[TX7] |
|
||||
| Clothing[TX2] > Hats[TX8] |
|
||||
And I am logged in as administrator
|
||||
|
||||
Scenario: Seeing index of all taxonomies
|
||||
|
|
@ -44,12 +44,13 @@ Feature: taxonomies
|
|||
Scenario: Creating new taxonomy
|
||||
Given I am on the taxonomy creation page
|
||||
When I fill in "Name" with "Vendor"
|
||||
And I fill in "Code" with "RTX3"
|
||||
And I press "Create"
|
||||
Then I should be on the page of taxonomy "Vendor"
|
||||
And I should see "Taxonomy has been successfully created."
|
||||
|
||||
Scenario: Created taxonomies appear in the list
|
||||
Given I created taxonomy "Food"
|
||||
Given I created taxonomy "Food" with code "RTX4"
|
||||
When I go to the taxonomy index page
|
||||
Then I should see 3 taxonomies in the list
|
||||
And I should see taxonomy with name "Food" in that list
|
||||
|
|
@ -97,6 +98,7 @@ Feature: taxonomies
|
|||
Given I am on the page of taxonomy "Category"
|
||||
And I follow "Create taxon"
|
||||
When I fill in "Name" with "Cars"
|
||||
And I fill in "Code" with "TX9"
|
||||
And I press "Create"
|
||||
Then I should be on the page of taxonomy "Category"
|
||||
And I should see "Taxon has been successfully created."
|
||||
|
|
@ -112,6 +114,7 @@ Feature: taxonomies
|
|||
Given I am on the page of taxonomy "Category"
|
||||
And I follow "Create taxon"
|
||||
When I fill in "Name" with "Electronics"
|
||||
And I fill in "Code" with "TX9"
|
||||
And I select "Clothing" from "Parent"
|
||||
And I press "Create"
|
||||
Then I should be on the page of taxonomy "Category"
|
||||
|
|
@ -122,6 +125,7 @@ Feature: taxonomies
|
|||
Given I am on the page of taxonomy "Category"
|
||||
And I follow "Create taxon"
|
||||
When I fill in "Name" with "iPods"
|
||||
And I fill in "Code" with "TR9"
|
||||
And I select "Electronics" from "Parent"
|
||||
And I press "Create"
|
||||
Then I should be on the page of taxonomy "Category"
|
||||
|
|
@ -151,3 +155,24 @@ Feature: taxonomies
|
|||
Then I should still be on the page of taxonomy "Category"
|
||||
And "Taxon has been successfully deleted." should appear on the page
|
||||
And I should see 5 taxons in the list
|
||||
|
||||
Scenario: Cannot update taxon code
|
||||
When I am editing taxon "Electronics" from taxonomy "Category"
|
||||
Then the code field should be disabled
|
||||
|
||||
Scenario: Try create taxon with existing code
|
||||
Given I am on the page of taxonomy "Category"
|
||||
And I follow "Create taxon"
|
||||
When I fill in "Name" with "Cars"
|
||||
And I fill in "Code" with "TX1"
|
||||
And I press "Create"
|
||||
Then I should still be on the taxon creation page from taxonomy "Category"
|
||||
And I should see "Taxon with given code already exists."
|
||||
|
||||
Scenario: Try create taxon without code
|
||||
Given I am on the page of taxonomy "Category"
|
||||
And I follow "Create taxon"
|
||||
When I fill in "Name" with "Cars"
|
||||
And I press "Create"
|
||||
Then I should still be on the taxon creation page from taxonomy "Category"
|
||||
And I should see "Please enter taxon code."
|
||||
|
|
|
|||
|
|
@ -11,10 +11,10 @@ Feature: Taxonomies internationalization
|
|||
| en_US |
|
||||
| es_ES |
|
||||
And there are following taxonomies defined:
|
||||
| name |
|
||||
| Category |
|
||||
| code | name |
|
||||
| RTX1 | Category |
|
||||
And taxonomy "Category" has following taxons:
|
||||
| Clothing > Shirts > Long Sleeve |
|
||||
| Clothing[TX1] > Shirts[TX2] > Long Sleeve[TX3] |
|
||||
And the following taxon translations exist:
|
||||
| taxon | name | locale |
|
||||
| Category | Categoria | es_ES |
|
||||
|
|
|
|||
|
|
@ -6,10 +6,10 @@ Feature: Currency selection
|
|||
|
||||
Background:
|
||||
Given there are following taxonomies defined:
|
||||
| name |
|
||||
| Category |
|
||||
| code | name |
|
||||
| RTX1 | Category |
|
||||
And taxonomy "Category" has following taxons:
|
||||
| Clothing > PHP T-Shirts |
|
||||
| Clothing[TX1] > PHP T-Shirts[TX2] |
|
||||
And the following products exist:
|
||||
| name | price | taxons |
|
||||
| PHP Top | 5.99 | PHP T-Shirts |
|
||||
|
|
|
|||
|
|
@ -7,11 +7,11 @@ Feature: Cart
|
|||
Background:
|
||||
Given store has default configuration
|
||||
And there are following taxonomies defined:
|
||||
| name |
|
||||
| Category |
|
||||
| code | name |
|
||||
| RTX1 | Category |
|
||||
And taxonomy "Category" has following taxons:
|
||||
| Clothing > T-Shirts |
|
||||
| Clothing > PHP T-Shirts |
|
||||
| Clothing[TX1] > T-Shirts[TX2] |
|
||||
| Clothing[TX1] > PHP T-Shirts[TX3] |
|
||||
And there are following options:
|
||||
| name | presentation | values |
|
||||
| T-Shirt color | Color | Red, Blue, Green |
|
||||
|
|
|
|||
|
|
@ -7,10 +7,10 @@ Feature: Tax included in price
|
|||
Background:
|
||||
Given store has default configuration
|
||||
And there are following taxonomies defined:
|
||||
| name |
|
||||
| Category |
|
||||
| code | name |
|
||||
| RTX1 | Category |
|
||||
And taxonomy "Category" has following taxons:
|
||||
| Clothing > PHP T-Shirts |
|
||||
| Clothing[TX1] > PHP T-Shirts[TX2] |
|
||||
And the following zones are defined:
|
||||
| name | type | members |
|
||||
| Germany | country | Germany |
|
||||
|
|
|
|||
|
|
@ -10,10 +10,10 @@ Feature: Cart
|
|||
| email | password | enabled |
|
||||
| bar@foo.com | foo1 | yes |
|
||||
And there are following taxonomies defined:
|
||||
| name |
|
||||
| Category |
|
||||
| code | name |
|
||||
| RTX1 | Category |
|
||||
And taxonomy "Category" has following taxons:
|
||||
| Clothing > PHP T-Shirts |
|
||||
| Clothing[TX1] > PHP T-Shirts[TX2] |
|
||||
And the following products exist:
|
||||
| name | price | taxons |
|
||||
| PHP Top | 85 | PHP T-Shirts |
|
||||
|
|
|
|||
|
|
@ -18,10 +18,10 @@ Feature: Checkout promotions with multiple rules and actions
|
|||
| Fixed discount | Amount: 20 |
|
||||
| Percentage discount | Percentage: 5 |
|
||||
And there are following taxonomies defined:
|
||||
| name |
|
||||
| Category |
|
||||
| code | name |
|
||||
| RTX1 | Category |
|
||||
And taxonomy "Category" has following taxons:
|
||||
| Clothing > Debian T-Shirts |
|
||||
| Clothing[TX1] > Debian T-Shirts[TX2] |
|
||||
And the following products exist:
|
||||
| name | price | taxons |
|
||||
| Buzz | 500 | Debian T-Shirts |
|
||||
|
|
|
|||
|
|
@ -29,10 +29,10 @@ Feature: Checkout coupon promotions
|
|||
| code | usage limit | used |
|
||||
| XD0002 | 1 | 1 |
|
||||
And there are following taxonomies defined:
|
||||
| name |
|
||||
| Category |
|
||||
| code | name |
|
||||
| RTX2 | Category |
|
||||
And taxonomy "Category" has following taxons:
|
||||
| Clothing > Debian T-Shirts |
|
||||
| Clothing[TX1] > Debian T-Shirts[TX2] |
|
||||
And the following products exist:
|
||||
| name | price | taxons |
|
||||
| Buzz | 500 | Debian T-Shirts |
|
||||
|
|
|
|||
|
|
@ -21,10 +21,10 @@ Feature: Checkout limited time promotions
|
|||
| type | configuration |
|
||||
| Fixed discount | Amount: 40 |
|
||||
And there are following taxonomies defined:
|
||||
| name |
|
||||
| Category |
|
||||
| code | name |
|
||||
| RTX1 | Category |
|
||||
And taxonomy "Category" has following taxons:
|
||||
| Clothing > Debian T-Shirts |
|
||||
| Clothing[TX1] > Debian T-Shirts[TX2] |
|
||||
And the following products exist:
|
||||
| name | price | taxons |
|
||||
| Buzz | 500 | Debian T-Shirts |
|
||||
|
|
|
|||
|
|
@ -11,11 +11,11 @@ Feature: Checkout fixed discount promotions
|
|||
| Germany |
|
||||
| Poland |
|
||||
And there are following taxonomies defined:
|
||||
| name |
|
||||
| Category |
|
||||
| code | name |
|
||||
| RTX1 | Category |
|
||||
And taxonomy "Category" has following taxons:
|
||||
| Clothing > Ubuntu T-Shirts |
|
||||
| Clothing > Debian T-Shirts |
|
||||
| Clothing[TX1] > Ubuntu T-Shirts[TX2] |
|
||||
| Clothing[TX1] > Debian T-Shirts[TX3] |
|
||||
And the following products exist:
|
||||
| name | price | taxons |
|
||||
| Buzz | 500 | Debian T-Shirts |
|
||||
|
|
|
|||
|
|
@ -23,10 +23,10 @@ Feature: Checkout percentage discount promotions
|
|||
| type | configuration |
|
||||
| Percentage discount | percentage: 10 |
|
||||
And there are following taxonomies defined:
|
||||
| name |
|
||||
| Category |
|
||||
| code | name |
|
||||
| RTX1 | Category |
|
||||
And taxonomy "Category" has following taxons:
|
||||
| Clothing > Debian T-Shirts |
|
||||
| Clothing[TX1] > Debian T-Shirts[TX2] |
|
||||
And the following products exist:
|
||||
| name | price | taxons |
|
||||
| Buzz | 500 | Debian T-Shirts |
|
||||
|
|
|
|||
|
|
@ -23,10 +23,10 @@ Feature: Checkout usage limited promotions
|
|||
| type | configuration |
|
||||
| Percentage discount | Percentage: 100 |
|
||||
And there are following taxonomies defined:
|
||||
| name |
|
||||
| Category |
|
||||
| code | name |
|
||||
| RTX1 | Category |
|
||||
And taxonomy "Category" has following taxons:
|
||||
| Clothing > Debian T-Shirts |
|
||||
| Clothing[TX1] > Debian T-Shirts[TX2] |
|
||||
And the following products exist:
|
||||
| name | price | taxons |
|
||||
| Buzz | 500 | Debian T-Shirts |
|
||||
|
|
|
|||
|
|
@ -7,11 +7,11 @@ Feature: Tax categories
|
|||
Background:
|
||||
Given store has default configuration
|
||||
And there are following taxonomies defined:
|
||||
| name |
|
||||
| Category |
|
||||
| code | name |
|
||||
| RTX1 | Category |
|
||||
And taxonomy "Category" has following taxons:
|
||||
| Clothing > PHP T-Shirts |
|
||||
| Food > Fruits |
|
||||
| Clothing[TX1] > PHP T-Shirts[TX2] |
|
||||
| Food[TX3] > Fruits[TX4] |
|
||||
And the following zones are defined:
|
||||
| name | type | members |
|
||||
| UK | country | United Kingdom |
|
||||
|
|
|
|||
|
|
@ -7,10 +7,10 @@ Feature: Cart taxation
|
|||
Background:
|
||||
Given store has default configuration
|
||||
And there are following taxonomies defined:
|
||||
| name |
|
||||
| Category |
|
||||
| code | name |
|
||||
| RTX1 | Category |
|
||||
And taxonomy "Category" has following taxons:
|
||||
| Clothing > PHP T-Shirts |
|
||||
| Clothing[TX1] > PHP T-Shirts[TX2] |
|
||||
And the following zones are defined:
|
||||
| name | type | members |
|
||||
| UK | country | United Kingdom |
|
||||
|
|
|
|||
|
|
@ -7,10 +7,10 @@ Feature: Checkout addressing
|
|||
Background:
|
||||
Given store has default configuration
|
||||
And there are following taxonomies defined:
|
||||
| name |
|
||||
| Category |
|
||||
| code | name |
|
||||
| RTX1 | Category |
|
||||
And taxonomy "Category" has following taxons:
|
||||
| Clothing > PHP T-Shirts |
|
||||
| Clothing[TX1] > PHP T-Shirts[TX2] |
|
||||
And the following products exist:
|
||||
| name | price | taxons |
|
||||
| PHP Top | 5.99 | PHP T-Shirts |
|
||||
|
|
|
|||
|
|
@ -7,10 +7,10 @@ Feature: Checkout addressing in preferred language
|
|||
Background:
|
||||
Given store has default configuration
|
||||
And there are following taxonomies defined:
|
||||
| name |
|
||||
| Category |
|
||||
| code | name |
|
||||
| RTX1 | Category |
|
||||
And taxonomy "Category" has following taxons:
|
||||
| Clothing > PHP T-Shirts |
|
||||
| Clothing[TX1] > PHP T-Shirts[TX2] |
|
||||
And the following products exist:
|
||||
| name | price | taxons |
|
||||
| PHP Top | 5.99 | PHP T-Shirts |
|
||||
|
|
|
|||
|
|
@ -10,10 +10,10 @@ Feature: Checkout finalization
|
|||
| email | password | enabled |
|
||||
| john@example.com | foo1 | yes |
|
||||
And there are following taxonomies defined:
|
||||
| name |
|
||||
| Category |
|
||||
| code | name |
|
||||
| RTX1 | Category |
|
||||
And taxonomy "Category" has following taxons:
|
||||
| Clothing > PHP T-Shirts |
|
||||
| Clothing[TX1] > PHP T-Shirts[TX2] |
|
||||
And the following products exist:
|
||||
| name | price | taxons |
|
||||
| PHP Top | 5.99 | PHP T-Shirts |
|
||||
|
|
|
|||
|
|
@ -7,10 +7,10 @@ Feature: Checkout inventory
|
|||
Background:
|
||||
Given store has default configuration
|
||||
And there are following taxonomies defined:
|
||||
| name |
|
||||
| Category |
|
||||
| code | name |
|
||||
| RTX1 | Category |
|
||||
And taxonomy "Category" has following taxons:
|
||||
| Clothing > PHP T-Shirts |
|
||||
| Clothing[TX1] > PHP T-Shirts[TX2] |
|
||||
And the following products exist:
|
||||
| name | price | taxons | quantity |
|
||||
| PHP Top | 5.99 | PHP T-Shirts | 14 |
|
||||
|
|
|
|||
|
|
@ -7,10 +7,10 @@ Feature: Checkout Payment
|
|||
Background:
|
||||
Given store has default configuration
|
||||
And there are following taxonomies defined:
|
||||
| name |
|
||||
| Category |
|
||||
| code | name |
|
||||
| RTX1 | Category |
|
||||
And taxonomy "Category" has following taxons:
|
||||
| Clothing > PHP T-Shirts |
|
||||
| Clothing[TX1] > PHP T-Shirts[TX2] |
|
||||
And the following products exist:
|
||||
| name | price | taxons |
|
||||
| PHP Top | 5.99 | PHP T-Shirts |
|
||||
|
|
|
|||
|
|
@ -7,10 +7,10 @@ Feature: Checkout security
|
|||
Background:
|
||||
Given store has default configuration
|
||||
And there are following taxonomies defined:
|
||||
| name |
|
||||
| Category |
|
||||
| code | name |
|
||||
| RTX1 | Category |
|
||||
And taxonomy "Category" has following taxons:
|
||||
| Clothing > PHP T-Shirts |
|
||||
| Clothing[TX1] > PHP T-Shirts[TX2] |
|
||||
And the following products exist:
|
||||
| name | price | taxons |
|
||||
| PHP Top | 5.99 | PHP T-Shirts |
|
||||
|
|
|
|||
|
|
@ -7,10 +7,10 @@ Feature: Checkout shipping
|
|||
Background:
|
||||
Given store has default configuration
|
||||
And there are following taxonomies defined:
|
||||
| name |
|
||||
| Category |
|
||||
| code | name |
|
||||
| RTX1 | Category |
|
||||
And taxonomy "Category" has following taxons:
|
||||
| Clothing > PHP T-Shirts |
|
||||
| Clothing[TX1] > PHP T-Shirts[TX2] |
|
||||
And the following products exist:
|
||||
| name | price | taxons |
|
||||
| PHP Top | 5.99 | PHP T-Shirts |
|
||||
|
|
|
|||
|
|
@ -7,10 +7,10 @@ Feature: Checkout shipping in preferred language
|
|||
Background:
|
||||
Given store has default configuration
|
||||
And there are following taxonomies defined:
|
||||
| name |
|
||||
| Category |
|
||||
| code | name |
|
||||
| RTX1 | Category |
|
||||
And taxonomy "Category" has following taxons:
|
||||
| Clothing > PHP T-Shirts |
|
||||
| Clothing[TX1] > PHP T-Shirts[TX2] |
|
||||
And the following products exist:
|
||||
| name | price | taxons |
|
||||
| PHP Top | 5.99 | PHP T-Shirts |
|
||||
|
|
|
|||
|
|
@ -7,11 +7,11 @@ Feature: Checkout starting
|
|||
Background:
|
||||
Given store has default configuration
|
||||
And there are following taxonomies defined:
|
||||
| name |
|
||||
| Category |
|
||||
| code | name |
|
||||
| RTX1 | Category |
|
||||
And taxonomy "Category" has following taxons:
|
||||
| Clothing > T-Shirts |
|
||||
| Clothing > PHP T-Shirts |
|
||||
| Clothing[TX1] > T-Shirts[TX2] |
|
||||
| Clothing[TX1] > PHP T-Shirts[TX3] |
|
||||
And there are following options:
|
||||
| name | presentation | values |
|
||||
| T-Shirt color | Color | Red, Blue, Green |
|
||||
|
|
|
|||
|
|
@ -7,10 +7,10 @@ Feature: Checkout taxation
|
|||
Background:
|
||||
Given store has default configuration
|
||||
And there are following taxonomies defined:
|
||||
| name |
|
||||
| Category |
|
||||
| code | name |
|
||||
| RTX1 | Category |
|
||||
And taxonomy "Category" has following taxons:
|
||||
| Clothing > PHP T-Shirts |
|
||||
| Clothing[TX1] > PHP T-Shirts[TX2] |
|
||||
And the following zones are defined:
|
||||
| name | type | members |
|
||||
| UK | country | United Kingdom |
|
||||
|
|
|
|||
|
|
@ -7,12 +7,12 @@ Feature: Products
|
|||
Background:
|
||||
Given there is default currency configured
|
||||
And there are following taxonomies defined:
|
||||
| name |
|
||||
| Category |
|
||||
| code | name |
|
||||
| RTX1 | Category |
|
||||
And taxonomy "Category" has following taxons:
|
||||
| Clothing > T-Shirts |
|
||||
| Clothing > PHP T-Shirts |
|
||||
| Clothing > Gloves |
|
||||
| Clothing[TX1] > T-Shirts[TX2] |
|
||||
| Clothing[TX1] > PHP T-Shirts[TX3] |
|
||||
| Clothing[TX1] > Gloves[TX4] |
|
||||
And there are following channels configured:
|
||||
| code | name | currencies | locales | url |
|
||||
| WEB-US | mystore.us | EUR, GBP | en_US | |
|
||||
|
|
|
|||
|
|
@ -7,11 +7,11 @@ Feature: Browse products, categories, attributes and options in preferred langua
|
|||
Background:
|
||||
Given store has default configuration
|
||||
And there are following taxonomies defined:
|
||||
| name |
|
||||
| Category |
|
||||
| code | name |
|
||||
| RTX1 | Category |
|
||||
And taxonomy "Category" has following taxons:
|
||||
| Clothing > T-Shirts |
|
||||
| Clothing > PHP T-Shirts |
|
||||
| Clothing[TX1] > T-Shirts[TX2] |
|
||||
| Clothing[TX1] > PHP T-Shirts[TX3] |
|
||||
And there are following options:
|
||||
| name | presentation | values |
|
||||
| T-Shirt color | Color | Red, Blue, Green |
|
||||
|
|
|
|||
|
|
@ -7,12 +7,13 @@ Feature: Search products
|
|||
Background:
|
||||
Given store has default configuration
|
||||
And there are following taxonomies defined:
|
||||
| name |
|
||||
| Category |
|
||||
| code | name |
|
||||
| RTX1 | Category |
|
||||
|
||||
And taxonomy "Category" has following taxons:
|
||||
| Clothing > T-Shirts |
|
||||
| Clothing > PHP T-Shirts |
|
||||
| Clothing > Gloves |
|
||||
| Clothing[TX1] > T-Shirts[TX2] |
|
||||
| Clothing[TX1] > PHP T-Shirts[TX3] |
|
||||
| Clothing[TX1] > Gloves[TX4] |
|
||||
And the following products exist:
|
||||
| name | price | taxons | description |
|
||||
| Super T-Shirt | 19.99 | T-Shirts | super black t-shirt |
|
||||
|
|
|
|||
|
|
@ -7,10 +7,10 @@ Feature: Group based pricing
|
|||
Background:
|
||||
Given store has default configuration
|
||||
And there are following taxonomies defined:
|
||||
| name |
|
||||
| Category |
|
||||
| code | name |
|
||||
| RTX1 | Category |
|
||||
And taxonomy "Category" has following taxons:
|
||||
| Clothing > PHP T-Shirts |
|
||||
| Clothing[TX1] > PHP T-Shirts[TX2] |
|
||||
And the following zones are defined:
|
||||
| name | type | members |
|
||||
| UK | country | United Kingdom |
|
||||
|
|
|
|||
|
|
@ -7,10 +7,10 @@ Feature: Standard pricing
|
|||
Background:
|
||||
Given store has default configuration
|
||||
And there are following taxonomies defined:
|
||||
| name |
|
||||
| Category |
|
||||
| code | name |
|
||||
| RTX1 | Category |
|
||||
And taxonomy "Category" has following taxons:
|
||||
| Clothing > PHP T-Shirts |
|
||||
| Clothing[TX1] > PHP T-Shirts[TX2] |
|
||||
And the following zones are defined:
|
||||
| name | type | members |
|
||||
| UK | country | United Kingdom |
|
||||
|
|
|
|||
|
|
@ -7,10 +7,10 @@ Feature: Volume based pricing
|
|||
Background:
|
||||
Given store has default configuration
|
||||
And there are following taxonomies defined:
|
||||
| name |
|
||||
| Category |
|
||||
| code | name |
|
||||
| RTX1 | Category |
|
||||
And taxonomy "Category" has following taxons:
|
||||
| Clothing > PHP T-Shirts |
|
||||
| Clothing[TX1] > PHP T-Shirts[TX2] |
|
||||
And the following zones are defined:
|
||||
| name | type | members |
|
||||
| UK | country | United Kingdom |
|
||||
|
|
|
|||
|
|
@ -30,21 +30,21 @@ class LoadTaxonomiesData extends DataFixture
|
|||
public function load(ObjectManager $manager)
|
||||
{
|
||||
$manager->persist($this->createTaxonomy(
|
||||
array($this->defaultLocale => 'Category', 'es_ES' => 'Categoria'),
|
||||
'RTX1', array($this->defaultLocale => 'Category', 'es_ES' => 'Categoria'),
|
||||
array(
|
||||
array($this->defaultLocale => 'T-Shirts', 'es_ES' => 'Camisetas'),
|
||||
array($this->defaultLocale => 'Stickers', 'es_ES' => 'Pegatinas'),
|
||||
array($this->defaultLocale => 'Mugs', 'es_ES' => 'Tazas'),
|
||||
array($this->defaultLocale => 'Books', 'es_ES' => 'Libros'),
|
||||
array('code' => 'TX1', 'locales' => array($this->defaultLocale => 'T-Shirts', 'es_ES' => 'Camisetas')),
|
||||
array('code' => 'TX2', 'locales' => array($this->defaultLocale => 'Stickers', 'es_ES' => 'Pegatinas')),
|
||||
array('code' => 'TX3', 'locales' => array($this->defaultLocale => 'Mugs', 'es_ES' => 'Tazas')),
|
||||
array('code' => 'TX4', 'locales' => array($this->defaultLocale => 'Books', 'es_ES' => 'Libros')),
|
||||
)));
|
||||
|
||||
$manager->persist($this->createTaxonomy(
|
||||
array($this->defaultLocale => 'Brand', 'es_ES' => 'Marca'),
|
||||
'RTX2', array($this->defaultLocale => 'Brand', 'es_ES' => 'Marca'),
|
||||
array(
|
||||
array($this->defaultLocale => 'SuperTees', 'es_ES' => 'SuperCamisetas'),
|
||||
array($this->defaultLocale => 'Stickypicky', 'es_ES' => 'Pegapicky'),
|
||||
array($this->defaultLocale => 'Mugland', 'es_ES' => 'Mundotaza'),
|
||||
array($this->defaultLocale => 'Bookmania', 'es_ES' => 'Libromania'),
|
||||
array('code' => 'TX5', 'locales' => array($this->defaultLocale => 'SuperTees', 'es_ES' => 'SuperCamisetas')),
|
||||
array('code' => 'TX6', 'locales' => array($this->defaultLocale => 'Stickypicky', 'es_ES' => 'Pegapicky')),
|
||||
array('code' => 'TX7', 'locales' => array($this->defaultLocale => 'Mugland', 'es_ES' => 'Mundotaza')),
|
||||
array('code' => 'TX8', 'locales' => array($this->defaultLocale => 'Bookmania', 'es_ES' => 'Libromania')),
|
||||
)));
|
||||
|
||||
$manager->flush();
|
||||
|
|
@ -69,10 +69,11 @@ class LoadTaxonomiesData extends DataFixture
|
|||
*
|
||||
* @return TaxonomyInterface
|
||||
*/
|
||||
protected function createTaxonomy(array $taxonomyName, array $taxonsArray)
|
||||
protected function createTaxonomy($code, array $taxonomyName, array $taxonsArray)
|
||||
{
|
||||
/* @var $taxonomy TaxonomyInterface */
|
||||
$taxonomy = $this->getTaxonomyFactory()->createNew();
|
||||
$taxonomy->getRoot()->setCode($code);
|
||||
|
||||
foreach ($taxonomyName as $locale => $name) {
|
||||
$taxonomy->setCurrentLocale($locale);
|
||||
|
|
@ -87,7 +88,8 @@ class LoadTaxonomiesData extends DataFixture
|
|||
foreach ($taxonsArray as $taxonArray) {
|
||||
/* @var $taxon TaxonInterface */
|
||||
$taxon = $this->getTaxonFactory()->createNew();
|
||||
foreach ($taxonArray as $locale => $taxonName) {
|
||||
$taxon->setCode($taxonArray['code']);
|
||||
foreach ($taxonArray['locales'] as $locale => $taxonName) {
|
||||
$taxon->setCurrentLocale($locale);
|
||||
$taxon->setFallbackLocale($locale);
|
||||
$taxon->setName($taxonName);
|
||||
|
|
|
|||
|
|
@ -470,6 +470,36 @@ class WebContext extends DefaultContext
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @Then /^I should still be on the (.+) page from ([^""]*) "([^""]*)"/
|
||||
*/
|
||||
public function iShouldBeOnThePageWithGivenParent($page, $parentType, $parentName)
|
||||
{
|
||||
$parent = $this->findOneByName($parentType, $parentName);
|
||||
$this->assertSession()->addressEquals($this->generatePageUrl($page, array(sprintf('%sId',$parentType) => $parent->getId())));
|
||||
|
||||
try {
|
||||
$this->assertStatusCodeEquals(200);
|
||||
} catch (UnsupportedDriverActionException $e) {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @Given /^I am (building|viewing|editing) ([^""]*) "([^""]*)" from ([^""]*) "([^""]*)"$/
|
||||
*/
|
||||
public function iAmDoingSomethingWithResourceByNameFromGivenCategory($action, $type, $name, $categoryType, $categoryName)
|
||||
{
|
||||
$type = str_replace(' ','_', $type);
|
||||
$action = str_replace(array_keys($this->actions), array_values($this->actions), $action);
|
||||
|
||||
$root = $this->findOneByName($categoryType, $categoryName);
|
||||
$resource = $this->findOneByName($type, $name);
|
||||
|
||||
$this->getSession()->visit($this->generatePageUrl(
|
||||
sprintf('%s_%s', $type, $action), array('id' => $resource->getId(), sprintf('%sId', $categoryType) => $root->getId())
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* Assert that given code equals the current one.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -23,19 +23,20 @@ class TaxonomyContext extends DefaultContext
|
|||
public function thereAreFollowingTaxonomies(TableNode $table)
|
||||
{
|
||||
foreach ($table->getHash() as $data) {
|
||||
$this->thereIsTaxonomy($data['name'], false);
|
||||
$this->thereIsTaxonomy($data['name'], $data['code'], false);
|
||||
}
|
||||
|
||||
$this->getEntityManager()->flush();
|
||||
}
|
||||
|
||||
/**
|
||||
* @Given /^I created taxonomy "([^""]*)"$/
|
||||
* @Given /^I created taxonomy "([^""]*)" with code "([^""]*)"$/
|
||||
*/
|
||||
public function thereIsTaxonomy($name, $flush = true)
|
||||
public function thereIsTaxonomy($name, $code, $flush = true)
|
||||
{
|
||||
$taxonomy = $this->getFactory('taxonomy')->createNew();
|
||||
$taxonomy->setName($name);
|
||||
$taxonomy->getRoot()->setCode($code);
|
||||
|
||||
if (null === $taxonomy->getCurrentLocale()) {
|
||||
$taxonomy->setCurrentLocale('en_US');
|
||||
|
|
@ -61,18 +62,20 @@ class TaxonomyContext extends DefaultContext
|
|||
$taxonList = explode('>', $node[0]);
|
||||
$parent = null;
|
||||
|
||||
foreach ($taxonList as $taxonName) {
|
||||
$taxonName = trim($taxonName);
|
||||
foreach ($taxonList as $taxon) {
|
||||
$taxon = trim($taxon);
|
||||
$taxonData = preg_split("[\\[|\\]]", $taxon, -1, PREG_SPLIT_NO_EMPTY);
|
||||
|
||||
if (!isset($taxons[$taxonName])) {
|
||||
if (!isset($taxons[$taxonData[0]])) {
|
||||
/* @var $taxon TaxonInterface */
|
||||
$taxon = $this->getFactory('taxon')->createNew();
|
||||
$taxon->setName($taxonName);
|
||||
$taxon->setName($taxonData[0]);
|
||||
$taxon->setCode($taxonData[1]);
|
||||
|
||||
$taxons[$taxonName] = $taxon;
|
||||
$taxons[$taxonData[0]] = $taxon;
|
||||
}
|
||||
|
||||
$taxon = $taxons[$taxonName];
|
||||
$taxon = $taxons[$taxonData[0]];
|
||||
|
||||
if (null !== $parent) {
|
||||
$parent->addChild($taxon);
|
||||
|
|
|
|||
|
|
@ -11,13 +11,12 @@
|
|||
|
||||
namespace Sylius\Bundle\TaxonomyBundle\Form\Type;
|
||||
|
||||
use Sylius\Bundle\ResourceBundle\Form\EventSubscriber\AddCodeFormSubscriber;
|
||||
use Sylius\Bundle\ResourceBundle\Form\Type\AbstractResourceType;
|
||||
use Sylius\Bundle\TaxonomyBundle\Form\EventListener\BuildTaxonFormSubscriber;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
|
||||
/**
|
||||
* Taxon form type.
|
||||
*
|
||||
* @author Paweł Jędrzejewski <pawel@sylius.org>
|
||||
* @author Gonzalo Vilaseca <gvilaseca@reiss.co.uk>
|
||||
*/
|
||||
|
|
@ -33,6 +32,7 @@ class TaxonType extends AbstractResourceType
|
|||
'form_type' => 'sylius_taxon_translation',
|
||||
'label' => 'sylius.form.taxon.name',
|
||||
))
|
||||
->addEventSubscriber(new AddCodeFormSubscriber())
|
||||
->addEventSubscriber(new BuildTaxonFormSubscriber($builder->getFormFactory()))
|
||||
;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@
|
|||
|
||||
namespace Sylius\Bundle\TaxonomyBundle\Form\Type;
|
||||
|
||||
use Sylius\Bundle\ResourceBundle\Form\EventSubscriber\AddCodeFormSubscriber;
|
||||
use Sylius\Bundle\ResourceBundle\Form\Type\AbstractResourceType;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
|
||||
|
|
@ -32,6 +33,7 @@ class TaxonomyType extends AbstractResourceType
|
|||
'form_type' => 'sylius_taxonomy_translation',
|
||||
'label' => 'sylius.form.taxonomy.name',
|
||||
))
|
||||
->addEventSubscriber(new AddCodeFormSubscriber())
|
||||
;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@
|
|||
<order-by>
|
||||
<order-by-field name="left" direction="ASC" />
|
||||
</order-by>
|
||||
<field name="code" column="code" type="string" unique="true"/>
|
||||
<field name="name" column="name" type="string" />
|
||||
<field name="slug" column="slug" type="string" unique="true">
|
||||
<gedmo:slug fields="name" unique="true" />
|
||||
|
|
|
|||
|
|
@ -44,6 +44,7 @@
|
|||
<order-by-field name="left" direction="ASC" />
|
||||
</order-by>
|
||||
|
||||
<field name="code" column="code" type="string" unique="true"/>
|
||||
<field name="left" column="tree_left" type="integer">
|
||||
<gedmo:tree-left />
|
||||
</field>
|
||||
|
|
|
|||
|
|
@ -6,6 +6,9 @@ Sylius\Component\Taxonomy\Model\Taxon:
|
|||
expose: true
|
||||
type: integer
|
||||
xml_attribute: true
|
||||
code:
|
||||
expose: true
|
||||
type: string
|
||||
name:
|
||||
expose: true
|
||||
type: string
|
||||
|
|
|
|||
|
|
@ -40,6 +40,17 @@
|
|||
<property name="translations">
|
||||
<constraint name="Valid" />
|
||||
</property>
|
||||
<constraint name="Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity">
|
||||
<option name="fields">code</option>
|
||||
<option name="message">sylius.taxon.code.unique</option>
|
||||
<option name="groups">sylius</option>
|
||||
</constraint>
|
||||
<property name="code">
|
||||
<constraint name="NotBlank">
|
||||
<option name="message">sylius.taxon.code.not_blank</option>
|
||||
<option name="groups">sylius</option>
|
||||
</constraint>
|
||||
</property>
|
||||
</class>
|
||||
|
||||
<class name="Sylius\Component\Taxonomy\Model\TaxonTranslation">
|
||||
|
|
|
|||
|
|
@ -6,6 +6,9 @@ sylius:
|
|||
name:
|
||||
max_length: Taxon name must not be longer than 255 characters.
|
||||
not_blank: Please enter taxon name.
|
||||
code:
|
||||
unique: Taxon with given code already exists.
|
||||
not_blank: Please enter taxon code.
|
||||
taxonomy:
|
||||
name:
|
||||
max_length: Taxonomy name must not be longer than 255 characters.
|
||||
|
|
|
|||
|
|
@ -13,6 +13,8 @@ namespace spec\Sylius\Bundle\TaxonomyBundle\Form\Type;
|
|||
|
||||
use PhpSpec\ObjectBehavior;
|
||||
use Prophecy\Argument;
|
||||
use Sylius\Bundle\ResourceBundle\Form\EventSubscriber\AddCodeFormSubscriber;
|
||||
use Sylius\Bundle\TaxonomyBundle\Form\EventListener\BuildTaxonFormSubscriber;
|
||||
use Symfony\Component\Form\FormBuilder;
|
||||
use Symfony\Component\Form\FormFactoryInterface;
|
||||
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||
|
|
@ -38,21 +40,25 @@ class TaxonTypeSpec extends ObjectBehavior
|
|||
$this->shouldImplement('Symfony\Component\Form\FormTypeInterface');
|
||||
}
|
||||
|
||||
function it_builds_form_with_proper_fields(
|
||||
FormBuilder $builder,
|
||||
FormFactoryInterface $factory
|
||||
) {
|
||||
function it_builds_form_with_proper_fields(FormBuilder $builder, FormFactoryInterface $factory)
|
||||
{
|
||||
$builder->getFormFactory()->willReturn($factory);
|
||||
|
||||
$builder
|
||||
->addEventSubscriber(
|
||||
Argument::type('Sylius\Bundle\TaxonomyBundle\Form\EventListener\BuildTaxonFormSubscriber')
|
||||
)
|
||||
->addEventSubscriber(Argument::type(BuildTaxonFormSubscriber::class))
|
||||
->shouldBeCalled()
|
||||
->willReturn($builder)
|
||||
;
|
||||
|
||||
$builder
|
||||
->addEventSubscriber(Argument::type(AddCodeFormSubscriber::class))
|
||||
->shouldBeCalled()
|
||||
->willReturn($builder)
|
||||
;
|
||||
|
||||
$builder
|
||||
->add('translations', 'a2lix_translationsForms', Argument::any())
|
||||
->shouldBeCalled()
|
||||
->willReturn($builder)
|
||||
;
|
||||
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@ namespace spec\Sylius\Bundle\TaxonomyBundle\Form\Type;
|
|||
|
||||
use PhpSpec\ObjectBehavior;
|
||||
use Prophecy\Argument;
|
||||
use Sylius\Bundle\ResourceBundle\Form\EventSubscriber\AddCodeFormSubscriber;
|
||||
use Symfony\Component\Form\FormBuilder;
|
||||
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||
|
||||
|
|
@ -41,9 +42,15 @@ class TaxonomyTypeSpec extends ObjectBehavior
|
|||
{
|
||||
$builder
|
||||
->add('translations', 'a2lix_translationsForms', Argument::any())
|
||||
->shouldBeCalled()
|
||||
->willReturn($builder)
|
||||
;
|
||||
|
||||
$builder
|
||||
->addEventSubscriber(Argument::type(AddCodeFormSubscriber::class))
|
||||
->shouldBeCalled()
|
||||
->willReturn($builder);
|
||||
|
||||
$this->buildForm($builder, array());
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
{% form_theme form 'SyliusWebBundle:Backend:forms.html.twig' %}
|
||||
|
||||
<fieldset>
|
||||
{{ form_row(form.code, {'attr': {'class': 'input-lg'}}) }}
|
||||
{{ form_row(form.translations, {'attr': {'class': 'input-lg'}}) }}
|
||||
{{ form_row(form.parent, {'attr': {'class': 'input-lg'} }) }}
|
||||
{{ form_row(form.file) }}
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@
|
|||
<table class="table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>{{ 'sylius.ui.code'|trans }}</th>
|
||||
<th>{{ 'sylius.taxon.name'|trans }}</th>
|
||||
<th></th>
|
||||
</tr>
|
||||
|
|
@ -26,6 +27,9 @@
|
|||
|
||||
{% for taxon in taxons %}
|
||||
<tr id="{{ taxon.id }}">
|
||||
<td>
|
||||
{{ taxon.code }}
|
||||
</td>
|
||||
<td>
|
||||
<span style="border-left: {{ (taxon.level - 1) * 20}}px solid #f1f1f1; padding-left: 10px;">
|
||||
{% if taxon.path|length > 0 %}
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
<fieldset>
|
||||
{{ form_row(form.translations, {'attr': {'class': 'input-lg'}}) }}
|
||||
{{ form_row(form.code) }}
|
||||
{{ form_row(form.file) }}
|
||||
<br>
|
||||
</fieldset>
|
||||
|
|
|
|||
|
|
@ -26,6 +26,11 @@ class Taxon extends AbstractTranslatable implements TaxonInterface
|
|||
*/
|
||||
protected $id;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $code;
|
||||
|
||||
/**
|
||||
* @var TaxonomyInterface
|
||||
*/
|
||||
|
|
@ -83,6 +88,22 @@ class Taxon extends AbstractTranslatable implements TaxonInterface
|
|||
return $this->id;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getCode()
|
||||
{
|
||||
return $this->code;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function setCode($code)
|
||||
{
|
||||
$this->code = $code;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@
|
|||
namespace Sylius\Component\Taxonomy\Model;
|
||||
|
||||
use Doctrine\Common\Collections\Collection;
|
||||
use Sylius\Component\Resource\Model\CodeAwareInterface;
|
||||
use Sylius\Component\Resource\Model\SoftDeletableInterface;
|
||||
use Sylius\Component\Translation\Model\TranslatableInterface;
|
||||
|
||||
|
|
@ -19,7 +20,7 @@ use Sylius\Component\Translation\Model\TranslatableInterface;
|
|||
* @author Paweł Jędrzejewski <pawel@sylius.org>
|
||||
* @author Gonzalo Vilaseca <gvilaseca@reiss.co.uk>
|
||||
*/
|
||||
interface TaxonInterface extends SoftDeletableInterface, TaxonTranslationInterface, TranslatableInterface
|
||||
interface TaxonInterface extends CodeAwareInterface, SoftDeletableInterface, TaxonTranslationInterface, TranslatableInterface
|
||||
{
|
||||
/**
|
||||
* @return TaxonomyInterface
|
||||
|
|
|
|||
|
|
@ -47,6 +47,22 @@ class Taxonomy extends AbstractTranslatable implements TaxonomyInterface
|
|||
return $this->id;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getCode()
|
||||
{
|
||||
return $this->root->getCode();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function setCode($code)
|
||||
{
|
||||
$this->root->setCode($code);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -11,13 +11,14 @@
|
|||
|
||||
namespace Sylius\Component\Taxonomy\Model;
|
||||
|
||||
use Sylius\Component\Resource\Model\CodeAwareInterface;
|
||||
use Sylius\Component\Translation\Model\TranslatableInterface;
|
||||
|
||||
/**
|
||||
* @author Paweł Jędrzejewski <pawel@sylius.org>
|
||||
* @author Gonzalo Vilaseca <gvilaseca@reiss.co.uk>
|
||||
*/
|
||||
interface TaxonomyInterface extends TranslatableInterface, TaxonomyTranslationInterface, TaxonsAwareInterface
|
||||
interface TaxonomyInterface extends CodeAwareInterface, TranslatableInterface, TaxonomyTranslationInterface, TaxonsAwareInterface
|
||||
{
|
||||
/**
|
||||
* @return TaxonInterface
|
||||
|
|
|
|||
|
|
@ -42,6 +42,12 @@ class TaxonSpec extends ObjectBehavior
|
|||
$this->getId()->shouldReturn(null);
|
||||
}
|
||||
|
||||
function it_has_mutable_code()
|
||||
{
|
||||
$this->setCode('TX2');
|
||||
$this->getCode()->shouldReturn('TX2');
|
||||
}
|
||||
|
||||
function it_does_not_belong_to_taxonomy_by_default()
|
||||
{
|
||||
$this->getTaxonomy()->shouldReturn(null);
|
||||
|
|
|
|||
|
|
@ -13,7 +13,6 @@ namespace spec\Sylius\Component\Taxonomy\Model;
|
|||
|
||||
use PhpSpec\ObjectBehavior;
|
||||
use Prophecy\Argument;
|
||||
use Sylius\Component\Taxonomy\Model\Taxon;
|
||||
use Sylius\Component\Taxonomy\Model\TaxonInterface;
|
||||
use Sylius\Component\Taxonomy\Model\TaxonomyTranslation;
|
||||
|
||||
|
|
@ -44,7 +43,7 @@ class TaxonomySpec extends ObjectBehavior
|
|||
$this->getId()->shouldReturn(null);
|
||||
}
|
||||
|
||||
function it_calls_translation_to_string(TaxonomyTranslation $translation, Taxon $root)
|
||||
function it_calls_translation_to_string(TaxonomyTranslation $translation, TaxonInterface $root)
|
||||
{
|
||||
$this->setRoot($root);
|
||||
|
||||
|
|
@ -69,14 +68,14 @@ class TaxonomySpec extends ObjectBehavior
|
|||
$this->getRoot()->shouldReturn($taxon);
|
||||
}
|
||||
|
||||
function it_is_unnamed_by_default(Taxon $root)
|
||||
function it_is_unnamed_by_default(TaxonInterface $root)
|
||||
{
|
||||
$this->setRoot($root);
|
||||
|
||||
$this->getName()->shouldReturn(null);
|
||||
}
|
||||
|
||||
function it_delegates_current_and_fallback_locale_to_root_taxon(Taxon $taxon)
|
||||
function it_delegates_current_and_fallback_locale_to_root_taxon(TaxonInterface $taxon)
|
||||
{
|
||||
$taxon->setCurrentLocale('en_US')->shouldBeCalled();
|
||||
$taxon->setFallbackLocale('en_US')->shouldBeCalled();
|
||||
|
|
@ -88,7 +87,7 @@ class TaxonomySpec extends ObjectBehavior
|
|||
$this->setFallbackLocale('en_US');
|
||||
}
|
||||
|
||||
function its_name_is_mutable(Taxon $taxon)
|
||||
function its_name_is_mutable(TaxonInterface $taxon)
|
||||
{
|
||||
$taxon->setName(null)->shouldBeCalled();
|
||||
$taxon->setName('Brand')->shouldBeCalled();
|
||||
|
|
@ -102,7 +101,7 @@ class TaxonomySpec extends ObjectBehavior
|
|||
$this->getName()->shouldReturn('Brand');
|
||||
}
|
||||
|
||||
function it_also_sets_name_on_the_root_taxon(Taxon $taxon)
|
||||
function it_also_sets_name_on_the_root_taxon(TaxonInterface $taxon)
|
||||
{
|
||||
$taxon->setName(null)->shouldBeCalled();
|
||||
$taxon->setName('Category')->shouldBeCalled();
|
||||
|
|
@ -118,6 +117,17 @@ class TaxonomySpec extends ObjectBehavior
|
|||
$this->setName('Category');
|
||||
}
|
||||
|
||||
function it_sets_code_for_root_taxon(TaxonInterface $taxon)
|
||||
{
|
||||
$this->setRoot($taxon);
|
||||
|
||||
$taxon->setCode('RTX2')->shouldBeCalled();
|
||||
$taxon->getCode()->shouldBeCalled()->willReturn('RTX2');
|
||||
|
||||
$this->setCode('RTX2');
|
||||
$this->getCode()->shouldReturn('RTX2');
|
||||
}
|
||||
|
||||
function it_delegates_the_hasTaxon_method_to_root_taxon(TaxonInterface $root, TaxonInterface $taxon)
|
||||
{
|
||||
$this->setRoot($root);
|
||||
|
|
@ -145,7 +155,7 @@ class TaxonomySpec extends ObjectBehavior
|
|||
$this->removeTaxon($taxon);
|
||||
}
|
||||
|
||||
function it_also_sets_translation_on_root_taxon(Taxon $taxon, TaxonomyTranslation $translation)
|
||||
function it_also_sets_translation_on_root_taxon(TaxonInterface $taxon, TaxonomyTranslation $translation)
|
||||
{
|
||||
$translation->getName()->willReturn('New');
|
||||
$translation->getLocale()->shouldBeCalled();
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue