From c04ea156c9052de6fff5d17cbd77298f42ce6134 Mon Sep 17 00:00:00 2001 From: marcodebortoli Date: Wed, 8 May 2013 10:22:56 +0100 Subject: [PATCH 1/3] Users are provided with a clear step by step guide to show them how to use BehatMage as intented by its developers --- README.md | 118 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 118 insertions(+) diff --git a/README.md b/README.md index a4b911a..e9be809 100644 --- a/README.md +++ b/README.md @@ -423,6 +423,124 @@ Feature: Admin User can manage review visibility When I turn reviews off for "Ottoman1" product # AdminUserContext::iTurnReviewsOffForProduct() Then no review should be displayed for "Ottoman1" # AdminUserContext::noReviewShouldBeDisplayedFor()## Some more about Behat basics ``` + +As you can see Behat is providing to the developer, thanks to the BehatMage extension, meaningful and useful information about the next step to take in order to implement the required behaviour. So let's add the needed code to make the first requirement of our step pass. Create the following files based on the suggested code: + +```xml + + + + + + 0.1.0 + + + + + + + + + + core_setup + + + BehatMage_Catalog + BehatMage_Catalog_Model_Resource_Entity_Setup + + + + + +``` + +```xml + + + + + + true + local + + + + + + + +``` + +```php +# app/code/local/BehatMage/Catalog/Model/Resource/Entity/Setup.php + +startSetup(); + +$installer->addAttribute('catalog_product', 'accepts_reviews', array( + 'group' => 'General', + 'input' => 'yesno', + 'type' => 'int', + 'label' => 'Accept Reviews', + 'backend' => '', + 'default' => true, + 'visible' => true, + 'required' => true, + 'user_defined' => true, + 'searchable' => false, + 'filterable' => false, + 'comparable' => false, + 'visible_on_front' => true, + 'visible_in_advanced_search' => false, + 'is_html_allowed_on_front' => false, + 'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL, +)); + +$installer->endSetup(); +``` + +Once the files have been created clear the Magento cache in order to run the setup script and add the required attribute. It's now time to run Behat again: + +```bash +$ bin/behat +``` + +If everything is successful your output should now be something like this: + +```bash +Feature: Admin User can manage review visibility + So that our Customers are not influenced by a product with bad review history, + as an Admin User + I want to disable reviews of those specific products + + Scenario: Turn off reviews per product # features/reviews/admin_user_manages_review_visibility.feature:7 + Given the following products exist: # AdminUserContext::theProductsExist() + | sku | name | accepts_reviews | + | Ottoman1 | Ottoman | 1 | + And "Ottoman1" has existing reviews # AdminUserContext::hasExistingReviews() + TODO: write pending definition + When I turn reviews off for "Ottoman1" product # AdminUserContext::iTurnReviewsOffForProduct() + Then no review should be displayed for "Ottoman1" # AdminUserContext::noReviewShouldBeDisplayedFor() + +1 scenario (1 pending) +4 steps (1 passed, 2 skipped, 1 pending) +0m6.478s +``` + +Has you can see now that our product definition has the required attribute Behat moved onto the next step of our scenario. As you can imagine now it's only a matter of implementing, step by step, all the required tests and code to adhere to the previously defined scenario. + ## More about Features ## More about Steps From 6958c362a9dee30b06f4146b5426846b3c892e40 Mon Sep 17 00:00:00 2001 From: marcodebortoli Date: Wed, 8 May 2013 10:25:11 +0100 Subject: [PATCH 2/3] Users are provided with a clear step by step guide to show them how to use BehatMage as intented by its developers --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index e9be809..b27987d 100644 --- a/README.md +++ b/README.md @@ -539,7 +539,7 @@ Feature: Admin User can manage review visibility 0m6.478s ``` -Has you can see now that our product definition has the required attribute Behat moved onto the next step of our scenario. As you can imagine now it's only a matter of implementing, step by step, all the required tests and code to adhere to the previously defined scenario. +As you can see now that our product definition has the required attribute Behat moved onto the next step of our scenario. As you can imagine now it's only a matter of implementing, step by step, all the required tests and code to adhere to the previously defined scenario. ## More about Features ## More about Steps From 550b49ff0b8b8defe7f7d31c2829b0b131f16a39 Mon Sep 17 00:00:00 2001 From: marcodebortoli Date: Wed, 8 May 2013 10:26:38 +0100 Subject: [PATCH 3/3] Users are provided with a clear step by step guide to show them how to use BehatMage as intented by its developers --- README.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index b27987d..15c4016 100644 --- a/README.md +++ b/README.md @@ -542,11 +542,12 @@ Feature: Admin User can manage review visibility As you can see now that our product definition has the required attribute Behat moved onto the next step of our scenario. As you can imagine now it's only a matter of implementing, step by step, all the required tests and code to adhere to the previously defined scenario. ## More about Features + ## More about Steps -## The Context Class: FeatureContext +## The Context Class: MagentoContext -## The behat Command Line Tool +## The BehatMage Command Line Tool ## What’s Next?