Skip to content
This repository was archived by the owner on Sep 15, 2022. It is now read-only.
Open
Show file tree
Hide file tree
Changes from 31 commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
8109b60
Introducte composer updates
PedroTroller Jun 20, 2014
5c49b97
Fix composer
PedroTroller Jun 20, 2014
cda5acc
Add new namespace
PedroTroller Jun 25, 2014
ee907d1
WIP
PedroTroller Jul 16, 2014
1aaeebd
WIP
PedroTroller Jul 16, 2014
65c2b4b
WIP
PedroTroller Jul 18, 2014
479e778
WIP
PedroTroller Jul 22, 2014
e910bf3
Add event listener and new tag policy
PedroTroller Aug 1, 2014
08fed76
Refactor services
PedroTroller Aug 21, 2014
b6ffa4a
Introduce command context
PedroTroller Aug 29, 2014
aeacc7a
Improve stability
PedroTroller Oct 13, 2014
58a6b4a
Patch CS
PedroTroller Oct 13, 2014
ecd9db2
Add tag API
PedroTroller Oct 14, 2014
8a78a21
Register TagLoaderHasService
PedroTroller Oct 14, 2014
213a684
Add alice class loader
PedroTroller Oct 14, 2014
531e3d1
Add alice config
PedroTroller Oct 14, 2014
0fe226d
Move smartstep feature, intraduce alice
PedroTroller Oct 15, 2014
0718188
Fix service def
PedroTroller Oct 15, 2014
880a5d0
Migrate API classes and Page classes
PedroTroller Oct 15, 2014
1f02414
Add page context and behat tests
PedroTroller Oct 16, 2014
9f41cab
Add table and specs
PedroTroller Oct 16, 2014
e41d882
Move mink context
PedroTroller Oct 16, 2014
75b96ea
Add tests for mink context
PedroTroller Oct 16, 2014
6bc0c04
Add screenshot
PedroTroller Oct 24, 2014
a0b9912
Change config location
PedroTroller Oct 24, 2014
73b4369
Use tag loader to reset schema
PedroTroller Oct 24, 2014
c811944
Fix tests
PedroTroller Oct 24, 2014
2129bdd
Begin alice work
PedroTroller Nov 6, 2014
b0c027b
Migrate api context
PedroTroller Nov 7, 2014
cae3538
Add api tests
PedroTroller Nov 7, 2014
64d436f
Add SF helper
PedroTroller Nov 9, 2014
52d06cd
remove crapy file
PedroTroller Nov 10, 2014
e7473e6
Fix CS
PedroTroller Nov 10, 2014
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
Empty file modified .gitignore
100644 → 100755
Empty file.
1 change: 1 addition & 0 deletions .travis.yml
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ before_script:

script:
- bin/phpspec run -fpretty
- bin/behat --no-snippets --verbose

notifications:
webhooks:
Expand Down
Empty file modified LICENSE
100644 → 100755
Empty file.
Empty file modified README.md
100644 → 100755
Empty file.
27 changes: 20 additions & 7 deletions behat.yml.dist
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,14 +1,27 @@
default:
autoload:
"Context": %paths.base%/features
"Page": %paths.base%/features
suites:
default:
path: %paths.base%/features
contexts:
- Knp\FriendlyContexts\Context\MinkContext
- Knp\FriendlyContexts\Context\TableContext
- Knp\FriendlyContexts\Context\EntityContext
- Knp\FriendlyContexts\Context\AliceContext
- Knp\FriendlyContexts\Context\PageContext
contexts:
- Context\FeatureContext
- Knp\FriendlyExtension\Context\PageContext
- Knp\FriendlyExtension\Context\MinkContext
- Knp\FriendlyExtension\Context\ApiContext
extensions:
Knp\FriendlyContexts\Extension: ~
Knp\FriendlyExtension:
smart_tag: 'smart-step'
screenshot:
recipents:
- [email protected]
mailer:
username: [email protected]
password: loremipsum
Copy link
Contributor

Choose a reason for hiding this comment

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

I am not sure the password should be here

Copy link
Contributor

Choose a reason for hiding this comment

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

indeed :') . Notice that you should change your password before somebody else do it...

Copy link
Member Author

Choose a reason for hiding this comment

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

I don't care, it's an email address dedicated to tests.
BTW, I've activated 2 steps connexion.

Behat\MinkExtension:
base_url: 'http://localhost:8080/'
goutte: ~
selenium2: ~
default_session: goutte
javascript_session: selenium2
34 changes: 21 additions & 13 deletions composer.json
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,30 @@
"name": "knplabs/friendly-contexts",
"description": "Some BEHAT contexts",
"autoload": {
"psr-0": { "Knp\\FriendlyContexts": "src/"}
"psr-0": {
"Knp\\FriendlyExtension": "src/"
}
},
"require": {
"behat/behat": "~3.0",
"symfony/property-access": "~2.0",
"doctrine/inflector": "~1.0",
"doctrine/data-fixtures": "~1.0",
"behat/mink-extension": "~2.0",
"fzaninotto/faker": "~1.0",
"nelmio/alice": "~1.0",
"guzzle/guzzle": "~3.7"
"behat/behat": "~3.0",
"fzaninotto/faker": "~1.0",
"guzzle/guzzle": "~3.7",
"nelmio/alice": "~1",
"symfony/property-access": "~2.0",
"swiftmailer/swiftmailer": "~5.0"
},
"require-dev": {
"phpspec/phpspec": "2.0.*@dev",
"doctrine/orm": "dev-master",
"knplabs/phpspec-welldone-extension": "dev-master"
"symfony/http-kernel": "~2.0",
"symfony/framework-bundle": "~2.0",
"doctrine/common": "~2.0",
Copy link
Contributor

Choose a reason for hiding this comment

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

"doctrine/data-fixtures": "~1.0",
"doctrine/orm": "~2.0",
"doctrine/inflector": "~1.0",
"behat/mink-extension": "~2.0",
"behat/mink-goutte-driver": "~1.0",
"behat/mink-selenium2-driver": "~1.0",
"phpspec/phpspec": "~2.0",
"knplabs/phpspec-welldone-extension": "dev-master"
},
"license": "MIT",
"authors": [
Expand All @@ -33,5 +41,5 @@
"config": {
"bin-dir": "bin"
},
"minimum-stability": "dev"
"minimum-stability": "stable"
Copy link
Contributor

Choose a reason for hiding this comment

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

As any dependency, the minimum stability should be dev.

Copy link
Contributor

Choose a reason for hiding this comment

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

👍 . An other fact is that you restrict the entire require and require-dev section to be stable too. This not really needed and more this is not flexible ^^.

Copy link
Member Author

Choose a reason for hiding this comment

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

It's a dev restriction ;) It will stay like that until the release.

}
4 changes: 4 additions & 0 deletions devnull
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Lecture des listes de paquets…
Copy link
Contributor

Choose a reason for hiding this comment

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

Youps ...

Construction de l'arbre des dépendances…
Lecture des informations d'état…
0 mis à jour, 0 nouvellement installés, 0 à enlever et 0 non mis à jour.
Empty file modified doc/configuration.md
100644 → 100755
Empty file.
Empty file modified doc/context-alice.md
100644 → 100755
Empty file.
Empty file modified doc/context-api.md
100644 → 100755
Empty file.
Empty file modified doc/context-entity.md
100644 → 100755
Empty file.
Empty file modified doc/context-mink.md
100644 → 100755
Empty file.
Empty file modified doc/context-page.md
100644 → 100755
Empty file.
Empty file modified doc/context-table.md
100644 → 100755
Empty file.
Empty file modified doc/feature-smartStep.md
100644 → 100755
Empty file.
16 changes: 16 additions & 0 deletions features/Context/FeatureContext.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php

namespace Context;

use Knp\FriendlyExtension\Context\Context;

class FeatureContext extends Context
{
/**
* @Given I wait
*/
public function wait($seconds = 2)
{
$this->get('mink')->getSession()->wait($seconds * 1000);
}
}
70 changes: 70 additions & 0 deletions features/Context/ServerContext.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
<?php

namespace Context;

use Behat\Behat\Context\Context;

class ServerContext implements Context
{
const SERVER_ADDRESS = "127.0.0.1:8080";

private static $proc;

/**
* @BeforeSuite
*/
public static function start()
{
self::$proc = sprintf('/tmp/%s', md5(time() . uniqid()));
$command = sprintf(
'php -S %s -t %s/../server',
self::SERVER_ADDRESS,
__DIR__
);
$outputfile = '/dev/null';
shell_exec(sprintf("%s > %s 2>&1 & echo $! >> %s", $command, $outputfile, self::$proc));

$loop = 0;
while ($loop < 5) {
try {
self::test();
return;
} catch (\Exception $ex) {
$loop++;
sleep(1);
}
}
}

/**
* @BeforeScenario
*/
public static function test()
{
$ch = curl_init(sprintf('%s/html/index.html', self::SERVER_ADDRESS));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_exec($ch);

if (200 !== curl_getinfo($ch, CURLINFO_HTTP_CODE)) {

throw new \Exception('PHP builtin server is down.');
} else {

return;
}
}

/**
* @AfterSuite
*/
public static function stop()
{
if (file_exists(self::$proc)) {
$pids = file(self::$proc);
foreach ($pids as $pid) {
shell_exec('kill -9 ' . $pid);
}
unlink(self::$proc);
}
}
}
13 changes: 13 additions & 0 deletions features/Page/APage.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php

namespace Page;

use Knp\FriendlyExtension\Page\Page;

class APage extends Page
{
public function getPath()
{
return '/{part}/{file}.{extension}';
}
}
13 changes: 13 additions & 0 deletions features/Page/FormPage.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php

namespace Page;

use Knp\FriendlyExtension\Page\Page;

class FormPage extends Page
{
public function getPath()
{
return '/html/form.php';
}
}
13 changes: 13 additions & 0 deletions features/Page/IndexPage.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php

namespace Page;

use Knp\FriendlyExtension\Page\Page;

class IndexPage extends Page
{
public function getPath()
{
return '/html/index.html';
}
}
13 changes: 13 additions & 0 deletions features/Page/TablePage.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php

namespace Page;

use Knp\FriendlyExtension\Page\Page;

class TablePage extends Page
{
public function getPath()
{
return '/html/table1.html';
}
}
58 changes: 58 additions & 0 deletions features/api.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
Feature: I am able to describe API

Scenario: I send a get request
Given I prepare a GET request on "/api"
When I send the request
Then the response should contains the following headers:
| Content-type | text/html |
And I should receive a 200 response
And the response should contains:
"""
<body>
<h1>This is a test</h1>
</body>
"""
And the response should contains "This is a test"

Scenario: I send a put request
Given I prepare a PUT request on "/api"
When I send the request
Then I should receive a 404 response

Scenario: I send a get request and recieved a json
Given I prepare a GET request on "/api"
Given I specified the following request headers:
| format | json |
When I send the request
Then the response should contains the following headers:
| Content-type | application/json |
And I should receive a 200 response
Then the response should contains the following json:
"""
{
"plop": {
"plip": 13,
"foo": "bar"
}
}
"""

Scenario: I send a post request and recieved a json
Given I prepare a POST request on "/api"
Given I specified the following request headers:
| format | json |
And I specified the following request data:
| id | 17 |
When I send the request
Then the response should contains the following headers:
| Content-type | application/json |
And I should receive a 202 response
Then the response should contains the following json:
"""
{
"plop": {
"plip": 17,
"foo": "bar"
}
}
"""
25 changes: 25 additions & 0 deletions features/form.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
@javascript
Feature: I am able to use a form

Background:
Given I am on the form page
And I wait

Scenario Outline: I fill in text fields
When I fill in the <number> "<field>" field with "<value>"
Then I should see "<result>"

Examples:
| number | field | value | result |
| 2nd | Text field | foo | Field Text field (text-2) value updated |
| last | Text field | bar | Field Text field (text-4) value updated |

Scenario Outline: I check radio with same names
When I check the <number> "<field>" radio
Then I should see "<result>"

Examples:
| number | field | result |
| first | Radio field 1 | Field Radio field 1 (first-radio) value updated |
| last | Radio field 1 | Field Radio field 1 (second-radio) value updated |
| 2nd | Radio field 1 | Field Radio field 1 (second-radio) value updated |
28 changes: 28 additions & 0 deletions features/page.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
Feature: I am able to navigate between pages

@smart-step
Scenario: I open a page
When I go to the table page
Then I should be on the table page

@smart-step
Scenario: I change the page
Given I open a page
When I go to the index page
Then I should be on the index page

Scenario: I come bak to the first page
Given I change the page
When I go to the table page
Then I should be on the table page

Scenario: I should be on a compite page
Given I am on the a page with:
| part | html |
| file | index |
| extension | html |
When I go to the table page
Then I should be on the a page with:
| part | html |
| file | table1 |
| extension | html |
9 changes: 9 additions & 0 deletions features/server/api/get.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<html>
<head>
<title>Document</title>
</head>
<body>
<h1>This is a test</h1>
</body>
</html>

6 changes: 6 additions & 0 deletions features/server/api/get.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"plop": {
"plip": 13,
"foo": "bar"
}
}
Loading