Skip to content
This repository was archived by the owner on Mar 17, 2020. It is now read-only.

Commit c3a4a0f

Browse files
committed
Merge pull request #15 from javigomez/jab16GherkinpageObjectsandSteps2
[tests] new convention for locating elements
2 parents 39146ff + 97914b7 commit c3a4a0f

File tree

7 files changed

+90
-38
lines changed

7 files changed

+90
-38
lines changed

administrator/modules/mod_login/tmpl/default.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
<?php echo JText::_('JGLOBAL_USERNAME'); ?>
2626
</label>
2727
</span>
28-
<input name="username" tabindex="1" id="mod-login-username" type="text" class="input-medium" placeholder="<?php echo JText::_('JGLOBAL_USERNAME'); ?>" size="15" autofocus="true" />
28+
<input name="username" tabindex="1" id="mod-login-username" type="text" class="input-medium" placeholder="<?php echo JText::_('JGLOBAL_USERNAME'); ?>" size="15" autofocus="true" data-tests="username"/>
2929
<a href="<?php echo JUri::root(); ?>index.php?option=com_users&view=remind" class="btn width-auto hasTooltip" title="<?php echo JText::_('MOD_LOGIN_REMIND'); ?>">
3030
<span class="icon-help"></span>
3131
</a>
@@ -41,7 +41,7 @@
4141
<?php echo JText::_('JGLOBAL_PASSWORD'); ?>
4242
</label>
4343
</span>
44-
<input name="passwd" tabindex="2" id="mod-login-password" type="password" class="input-medium" placeholder="<?php echo JText::_('JGLOBAL_PASSWORD'); ?>" size="15"/>
44+
<input name="passwd" tabindex="2" id="mod-login-password" type="password" class="input-medium" placeholder="<?php echo JText::_('JGLOBAL_PASSWORD'); ?>" size="15" data-tests="password"/>
4545
<a href="<?php echo JUri::root(); ?>index.php?option=com_users&view=reset" class="btn width-auto hasTooltip" title="<?php echo JText::_('MOD_LOGIN_RESET'); ?>">
4646
<span class="icon-help"></span>
4747
</a>
@@ -84,7 +84,7 @@
8484
<div class="control-group">
8585
<div class="controls">
8686
<div class="btn-group">
87-
<button tabindex="3" class="btn btn-primary btn-block btn-large">
87+
<button tabindex="3" class="btn btn-primary btn-block btn-large" data-tests="log in">
8888
<span class="icon-lock icon-white"></span> <?php echo JText::_('MOD_LOGIN_LOGIN'); ?>
8989
</button>
9090
</div>
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?php
2+
namespace Page\Acceptance\Administrator;
3+
4+
class Login extends \AcceptanceTester
5+
{
6+
/**
7+
* @When I login into Joomla Administrator with username :arg1 and password :arg1
8+
*/
9+
public function login($username, $password)
10+
{
11+
$I = $this;
12+
$I->amOnPage('administrator/');
13+
$I->fillField(['css' => 'input[data-tests="username"]'], $username);
14+
$I->fillField(['css' => 'input[data-tests="password"]'], $password);
15+
$I->click(['css' => 'button[data-tests="log in"]']);
16+
}
17+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?php
2+
namespace Step\Acceptance\Administrator;
3+
4+
class User extends \AcceptanceTester
5+
{
6+
/**
7+
* @Given I am registered administrator named :arg1
8+
*/
9+
public function iAmRegisteredAdministratorNamed($arg1)
10+
{
11+
$I = $this;
12+
$I->comment('@todo');
13+
}
14+
15+
/**
16+
* @Then I should see administrator dashboard
17+
*/
18+
public function iShouldSeeAdministratorDashboard()
19+
{
20+
$I = $this;
21+
$I->comment('@todo');
22+
}
23+
}

tests/acceptance.suite.dist.yml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,4 +30,10 @@ modules:
3030
language: 'English (United Kingdom)' # Language in which you want the Application to be Installed
3131
AcceptanceHelper:
3232
url: 'http://localhost/tests/joomla-cms3' # the url that points to the joomla installation at /tests/system/joomla-cms - we need it twice here
33-
error_level: "E_ALL & ~E_STRICT & ~E_DEPRECATED"
33+
error_level: "E_ALL & ~E_STRICT & ~E_DEPRECATED"
34+
gherkin:
35+
contexts:
36+
default:
37+
- AcceptanceTester
38+
- Step\Acceptance\Administrator\User
39+
- Page\Acceptance\Administrator\Login

tests/acceptance/_bootstrap.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1 @@
11
<?php
2-
// Here you can initialize variables that will be available to your tests
3-
4-
\Codeception\Util\Autoload::registerSuffix('Steps', __DIR__. DIRECTORY_SEPARATOR . '_steps');
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
Feature: administrator login
2+
In order to manage my web application
3+
As administrator
4+
I need to be able to login
5+
6+
Scenario: Successful login
7+
Given I am registered administrator named "admin"
8+
When I login into Joomla Administrator with username "admin" and password "admin"
9+
Then I should see administrator dashboard

tests/composer.lock

Lines changed: 31 additions & 31 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)