Browse Source

Behat: Add update admin settings test.

jmontoyaa 8 years ago
parent
commit
3d4eef7a84

+ 24 - 17
tests/behat/README.md

@@ -1,18 +1,4 @@
-In order to run tests locally:
-
-- An administrator user should be created with:
-    - Username "admin" 
-    - Password "admin"
-    - First name John
-    - Last name Doe
-    - user_id = 1 
-
-- Edit file tests/behat/behat.yml
-  Update with your Chamilo local URL.
-  
-- The main platform language must be in English.
-
-- Social network tool must be available.
+In order to run behat tests locally you need:
 
 - Install Selenium 3
  
@@ -32,14 +18,35 @@ https://sites.google.com/a/chromium.org/chromedriver/downloads
  - wget https://chromedriver.storage.googleapis.com/2.27/chromedriver_linux64.zip && unzip chromedriver_linux64.zip && sudo mv chromedriver /usr/bin 
 ```
 
-Run:
+### Chamilo configuration
+
+- An administrator user should be created with this parameters:
+    - Username "admin" 
+    - Password "admin"
+    - First name John
+    - Last name Doe
+    - user_id = 1 
+
+- Edit file tests/behat/behat.yml
+  Update with your Chamilo local URL.
+  
+- The main platform language must be in English (platformLanguage = english)
+- Social network tool must be available (allow_social_tool = true)
+- Student can register to the system (allow_registration = yes)
+- Teacher can register to the system (allow_registration_as_teacher = yes)
+
+
+### Run tests
+
+To run all features:
 
 ```
+# /var/www/html/chamilo
 cd tests/behat
  ../../vendor/behat/behat/bin/behat -v
  ```
  
-Or for a specific feature:
+To run an specific feature:
 
 ```
 ../../vendor/behat/behat/bin/behat features/createCourse.feature

+ 21 - 0
tests/behat/features/adminSettings.feature

@@ -0,0 +1,21 @@
+Feature: Settings update
+  In order to use Chamilo
+  As an administrator
+  I need to be able to update Chamilo settings
+
+  Scenario: Update 'profile' setting
+    Given I am a platform administrator
+    And I am on "/main/admin/settings.php?category=User"
+    And I check "Name"
+    And I check "e-mail"
+    And I check "Code"
+    And I check "Login"
+    And I press "Save settings"
+    Then I should see "Update successful"
+
+  Scenario: Update 'allow_registration' setting
+    Given I am a platform administrator
+    And I am on "/main/admin/settings.php"
+    And I check the "allow_registration" radio button with "Yes" value
+    And I press "Save settings"
+    Then I should see "Update successful"

+ 17 - 0
tests/behat/features/bootstrap/FeatureContext.php

@@ -443,4 +443,21 @@ class FeatureContext extends MinkContext
         $input = $this->getSession()->getPage()->findField($input);
         $input->focus();
     }
+
+    /**
+     * @Given /^I check the "([^"]*)" radio button with "([^"]*)" value$/
+     */
+    public function iCheckTheRadioButtonWithValue($element, $value)
+    {
+        $page = $this->getSession()->getPage();
+        foreach ($page->findAll('css', 'input[type="radio"][name="'.$element.'"]') as $radio) {
+            if ($radio->getAttribute('value') == $value) {
+                $radio->check();
+
+                return true;
+            }
+        }
+
+        return false;
+    }
 }