Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

BDD Tests: Getting tests working with newest behat

  • Loading branch information...
commit df54686269940da36ba3e1eeed490cac3f80b981 1 parent 04db19e
@zombor zombor authored
View
28 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
+#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
View
12 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"
View
2  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"
View
10 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 | | | |
View
12 test/features/vendo/steps/cartSteps.php
@@ -1,7 +1,9 @@
<?php
$steps->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);
});
View
13 test/features/vendo/steps/checkoutSteps.php
@@ -1,11 +1,16 @@
<?php
$steps->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());
});
View
2  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!');
}
});
View
2  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);
View
12 test/features/vendo/support/bootstrap.php
@@ -0,0 +1,12 @@
+<?php
+
+// Init kohana
+require_once '../modules/unittest/bootstrap.php';
+
+require_once 'mink/autoload.php';
+require_once 'Zend/Registry.php';
+require_once 'PHPUnit/Autoload.php';
+require_once 'PHPUnit/Framework/Assert/Functions.php';
+
+// Ignore facebook html errors
+libxml_use_internal_errors(true);
View
17 test/features/vendo/support/env.php
@@ -1,17 +1,4 @@
-<?php
-
-// Init kohana
-defined('APPPATH') ?: define('APPPATH', '../application/');
-defined('MODPATH') ?: define('MODPATH', '../modules/');
-defined('SYSPATH') ?: define('SYSPATH', '../system/');
-defined('EXT') ?: define('EXT', '.php');
-
-require_once APPPATH.'bootstrap.php';
-
-require_once 'Zend/Registry.php';
-require_once 'PHPUnit/Autoload.php';
-require_once 'PHPUnit/Framework/Assert/Functions.php';
-require_once 'features/goutte.phar';
+<?php
// Create WebClient behavior
$world->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);
View
4 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
Please sign in to comment.
Something went wrong with that request. Please try again.