Add taxonomies management to the backend

This commit is contained in:
Paweł Jędrzejewski 2013-02-14 22:03:38 +01:00
parent 22ce41389e
commit 1c066399b7
6 changed files with 771 additions and 511 deletions

View file

@ -41,12 +41,14 @@
},
"scripts": {
"post-install-cmd": [
"Sylius\\Bundle\\CoreBundle\\Composer\\ScriptHandler::installParametersFile",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::buildBootstrap",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::clearCache",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installAssets",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installRequirementsFile"
],
"post-update-cmd": [
"Sylius\\Bundle\\CoreBundle\\Composer\\ScriptHandler::installParametersFile",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::buildBootstrap",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::clearCache",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installAssets",

1087
composer.lock generated

File diff suppressed because it is too large Load diff

View file

@ -59,6 +59,69 @@ class DataContext extends BehatContext implements KernelAwareInterface
$this->kernel = $kernel;
}
/**
* @Given /^there are following taxonomies defined:$/
*/
public function thereAreFollowingTaxonomies(TableNode $table)
{
$manager = $this->getEntityManager();
foreach ($table->getHash() as $data) {
$this->thereIsTaxonomy($data['name']);
}
}
/**
* @Given /^I created taxonomy "([^""]*)"$/
*/
public function thereIsTaxonomy($name)
{
$taxonomy = $this->getRepository('taxonomy')->createNew();
$taxonomy->setName($name);
$this->getEntityManager()->persist($taxonomy);
$this->getEntityManager()->flush();
}
/**
* @Given /^taxonomy "([^""]*)" has following taxons:$/
*/
public function taxonomyHasFollowingTaxons($taxonomyName, TableNode $taxonsTable)
{
$taxonomy = $this->findOneByName('taxonomy', $taxonomyName);
$manager = $this->getEntityManager();
$taxons = array();
foreach ($taxonsTable->getRows() as $node) {
$taxonList = explode('>', $node[0]);
$parent = null;
foreach ($taxonList as $taxonName) {
$taxonName = trim($taxonName);
if (!isset($taxons[$taxonName])) {
$taxon = $this->getRepository('taxon')->createNew();
$taxon->setTaxonomy($taxonomy);
$taxon->setName($taxonName);
if (null !== $parent) {
$taxon->setParent($parent);
}
$manager->persist($taxon);
$manager->flush($taxon);
$taxons[$taxonName] = $taxon;
$parent = $taxon;
}
}
}
$manager->flush();
}
/**
* @Given /^there are following users:$/
*/

126
features/taxonomies.feature Normal file
View file

@ -0,0 +1,126 @@
Feature: taxonomies
In order to categorize my merchandise
As a store owner
I want to be able to manage taxonomies
Background:
Given I am logged in as administrator
And there are following taxonomies defined:
| name |
| Category |
| Brand |
And taxonomy "Category" has following taxons:
| Electronics > PC |
| Electronics > Mac > iMac |
| Electronics > Mac > MBP |
| Clothing > Gloves |
| Clothing > Hats |
Scenario: Seeing index of all taxonomies
Given I am on the dashboard page
When I follow "Categorization"
Then I should be on the taxonomy index page
And I should see 2 taxonomies in the list
Scenario: Seeing empty index of taxonomies
Given there are no taxonomies
When I go to the taxonomy index page
Then I should see "There are no taxonomies defined"
Scenario: Accessing the taxonomy creation form
Given I am on the dashboard page
When I follow "Categorization"
And I follow "Create taxonomy"
Then I should be on the taxonomy creation page
Scenario: Submitting form without specifying the name
Given I am on the taxonomy creation page
When I press "Create"
Then I should still be on the taxonomy creation page
And I should see "Please enter taxonomy name"
Scenario: Creating new taxonomy
Given I am on the taxonomy creation page
When I fill in "Name" with "Vendor"
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"
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
Scenario: Accessing the editing form from the list
Given I am on the taxonomy index page
When I click "edit" near "Category"
Then I should be editing taxonomy "Category"
Scenario: Updating the taxonomy
Given I am editing taxonomy "Brand"
When I fill in "Name" with "Brands"
And I press "Save changes"
Then I should be on the page of taxonomy "Brands"
And I should see "Taxonomy has been successfully updated."
Scenario: Deleting taxonomy
Given I am on the taxonomy index page
When I click "delete" near "Brand"
Then I should be on the taxonomy index page
And I should see "Taxonomy has been successfully deleted."
Scenario: Deleted taxonomy disappears from the list
Given I am on the taxonomy index page
When I click "delete" near "Category"
Then I should be on the taxonomy index page
And I should not see taxonomy with name "Category" in that list
Scenario: Accessing taxonomy tree via the list
Given I am on the taxonomy index page
When I click "details" near "Category"
Then I should be on the page of taxonomy "Category"
Scenario: Seeing index of all taxonomy taxons
Given I am on the taxonomy index page
When I click "details" near "Category"
Then I should be on the page of taxonomy "Category"
And I should see 8 taxons in the list
Scenario: Creating new taxon under given taxonomy
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 be on the page of taxonomy "Category"
And I should see "Taxon has been successfully created."
Scenario: Creating new taxon with parent
Given I am on the page of taxonomy "Category"
And I follow "Create taxon"
When I fill in "Name" with "iPods"
And I select "Electronics" from "Parent"
And I press "Create"
Then I should be on the page of taxonomy "Category"
And I should see "Taxon has been successfully created."
Scenario: Renaming the taxon
Given I am on the page of taxonomy "Category"
And I click "edit" near "Clothing"
When I fill in "Name" with "Clothing and accessories"
And I press "Save changes"
Then I should be on the page of taxonomy "Category"
And I should see "Taxon has been successfully updated."
Scenario: Deleting taxons
Given I am on the page of taxonomy "Category"
When I click "delete" near "Electronics"
Then I should still be on the page of taxonomy "Category"
And I should see "Taxon has been successfully deleted."
Scenario: Deleted taxons disappear from the list
Given I am on the page of taxonomy "Category"
When I click "delete" near "Electronics"
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 4 taxons in the list

View file

@ -38,6 +38,7 @@ class SyliusKernel extends Kernel
new Sylius\Bundle\AddressingBundle\SyliusAddressingBundle(),
new Sylius\Bundle\SalesBundle\SyliusSalesBundle(),
new Sylius\Bundle\InventoryBundle\SyliusInventoryBundle(),
new Sylius\Bundle\TaxonomiesBundle\SyliusTaxonomiesBundle(),
// Core bundles.
new Doctrine\Bundle\DoctrineBundle\DoctrineBundle(),

View file

@ -66,6 +66,9 @@ swiftmailer:
sylius_settings:
driver: doctrine/orm
sylius_taxonomies:
driver: doctrine/orm
sylius_assortment:
driver: doctrine/orm
classes: