Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
.idea
bin
vendor
composer.lock
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure why you've changed file attributes from Unix ones to Windows ones (644 > 755).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My fault, configured the web server and executed chmod through my link. I can switch that back.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting why you've put composer.lock in the .gitignore and committed it as well?

40 changes: 40 additions & 0 deletions Features/bootstrap/MainContext.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<?php

use QATools\BehatExtension\Context\QAToolsContext;

class MainContext extends QAToolsContext
{

/**
* @When /^the user enters (.+?) and (.+?)$/
*/
public function fillForm($username, $password)
{
$this->page->fillForm($username, $password);
}

/**
* @Then /^the login should fail$/
*/
public function loginFail()
{
$this->page = $this->page->loginFailure();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's incorrect approach.

Page provides method to interact with elements on a page. It doesn't have methods, that would deliberately fill the form with data, that will lead to failure/success to allow tests to use them.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In that case always combine submit and filling the form? I always divided that but it could also be one step after all.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The method on PageObject/element class represents complete action from UI/user viewpoint. User sees login process as single action: fill fields + press ENTER/login button. This way the PageObject should do it in same fashion.

}

/**
* @Then /^the login should succeed/
*/
public function loginSucceed()
{
$this->page = $this->page->loginSuccess();
}

/**
* @Given /^the user waits for ([0-9]+) seconds$/
*/
public function waitFor($seconds)
{
sleep($seconds);
}

}
16 changes: 16 additions & 0 deletions Features/login.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
Feature: Login
In order to use the website site
As a website user
I need to login successfully

@javascript @login @failing-login
Scenario: Failing login due wrong password
Given the user visits the "Login Page"
When the user enters user and invalidpassword
And the login should fail

@javascript @login @successful-login
Scenario: Successful login of user
Given the user visits the "Login Page"
When the user enters user and validpassword
And the login should succeed
35 changes: 35 additions & 0 deletions Fixtures/account.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<html>
<head>
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css">
<!-- Optional theme -->
<link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap-theme.min.css">
<!-- additional css -->
<link rel="stylesheet" href="additional.css">
<!-- Latest compiled and minified JavaScript -->
<script src="//code.jquery.com/jquery-1.11.2.min.js"></script>
<script src="//maxcdn.bootstrapcdn.com/bootstrap/3.2.0/js/bootstrap.min.js"></script>
</head>
<body>
<div class="row">
<div class="col-md-5 col-md-offset-1">
<h3>Caption Column 1</h3>
Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore
magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd
gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing
elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero
eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum
dolor sit amet.
</div>
<div class="col-md-5">
<h3>Caption Column 2</h3>
Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore
magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd
gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing
elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero
eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum
dolor sit amet.
</div>
</div>
</body>
</html>
7 changes: 7 additions & 0 deletions Fixtures/additional.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
.margin-top {
margin-top: 20px;
}

.margin-bottom {
margin-bottom: 20px;
}
52 changes: 52 additions & 0 deletions Fixtures/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
<html>
<head>
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css">
<!-- Optional theme -->
<link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap-theme.min.css">
<!-- additional css -->
<link rel="stylesheet" href="additional.css">
<!-- Latest compiled and minified JavaScript -->
<script src="//code.jquery.com/jquery-1.11.2.min.js"></script>
<script src="//maxcdn.bootstrapcdn.com/bootstrap/3.2.0/js/bootstrap.min.js"></script>
</head>
<body>
<div class="row margin-top margin-bottom">
<form id="login-form" role="form" class="col-md-4 col-md-offset-4 panel panel-default" action="login.php" method="POST">
<div class="panel-body">
<div class="form-group">
<label for="username">Username</label>
<input type="text" class="form-control" name="username" id="username">
</div>
<div class="form-group">
<label for="password">Password</label>
<input type="password" class="form-control" name="password" id="password">
</div>
<input type="submit" class="btn btn-default" value="Login">
</div>
</form>
</div>
<hr>
<div class="row">
<div class="col-md-5 col-md-offset-1">
<h3>Caption Column 1</h3>
Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore
magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd
gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing
elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero
eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum
dolor sit amet.
</div>
<div class="col-md-5">
<h3>Caption Column 2</h3>
Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore
magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd
gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing
elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero
eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum
dolor sit amet.
</div>
</div>
</div>
</body>
</html>
23 changes: 23 additions & 0 deletions Fixtures/login.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?php
/**
* This file is part of the QA-Tools library.
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*
* @copyright Michael Iwersen <mi.iwersen@gmail.com>
* @link https://github.com/qa-tools/behat-example
*/

if ( empty($_POST) ) {
header('Location: index.html');
}

if ( $_POST['username'] != 'user' ) {
header('Location: index.html');
}

if ( $_POST['password'] != 'validpassword' ) {
header('Location: index.html');
}

header('Location: account.html');
Empty file modified LICENSE
100644 → 100755
Empty file.
Empty file modified README.md
100644 → 100755
Empty file.
18 changes: 18 additions & 0 deletions behat.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
default:
suites:
standard:
paths: ['Features']
contexts: [MainContext]

extensions:
Behat\MinkExtension:
default_session: selenium2
javascript_session: selenium2
base_url: 'http://behat-example.qa-tools.io'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we should use http://localhost as url here and in other setting. It's most unlikely that people will have that domain.

Also in README.md I recommend mentioning steps required to make example operational, like go and replace base_url in 2 places with your actual url.


selenium2: ~

QATools\BehatExtension:
qa_tools:
base_url: 'http://behat-example.qa-tools.io'
page_namespace_prefix: ['\QATools\Example\Pages']
27 changes: 27 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"name": "qa-tools/behat-example",
"license": "BSD-3-Clause",
"require": {
"php": ">=5.3.1",
"qa-tools/qa-tools": "~1.0@dev",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use stable versions, where you can.

"qa-tools/behat-extension": "dev-cleanup",
"mindplay/annotations": "~1.2@dev",
"behat/mink": "~1.5@dev",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mink isn't needed for this extension to operate, it's MinkExtension, that is needed.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It shouldn't be even in cause the all dependencies should be resolved through the extension itself.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Exactly. I recommend using example itself to create new project and see what will happen.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done, locally. Set to stable and qa-tools/* dependencies to dev-master and dev-develop.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dev-* isn't not stable, but direct reference to branch. What I meant is to use say ~1.0 as qa-tools version and so on.

"behat/mink-extension": "*@dev",
"behat/mink-selenium2-driver": "~1.1@dev"
},
"repositories": [
{
"type": "vcs",
"url": "/Users/michi/Documents/Workspace/behat-extension"
}
],
"autoload-dev": {
"psr-0": {
"QATools\\Example": "./src"
}
},
"config": {
"bin-dir": "bin/"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we have any binary files, that this repo provides?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, I totally misunderstood the config, always thought this is the target directory for all binaries of the dependencies like Behat.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The bin-dir is specified for a repo, when it offers any binaries to end user, so that Composer will know what to symlink to the /vendor/bin folder.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done, locally.

}
}
Loading