diff --git a/test/behat.yml b/test/behat.yml index 4c07dd9..7d10611 100644 --- a/test/behat.yml +++ b/test/behat.yml @@ -1,6 +1,22 @@ -paths: - features: %behat.paths.base%/vendo - support: %behat.paths.base%/vendo/support - steps: - - %behat.paths.base%/vendo/steps - - %behat.paths.base%/default/steps \ No newline at end of file +#paths: +# features: %behat.paths.base%/vendo +# support: %behat.paths.base%/vendo/support +# steps: +# - %behat.paths.base%/vendo/steps +# - %behat.paths.base%/default/steps + +default: +# formatter: +# name: progress + environment: + parameters: + start_url: http://vendo/ + + paths: + features: '%%BEHAT_BASE_PATH%%/vendo' + support: '%%BEHAT_BASE_PATH%%/vendo/support' + steps: + - '%%BEHAT_BASE_PATH%%/vendo/steps' + +imports: + - mink/behat.yml \ No newline at end of file diff --git a/test/features/vendo/cart.feature b/test/features/vendo/cart.feature index 59a13ec..ed168f9 100644 --- a/test/features/vendo/cart.feature +++ b/test/features/vendo/cart.feature @@ -6,14 +6,14 @@ Feature: Shopping cart management Given I create a test product Scenario: Add item to cart - Given I am on the test product page - When I click the "Add to cart" link + Given I visit the test product page + When I follow "Add to cart" Then I should see the "Shopping Cart" page And there should be 1 item in my shopping cart Scenario: Remove item to cart - Given I am on the test product page - When I click the "Add to cart" link + Given I visit the test product page + When I follow "Add to cart" Then I should see the "Shopping Cart" page And there should be 1 item in my shopping cart When I check the delete checkbox for "Test Product" @@ -21,8 +21,8 @@ Feature: Shopping cart management Then there should be 0 items in my shopping cart Scenario: Change quantity of item to cart - Given I am on the test product page - When I click the "Add to cart" link + Given I visit the test product page + When I follow "Add to cart" Then I should see the "Shopping Cart" page And there should be 1 item in my shopping cart When I update the quantity of "Test Product" to "2" diff --git a/test/features/vendo/checkout.feature b/test/features/vendo/checkout.feature index fc7be0e..34d9acb 100644 --- a/test/features/vendo/checkout.feature +++ b/test/features/vendo/checkout.feature @@ -5,7 +5,7 @@ Feature: Shopping cart checkout Scenario: Checkout fails with no data Given there are items in my cart When I go to /cart/index - And I click the "Checkout" link + And I follow "Checkout" Then I should see "Checkout goes here" When I press "Submit Order" Then I should see "Checkout goes here" \ No newline at end of file diff --git a/test/features/vendo/core.feature b/test/features/vendo/core.feature new file mode 100644 index 0000000..c4d435f --- /dev/null +++ b/test/features/vendo/core.feature @@ -0,0 +1,10 @@ +@code +Feature: Ensure core classes function properly + +# Scenario: I can read a product's variants +# Given the following product exists: +# | name | price | description | order | +# | Foo | 9.99 | This is a test | 1 | +# And the following variant exists +# | name | price | description | order | +# | Foo - Var | | | | \ No newline at end of file diff --git a/test/features/vendo/steps/cartSteps.php b/test/features/vendo/steps/cartSteps.php index fb9f492..31e1ba9 100644 --- a/test/features/vendo/steps/cartSteps.php +++ b/test/features/vendo/steps/cartSteps.php @@ -1,7 +1,9 @@ And('/^there should be (\d+) item|items in my shopping cart$/', function($world, $num) { - assertTrue(current($world->response->filter('.total_items')->extract(array('_text'))) == $num); + $node = $world->getSession()->getPage()->find('xpath', '//td[@id="total_items"]'); + + assertTrue($node->getText() == $num); }); $steps->Given('/^I create a test product$/', function($world) { @@ -24,23 +26,23 @@ )->delete(); }); -$steps->Given('/^I am on the test product page$/', function($world) { +$steps->Given('/^I visit the test product page$/', function($world) { $product = Model::factory('vendo_product')->load( db::select()->where('name', '=', 'Test Product') ); - $world->visit('/product/view/'.$product->id); + $world->getSession()->visit($world->getPathTo('/product/view/'.$product->id)); }); $steps->When('/^I check the delete checkbox for "([^"]*)"$/', function($world, $product_name) { $product = Model::factory('vendo_product')->load( db::select()->where('name', '=', $product_name) ); - $world->inputFields['delete['.$product->id.']'] = true; + $world->getSession()->getDriver()->check('//input[@name="delete['.$product->id.']"]'); }); $steps->When('/^I update the quantity of "([^"]*)" to "(\d+)"$/', function($world, $product_name, $num) { $product = Model::factory('vendo_product')->load( db::select()->where('name', '=', $product_name) ); - $world->inputFields['new_quantity['.$product->id.']'] = $num; + $world->getSession()->getDriver()->setValue('//input[@name="new_quantity['.$product->id.']"]', $num); }); \ No newline at end of file diff --git a/test/features/vendo/steps/checkoutSteps.php b/test/features/vendo/steps/checkoutSteps.php index da41ff4..7fce38b 100644 --- a/test/features/vendo/steps/checkoutSteps.php +++ b/test/features/vendo/steps/checkoutSteps.php @@ -1,11 +1,16 @@ Given('/^there are items in my cart$/', function($world) { - $world->visit('cart/add?id=105'); - assertTrue($world->response->filter('.total_items')->extract(array('_text')) > 0); + $product = Model::factory('vendo_product')->load( + db::select()->where('name', '=', 'Foobar') + ); + $world->getSession()->visit('/cart/add?id='.$product->id); + $node = $world->getSession()->getPage()->find('xpath', '//td[@id="total_items"]'); + + assertTrue($node->getText() > 0); }); $steps->Then('/^I should see the "(.+)" page$/', function($world, $title) { - $text = $world->response->filter('div#content > h2')->extract(array('_text')); - assertSame(current($text), $title); + $node = $world->getSession()->getPage()->find('xpath', '//div[@id="content"]/h2'); + assertSame($title, $node->getText()); }); \ No newline at end of file diff --git a/test/features/vendo/steps/googleCheckout.php b/test/features/vendo/steps/googleCheckout.php index bfbf635..6c11c4b 100644 --- a/test/features/vendo/steps/googleCheckout.php +++ b/test/features/vendo/steps/googleCheckout.php @@ -48,7 +48,7 @@ } catch (Payment_Exception $e) { - throw new \Everzet\Behat\Exception\Pending('No Internet Connection!'); + throw new \Behat\Behat\Exception\Pending('No Internet Connection!'); } }); diff --git a/test/features/vendo/steps/userSteps.php b/test/features/vendo/steps/userSteps.php index 78e134c..271b7f8 100644 --- a/test/features/vendo/steps/userSteps.php +++ b/test/features/vendo/steps/userSteps.php @@ -10,7 +10,7 @@ $steps->Given('/^I log in$/', function($world) use($steps) { $steps->Given('I am logged out', $world); - $steps->When('I click the "Login" link', $world); + $steps->When('I follow "Login"', $world); $steps->And('I fill in "email" with "test@example.com"', $world); $steps->And('I fill in "password" with "test"', $world); $steps->And('I press "Login"', $world); diff --git a/test/features/vendo/support/bootstrap.php b/test/features/vendo/support/bootstrap.php new file mode 100644 index 0000000..21f2da0 --- /dev/null +++ b/test/features/vendo/support/bootstrap.php @@ -0,0 +1,12 @@ +client = new \Goutte\Client; @@ -37,7 +24,7 @@ } catch (Exception $e) { - var_dump('Couldn\'t delete a model: '.$e->getMessage()); + //var_dump('Couldn\'t delete a model: '.$e->getMessage()); } }, $world); \ No newline at end of file diff --git a/test/features/vendo/user.feature b/test/features/vendo/user.feature index 9dae446..0a9235d 100644 --- a/test/features/vendo/user.feature +++ b/test/features/vendo/user.feature @@ -4,7 +4,7 @@ Feature: User management Scenario: register Given I am logged out - When I click the "Register" link + When I follow "Register" And I fill out the registration form And I press "Submit" Then I should be logged in @@ -16,7 +16,7 @@ Feature: User management Scenario: logout Given I log in Then I should be logged in - When I click the "Logout" link + When I follow "Logout" Then I should be logged out Scenario: delete registered user