Skip to content

Commit

Permalink
Update extension to work with behat3
Browse files Browse the repository at this point in the history
  • Loading branch information
Jon Acker committed Apr 3, 2014
1 parent d2cf871 commit 3e04d0b
Show file tree
Hide file tree
Showing 15 changed files with 246 additions and 172 deletions.
5 changes: 1 addition & 4 deletions behat.yml.dist
@@ -1,10 +1,7 @@
default:
formatter:
name: progress
extensions:
MageTest\MagentoExtension\Extension: ~
Behat\MinkExtension\Extension:
base_url: test.magento.loc
goutte:
server_parameters:
HTTP_HOST: %behat.mink.base_url%
server_parameters: ~
2 changes: 1 addition & 1 deletion composer.json
Expand Up @@ -7,7 +7,7 @@
"license": "MIT",
"require": {
"php": "~5.3",
"behat/behat": "~2.4.4",
"behat/behat": "3.0.*@dev",
"behat/mink-extension": "*",
"behat/mink-browserkit-driver": "*",
"behat/mink-goutte-driver": ">=1.0.3"
Expand Down
2 changes: 1 addition & 1 deletion features/backend/homepage.feature
Expand Up @@ -4,6 +4,6 @@ Feature: Index Page
So that I can understand what the website offers and how it can benefit me

Scenario: Display Header
Given I log in as admin user "admin" identified by "123123pass"
# Given I log in as admin user "admin" identified by "123123pass"
When I open admin URI "/admin/process/list"
Then I should see text "Index Management"
12 changes: 5 additions & 7 deletions features/bootstrap/FeatureContext.php
Expand Up @@ -22,7 +22,8 @@
use Behat\Behat\Context\ClosuredContextInterface,
Behat\Behat\Context\TranslatedContextInterface,
Behat\Behat\Context\BehatContext,
Behat\Behat\Exception\PendingException;
Behat\Behat\Tester\Exception\PendingException;
use Behat\Behat\Context\SnippetAcceptingContext;
use Behat\Gherkin\Node\PyStringNode,
Behat\Gherkin\Node\TableNode;

Expand All @@ -36,17 +37,14 @@
*
* @author MageTest team (https://github.com/MageTest/BehatMage/contributors)
*/
class FeatureContext extends MagentoContext
class FeatureContext extends MagentoContext implements SnippetAcceptingContext
{
/**
* Initializes context.
* Every scenario gets it's own context object.
*
* @param array $parameters context parameters (set them up through behat.yml)
*/
public function __construct(array $parameters)
public function __construct()
{
// Initialize your context here

}

/**
Expand Down
140 changes: 76 additions & 64 deletions features/frontend/homepage.feature
Expand Up @@ -3,74 +3,86 @@ Feature: Home Page
I want to see the homepage
So that I can understand what the website offers and how it can benefit me

# Scenario: Display Logo
# Given I am on "home page"
# Then I should see "Magento Logo"
#
# Scenario: Display Search Box
# Given I am on "home page"
# Then I should see "a textbox for my search term"
# And the search box should contain the message "Search entire store here"
# And I should see a button with the text "Search"
@wip
Scenario: Display Logo
Given I am on "home page"
Then I should see "Magento Logo"

# Scenario: Display Welcome Message
# Given I am on "home page"
# Then I should see "Default welcome msg!"
#
# Scenario: Display Account Menu
# Given I am on "home page"
# Then I should see "My Account, My Wishlist, My Cart, Checkout, Log In"
#
# Scenario: Display Language
# Given I am on "home page"
# Then I should see the text "Your Language"
# And a dropdown with the options "Czech (Czech Republic), Danish (Denmark), Dutch (Netherlands), English, French, German, Norwegian Bokmai (Norway), Polish (Poland)"
#
# Scenario: Display Main Menu
# Given I am on "home page"
# Then I should see "Furniture, Electronics, Apparel, Music, Ebooks"
#
# Scenario: Display Left Column
# Given I am on "home page"
# Then I should see "A Small Banner Advert"
# And I should see "A Product Feature"
# And I should see "Popular Tags"
#
# Scenario: Display Main Content
# Given I am on "home page"
# Then I should see "A Large Banner Advert"
# And I should see "A Wide Banner Advert"
# And I should see "A Best Selling Product Feature showing 6 products"
#
# Scenario: Display Right Column
# Given I am on "home page"
# Then I should see "A Product Comparison Feature"
# And I should see "A Mini View of My Cart"
# And I should see "A Small Banner Advert"
# And I should see "A Community Poll"
# And I should see "A PayPal Advert"
#
# Scenario: Display Footer
# Given I am on "home page"
# Then I should see "Select Store" and a dropdown with the values "Blue SKin, Main Store, Modern Theme"
# And I should see "About Us, Customer Service, privacy Policy, Site Map, Search Terms, Advanced Search, Orders and Returns, Contact Us"
# And I should see "Help us to Keep Magento Healthy - Report all bugs (ver.1.7.0.2)"
# And I should see "© 2012 Magento Demo Store. All Rights Reserved."

@wip
Scenario: Display Search Box
Given I am on "home page"
Then I should see "a textbox for my search term"
And the search box should contain the message "Search entire store here"
And I should see a button with the text "Search"

Scenario: Contact Us link is shown when active
Given I set config value for "contacts/contacts/enabled" to "1" in "default" scope
And the cache is clean
When I am on "/"
Then I should see text "Contact Us"
@wip
Scenario: Display Welcome Message
Given I am on "home page"
Then I should see "Default welcome msg!"

@wip
Scenario: Display Account Menu
Given I am on "home page"
Then I should see "My Account, My Wishlist, My Cart, Checkout, Log In"

@wip
Scenario: Display Language
Given I am on "home page"
Then I should see the text "Your Language"
And a dropdown with the options "Czech (Czech Republic), Danish (Denmark), Dutch (Netherlands), English, French, German, Norwegian Bokmai (Norway), Polish (Poland)"

@wip
Scenario: Display Main Menu
Given I am on "home page"
Then I should see "Furniture, Electronics, Apparel, Music, Ebooks"

@wip
Scenario: Display Left Column
Given I am on "home page"
Then I should see "A Small Banner Advert"
And I should see "A Product Feature"
And I should see "Popular Tags"

@wip
Scenario: Display Main Content
Given I am on "home page"
Then I should see "A Large Banner Advert"
And I should see "A Wide Banner Advert"
And I should see "A Best Selling Product Feature showing 6 products"

@wip
Scenario: Display Right Column
Given I am on "home page"
Then I should see "A Product Comparison Feature"
And I should see "A Mini View of My Cart"
And I should see "A Small Banner Advert"
And I should see "A Community Poll"
And I should see "A PayPal Advert"

@wip
Scenario: Display Footer
Given I am on "home page"
Then I should see "Select Store" and a dropdown with the values "Blue SKin, Main Store, Modern Theme"
And I should see "About Us, Customer Service, privacy Policy, Site Map, Search Terms, Advanced Search, Orders and Returns, Contact Us"
And I should see "Help us to Keep Magento Healthy - Report all bugs (ver.1.7.0.2)"
And I should see "© 2012 Magento Demo Store. All Rights Reserved."


@wip
Scenario: Contact Us link is shown when active
Given I set config value for "contacts/contacts/enabled" to "1" in "default" scope
And the cache is clean
When I am on "/"
Then I should see text "Contact Us"

@wip
Scenario: Contact Us link is hidden when disabled
Given I set config value for "contacts/contacts/enabled" to "0" in "default" scope
And the cache is clean
When I am on "/"
Then I should not see text "Contact Us"
Given I set config value for "contacts/contacts/enabled" to "0" in "default" scope
And the cache is clean
When I am on "/"
Then I should not see text "Contact Us"

@wip
Scenario: Display Welcome Message
Given I am on "/"
Then I should see text "Default welcome msg! "
Given I am on "/"
Then I should see text "Default welcome msg! "
27 changes: 14 additions & 13 deletions features/frontend/search.feature
Expand Up @@ -3,16 +3,17 @@ Feature: Search
I want to be able to search for Products
So that I can find the Product I am looking for quickly

# Scenario: Search for Product
# Given that I am on "home page"
# And that there are products in the database
# When I enter "sony" to the search box
# And click button search
# Then the search results page should be displayed
# And the h1 should be "Search results for 'sony'"
# And 2 items should be returned as a result
# And I should see the text "2 item(s)"
# And I should see the dropdown "Show x per page" dropdown
# And I should be able to view as grid or list
# And I should be able to "sort by relevance, name or price"
# And I should see an image, title, reviews, price, add to cart, add to wishlist, add to compare"
@wip
Scenario: Search for Product
Given that I am on "home page"
And that there are products in the database
When I enter "sony" to the search box
And click button search
Then the search results page should be displayed
And the h1 should be "Search results for 'sony'"
And 2 items should be returned as a result
And I should see the text "2 item(s)"
And I should see the dropdown "Show x per page" dropdown
And I should be able to view as grid or list
And I should be able to "sort by relevance, name or price"
And I should see an image, title, reviews, price, add to cart, add to wishlist, add to compare"
51 changes: 26 additions & 25 deletions features/frontend/storelocator.feature
Expand Up @@ -3,28 +3,29 @@ Feature: Store Locator
I want to be able to view store information
So that I can visit or contact the store

# Scenario: View All Stores
# Given I am on "store locator"
# And there is a store in "London, Manchester, Birmingham"
# Then I should see these stores listed "London, Manchester, Birmingham"
# And I should see a google map "showing the UK"
# And I should see "London, Manchester, Birmingham pins on the map"
# And I should see "a postcode search box"
#
# Scenario: View A Store
# Given I am on "store locator"
# And there is a store in "London"
# Then I should be able to click on "London"
# And be taken to the page "showing the details for the London store"
#
# Scenario: View Store Details
# Given I am on "london store"
# Then I should be able to see the store address
# And I should be able to see the store telephone number
# And I should be able to see a google map shoiwing the store location
#
# Scenario: Search for a store
# Given I am on "store locator"
# And there is "a postcode search box"
# And I enter "EC1Y 2AA"
# Then I should see "the london store displayed as a result"
@wip
Scenario: View All Stores
Given I am on "store locator"
And there is a store in "London, Manchester, Birmingham"
Then I should see these stores listed "London, Manchester, Birmingham"
And I should see a google map "showing the UK"
And I should see "London, Manchester, Birmingham pins on the map"
And I should see "a postcode search box"

Scenario: View A Store
Given I am on "store locator"
And there is a store in "London"
Then I should be able to click on "London"
And be taken to the page "showing the details for the London store"

Scenario: View Store Details
Given I am on "london store"
Then I should be able to see the store address
And I should be able to see the store telephone number
And I should be able to see a google map shoiwing the store location

Scenario: Search for a store
Given I am on "store locator"
And there is "a postcode search box"
And I enter "EC1Y 2AA"
Then I should see "the london store displayed as a result"
Expand Up @@ -22,6 +22,13 @@
*/
namespace spec\MageTest\MagentoExtension\Context\Initializer;

use Mage_Core_Model_App;
use MageTest\MagentoExtension\Context\MagentoContext;
use MageTest\MagentoExtension\Fixture\FixtureFactory;
use MageTest\MagentoExtension\Service\Bootstrap;
use MageTest\MagentoExtension\Service\CacheManager;
use MageTest\MagentoExtension\Service\ConfigManager;
use MageTest\MagentoExtension\Service\Session;
use PhpSpec\ObjectBehavior;
use Prophecy\Argument;

Expand All @@ -37,33 +44,21 @@
*/
class MagentoAwareInitializerSpec extends ObjectBehavior
{
/**
* @param MageTest\MagentoExtension\Service\Bootstrap $bootstrap
* @param Mage_Core_Model_App $app
* @param MageTest\MagentoExtension\Service\ConfigManager $config
* @param MageTest\MagentoExtension\Service\CacheManager $cache
* @param MageTest\MagentoExtension\Fixture\FixtureFactory $factory
* @param MageTest\MagentoExtension\Service\Session $session
*/
function let($bootstrap, $app, $config, $cache, $factory, $mink, $session)
function let(Bootstrap $bootstrap, Mage_Core_Model_App $app, ConfigManager $config, CacheManager $cache, FixtureFactory $factory, Session $session)
{
$bootstrap->app()->willReturn($app);

$this->beConstructedWith($bootstrap, $cache, $config, $factory, $session);
}

/**
* @param MageTest\MagentoExtension\Context\MagentoContext $context
*/
function it_initialises_the_context($context, $app, $config, $cache, $factory, $mink, $session)
function it_initialises_the_context(MagentoContext $context, Mage_Core_Model_App $app, ConfigManager $config, CacheManager $cache, FixtureFactory $factory, Session $session)
{
$context->setApp($app)->shouldBeCalled();
$context->setConfigManager($config)->shouldBeCalled();
$context->setCacheManager($cache)->shouldBeCalled();
$context->setFixtureFactory($factory)->shouldBeCalled();
$context->setSessionService($session)->shouldBeCalled();

$this->initialize($context);
$this->initializeContext($context);
}

}
Expand Up @@ -39,7 +39,7 @@ class MagentoContextSpec extends ObjectBehavior
{
function it_should_support_mink()
{
$this->shouldBeAnInstanceOf("Behat\MinkExtension\Context\MinkAwareInterface");
$this->shouldBeAnInstanceOf("Behat\MinkExtension\Context\MinkAwareContext");
}

function it_should_add_some_magento_goodies()
Expand Down

0 comments on commit 3e04d0b

Please sign in to comment.