Last active
August 29, 2015 14:14
-
-
Save farconada/3ca2fa6e7748eac0a4e9 to your computer and use it in GitHub Desktop.
Behat bug?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| default: | |
| suites: | |
| default: | |
| contexts: | |
| - FeatureContext | |
| - behatch:rest | |
| - behatch:browser | |
| extensions: | |
| Behat\Symfony2Extension: | |
| kernel: | |
| env: test | |
| debug: true | |
| Behat\MinkExtension: | |
| base_url: ~ | |
| default_session: my_session | |
| sessions: | |
| my_session: | |
| symfony2: ~ | |
| VIPSoft\DoctrineDataFixturesExtension\Extension: | |
| lifetime: scenario | |
| autoload: true | |
| directories: ~ | |
| fixtures: ~ | |
| Sanpi\Behatch\Extension: ~ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| "behat/behat": "*", | |
| "sensio/generator-bundle": "~2.3", | |
| "phpspec/phpspec": "~2.0@dev", | |
| "behat/symfony2-extension": "dev-master", | |
| "behatch/contexts": "dev-master", | |
| "behat/mink": "1.*@stable", | |
| "behat/mink-extension": "*", | |
| "behat/mink-browserkit-driver": "*", | |
| "behat/mink-goutte-driver": "*", | |
| "behat/mink-sahi-driver": "*", |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| imports: | |
| - { resource: config_dev.yml } | |
| framework: | |
| test: ~ | |
| session: | |
| storage_id: session.storage.native | |
| handler_id: session.handler.native_file | |
| profiler: | |
| collect: false | |
| web_profiler: | |
| toolbar: false | |
| intercept_redirects: false | |
| swiftmailer: | |
| disable_delivery: true | |
| doctrine: | |
| dbal: | |
| driver: "pdo_sqlite" | |
| path: "%kernel.cache_dir%/test.db" | |
| charset: UTF8 | |
| liip_functional_test: | |
| cache_sqlite_db: true |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Cannot change the ID of an active session (500 Internal Server Error) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Scenario: Puedo borrar un objeto Tag por su ID | |
| Given I count the "Tag" objects | |
| And I select one "Tag" ID | |
| When I POST to "/admin/tag/delete" with: | |
| |name | type | value | | |
| |tag_id | string | {Tag-selected} | | |
| |_token | csrf | | | |
| Then print last response | |
| Then the response status code should be 200 | |
| And I have 1 "less" "Tag" objects |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class FeatureContext extends MinkContext implements Context, SnippetAcceptingContext, KernelAwareContext { | |
| ..... | |
| /** | |
| * @When I POST to :url a form :form_name with: | |
| */ | |
| public function iPostToAFormWith($url, $form_name, TableNode $parametersTable) | |
| { | |
| $driver = $this->getSession()->getDriver(); | |
| if (!$driver instanceof BrowserKitDriver) { | |
| throw new \Exception('This step is only supported by the BrowserKitDriver'); | |
| } | |
| $params = array(); | |
| $files = array(); | |
| $client = $driver->getClient(); | |
| foreach ($parametersTable as $row) { | |
| switch ($row['type']) { | |
| case "string": | |
| $text = $this->replaceIdsInString($row['value']); | |
| $params[$form_name][$row['name']] = $text; | |
| break; | |
| case "boolean": | |
| $params[$form_name][$row['name']] = $row['value']; | |
| break; | |
| case "file": | |
| $fileUpload = new UploadedFile($row['value'], 'the_file_name'); | |
| $files[$form_name][$row['name']] = $fileUpload; | |
| break; | |
| case "csrf": | |
| $token = $client->getContainer()->get('form.csrf_provider')->generateCsrfToken($form_name); | |
| $params[$form_name][$row['name']] = $token; | |
| break; | |
| } | |
| } | |
| $client->request('POST', $url, $params, $files); | |
| } | |
| .... |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Background:
Given I am authenticated as "admin"
/**
* @given I am authenticated as :username
*/
public function iAmAuthenticatedAs($username)
{
$driver = $this->getSession()->getDriver();
if (!$driver instanceof BrowserKitDriver) {
throw new \Exception('This step is only supported by the BrowserKitDriver');
}