|
@@ -1,5 +1,6 @@
|
|
<?php
|
|
<?php
|
|
|
|
|
|
|
|
+use Behat\Gherkin\Node\TableNode;
|
|
use Behat\MinkExtension\Context\MinkContext;
|
|
use Behat\MinkExtension\Context\MinkContext;
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -141,7 +142,7 @@ class FeatureContext extends MinkContext
|
|
{
|
|
{
|
|
$this->visit('/index.php?logout=logout');
|
|
$this->visit('/index.php?logout=logout');
|
|
$this->iAmOnHomepage();
|
|
$this->iAmOnHomepage();
|
|
- $this->fillFields(new \Behat\Gherkin\Node\TableNode([
|
|
|
|
|
|
+ $this->fillFields(new TableNode([
|
|
['login', $username],
|
|
['login', $username],
|
|
['password', $username]
|
|
['password', $username]
|
|
]));
|
|
]));
|
|
@@ -181,7 +182,7 @@ class FeatureContext extends MinkContext
|
|
public function iHaveAPublicPasswordProtectedCourse($code, $password)
|
|
public function iHaveAPublicPasswordProtectedCourse($code, $password)
|
|
{
|
|
{
|
|
$this->visit('/main/admin/course_add.php');
|
|
$this->visit('/main/admin/course_add.php');
|
|
- $this->fillFields(new \Behat\Gherkin\Node\TableNode([
|
|
|
|
|
|
+ $this->fillFields(new TableNode([
|
|
['title', 'Password Protected'],
|
|
['title', 'Password Protected'],
|
|
['visual_code', $code],
|
|
['visual_code', $code],
|
|
['visibility', 3]
|
|
['visibility', 3]
|
|
@@ -471,4 +472,96 @@ class FeatureContext extends MinkContext
|
|
}
|
|
}
|
|
return false;
|
|
return false;
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * @Given /^I am a student subscribed to session "([^"]*)"$/
|
|
|
|
+ *
|
|
|
|
+ * @param string$sessionName
|
|
|
|
+ */
|
|
|
|
+ public function iAmStudentSubscribedToXSession($sessionName)
|
|
|
|
+ {
|
|
|
|
+ $this->iAmAPlatformAdministrator();
|
|
|
|
+ $this->visit('/main/session/session_add.php');
|
|
|
|
+ $this->fillField('name', $sessionName);
|
|
|
|
+ $this->pressButton('Next step');
|
|
|
|
+ $this->selectOption('NoSessionCoursesList[]', 'TEMP (TEMP)');
|
|
|
|
+ $this->pressButton('add_course');
|
|
|
|
+ $this->pressButton('Next step');
|
|
|
|
+ $this->assertPageContainsText('Update successful');
|
|
|
|
+ $this->fillField('user_to_add', 'acostea');
|
|
|
|
+ $this->waitForThePageToBeLoaded();
|
|
|
|
+ $this->clickLink('Costea Andrea (acostea)');
|
|
|
|
+ $this->pressButton('Finish session creation');
|
|
|
|
+ $this->assertPageContainsText('Session overview');
|
|
|
|
+ //$this->assertPageContainsText('Costea Andrea (acostea)');
|
|
|
|
+ $this->iAmAStudent();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * Example: Then I should see the table "#category_results":
|
|
|
|
+ * | Categories | Absolute score | Relative score |
|
|
|
|
+ * | Categoryname2 | 50 / 70 | 71.43% |
|
|
|
|
+ * | Categoryname1 | 60 / 60 | 100% |
|
|
|
|
+ *
|
|
|
|
+ * @Then /^I should see the table "([^"]*)":$/
|
|
|
|
+ *
|
|
|
|
+ * @param string $tableId
|
|
|
|
+ * @param TableNode $tableData
|
|
|
|
+ *
|
|
|
|
+ * @throws Exception
|
|
|
|
+ */
|
|
|
|
+ public function assertPageContainsTable($tableId, TableNode $tableData)
|
|
|
|
+ {
|
|
|
|
+ $table = $this->getSession()->getPage()->find('css', $tableId);
|
|
|
|
+ $rows = $tableData->getRowsHash();
|
|
|
|
+ $i = 1;
|
|
|
|
+
|
|
|
|
+ $right = array_keys($rows);
|
|
|
|
+
|
|
|
|
+ foreach ($right as $text) {
|
|
|
|
+ $cell = $table->find('css', 'tr:nth-child('.$i.') :nth-child(1)');
|
|
|
|
+ $i++;
|
|
|
|
+
|
|
|
|
+ if (!$cell) {
|
|
|
|
+ throw new Exception('Cell not found.');
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if ($cell->getText() != $text) {
|
|
|
|
+ throw new Exception('Table text not found.');
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ $i = 1;
|
|
|
|
+
|
|
|
|
+ foreach ($rows as $field => $cols) {
|
|
|
|
+ if (is_array($cols)) {
|
|
|
|
+ $j = 2;
|
|
|
|
+
|
|
|
|
+ foreach ($cols as $col) {
|
|
|
|
+ $cell = $table->find('css', 'tr:nth-child('.$i.') :nth-child('.$j.')');
|
|
|
|
+ $j++;
|
|
|
|
+
|
|
|
|
+ if (!$cell) {
|
|
|
|
+ throw new Exception('Cell not found.');
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if ($cell->getText() != $col) {
|
|
|
|
+ throw new Exception('Table text not found. Found "'.$cell->getText().'" <> "'.$col.'"');
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ $cell = $table->find('css', 'tr:nth-child('.$i.') :nth-child(2)');
|
|
|
|
+
|
|
|
|
+ if (!$cell) {
|
|
|
|
+ throw new Exception('Cell not found.');
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if ($cell->getText() != $cols) {
|
|
|
|
+ throw new Exception('Table text not found. Found "'.$cell->getText().'" <> "'.$cols.'"');
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ $i++;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
}
|
|
}
|