parent
5a007ea747
commit
62eeb30c2e
@ -0,0 +1,9 @@ |
||||
default: |
||||
extensions: |
||||
Behat\MinkExtension\Extension: |
||||
base_url: http://localhost |
||||
goutte: ~ |
||||
selenium2: ~ |
||||
paths: |
||||
features: features |
||||
bootstrap: %behat.paths.features%/bootstrap |
||||
@ -1,81 +1,48 @@ |
||||
<?php |
||||
|
||||
use Behat\Behat\Context\Context; |
||||
use Behat\Behat\Context\SnippetAcceptingContext; |
||||
use Behat\Gherkin\Node\PyStringNode; |
||||
use Behat\Gherkin\Node\TableNode; |
||||
use Behat\Behat\Context\ClosuredContextInterface, |
||||
Behat\Behat\Context\TranslatedContextInterface, |
||||
Behat\Behat\Context\BehatContext, |
||||
Behat\Behat\Exception\PendingException; |
||||
|
||||
use Behat\Gherkin\Node\PyStringNode, |
||||
Behat\Gherkin\Node\TableNode; |
||||
|
||||
use Behat\MinkExtension\Context\MinkContext; |
||||
|
||||
// |
||||
// Require 3rd-party libraries here: |
||||
// |
||||
// require_once 'PHPUnit/Autoload.php'; |
||||
// require_once 'PHPUnit/Framework/Assert/Functions.php'; |
||||
// |
||||
|
||||
/** |
||||
* Defines application features from the specific context. |
||||
* Features context. |
||||
*/ |
||||
class FeatureContext implements Context, SnippetAcceptingContext |
||||
class FeatureContext extends MinkContext |
||||
{ |
||||
/** |
||||
* Initializes context. |
||||
* Every scenario gets its own context object. |
||||
* |
||||
* Every scenario gets its own context instance. |
||||
* You can also pass arbitrary arguments to the |
||||
* context constructor through behat.yml. |
||||
* @param array $parameters context parameters (set them up through behat.yml) |
||||
*/ |
||||
public function __construct() |
||||
public function __construct(array $parameters) |
||||
{ |
||||
|
||||
// Initialize your context here |
||||
} |
||||
|
||||
/** |
||||
* Check Chamilo is installed - otherwise try to install it |
||||
* @param BeforeSuiteScope $scope The context scope |
||||
* @BeforeSuite |
||||
*/ |
||||
public static function prepare($scope) |
||||
{ |
||||
// prepare system for test suite |
||||
// before it runs |
||||
require __DIR__.'/../../../main/inc/lib/api.lib.php'; |
||||
$installed = apiIsSystemInstalled(); |
||||
if ($installed['installed'] == 0) { |
||||
// Try to install Chamilo |
||||
//apiInstallChamilo(); |
||||
} else { |
||||
// show version |
||||
} |
||||
require __DIR__.'/../../../main/inc/global.inc.php'; |
||||
} |
||||
|
||||
/** |
||||
* @Given I am logged in |
||||
*/ |
||||
public function iAmLoggedIn() |
||||
{ |
||||
if (api_get_user_id() == 0) { |
||||
throw new Exception('I am not connected as a user yet'); |
||||
} |
||||
} |
||||
|
||||
/** |
||||
* @Given I am an administrator |
||||
*/ |
||||
public function iAmAnAdministrator() |
||||
{ |
||||
if (!api_is_platform_admin()) { |
||||
throw new Exception('I am not connected as an admin'); |
||||
} |
||||
} |
||||
|
||||
/** |
||||
* @When I create a user with e-mail :arg1 |
||||
*/ |
||||
public function iCreateAUserWithEMail($email) |
||||
{ |
||||
throw new PendingException(); |
||||
} |
||||
|
||||
/** |
||||
* @Then the user should be added |
||||
* @Given /^I am a platform administrator$/ |
||||
*/ |
||||
public function theUserShouldBeAdded() |
||||
public function iAmAPlatformAdministrator() |
||||
{ |
||||
throw new PendingException(); |
||||
return array( |
||||
new \Behat\Behat\Context\Step\Given('I am on homepage'), |
||||
new \Behat\Behat\Context\Step\Given('I fill in "login" with "admin"'), |
||||
new \Behat\Behat\Context\Step\Given('I fill in "password" with "admin"'), |
||||
new \Behat\Behat\Context\Step\Given('I press "submitAuth"') |
||||
); |
||||
} |
||||
|
||||
} |
||||
|
||||
@ -1,11 +1,23 @@ |
||||
@administration |
||||
Feature: User creation as admin |
||||
Feature: Users management as admin |
||||
In order to add users |
||||
As an administrator |
||||
I need to be able to create new users |
||||
|
||||
Scenario: Create a user with only user's e-mail |
||||
Given I am logged in |
||||
And I am an administrator |
||||
When I create a user with e-mail "sam@example.com" |
||||
Then the user should be added |
||||
Scenario: Create a user with only basic info |
||||
Given I am a platform administrator |
||||
And I am on "/main/admin/user_add.php" |
||||
When I fill in "firstname" with "Sammy" |
||||
And I fill in "lastname" with "Marshall" |
||||
And I fill in "username" with "smarshall" |
||||
And I fill in "email" with "smarshall@example.com" |
||||
And I press "submit" |
||||
Then I should see "The user has been added" |
||||
|
||||
Scenario: Search and delete a user |
||||
Given I am a platform administrator |
||||
And I am on "/main/admin/user_list.php" |
||||
And I fill in "keyword" with "smarshall" |
||||
And I press "submit" |
||||
When I follow "Delete" |
||||
Then I should see "The user has been deleted" |
||||
|
||||
@ -0,0 +1,14 @@ |
||||
# features/createUser.feature |
||||
@common |
||||
Feature: User login |
||||
In order to log in |
||||
As a registered user |
||||
I need to be able to enter my details in the form and get in |
||||
|
||||
Scenario: Login as admin user successfully |
||||
Given I am on "/index.php" |
||||
When I fill in "login" with "admin" |
||||
And I fill in "password" with "admin" |
||||
And I press "submitAuth" |
||||
Then I should see "John Doe" |
||||
And I should see "Administration" |
||||
Loading…
Reference in new issue