-
Notifications
You must be signed in to change notification settings - Fork 65
[WIP] refactoring/new extension #100
base: master
Are you sure you want to change the base?
Changes from 31 commits
8109b60
5c49b97
cda5acc
ee907d1
1aaeebd
65c2b4b
479e778
e910bf3
08fed76
b6ffa4a
aeacc7a
58a6b4a
ecd9db2
8a78a21
213a684
531e3d1
0fe226d
0718188
880a5d0
1f02414
9f41cab
e41d882
75b96ea
6bc0c04
a0b9912
73b4369
c811944
2129bdd
b0c027b
cae3538
64d436f
52d06cd
e7473e6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| 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 | ||
| Behat\MinkExtension: | ||
| base_url: 'http://localhost:8080/' | ||
| goutte: ~ | ||
| selenium2: ~ | ||
| default_session: goutte | ||
| javascript_session: selenium2 | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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", | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We should place it in |
||
| "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": [ | ||
|
|
@@ -33,5 +41,5 @@ | |
| "config": { | ||
| "bin-dir": "bin" | ||
| }, | ||
| "minimum-stability": "dev" | ||
| "minimum-stability": "stable" | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As any dependency, the minimum stability should be dev. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍 . An other fact is that you restrict the entire There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. |
||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| Lecture des listes de paquets… | ||
|
||
| 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. | ||
| 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); | ||
| } | ||
| } |
| 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); | ||
| } | ||
| } | ||
| } |
| 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}'; | ||
| } | ||
| } |
| 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'; | ||
| } | ||
| } |
| 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'; | ||
| } | ||
| } |
| 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'; | ||
| } | ||
| } |
| 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" | ||
| } | ||
| } | ||
| """ |
| 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 | |
| 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 | |
| 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> | ||
|
|
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| { | ||
| "plop": { | ||
| "plip": 13, | ||
| "foo": "bar" | ||
| } | ||
| } |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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...
There was a problem hiding this comment.
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.