Skip to content

Commit

Permalink
Merge branch 'release/1.0.3'
Browse files Browse the repository at this point in the history
  • Loading branch information
everzet committed Aug 2, 2011
2 parents dbc7c6a + 913b8fa commit d8053c0
Show file tree
Hide file tree
Showing 12 changed files with 173 additions and 14 deletions.
10 changes: 10 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
1.0.3 / 2011-08-02
==================

* File uploads for empty fields fixed (GoutteDriver)
* Lazy sessions restart
* `show_tmp_dir` option in MinkContext
* Updated to stable Symfony2 components
* SahiClient connection limit bumped to 60 seconds
* Dutch language support

1.0.2 / 2011-07-22
==================

Expand Down
6 changes: 4 additions & 2 deletions src/Behat/Mink/Behat/Context/MinkContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ public function __construct(array $parameters = array())
'default_session' => 'goutte',
'base_url' => 'http://localhost',
'show_cmd' => null,
'show_tmp_dir' => sys_get_temp_dir(),
'browser' => 'firefox',
'goutte' => array(
'zend_config' => array(),
Expand Down Expand Up @@ -610,7 +611,7 @@ public function showLastResponse()
throw new \RuntimeException('Set "show_cmd" parameter in behat.yml to be able to open page in browser (ex.: "show_cmd: firefox %s")');
}

$filename = sys_get_temp_dir().DIRECTORY_SEPARATOR.uniqid().'.html';
$filename = rtrim($this->getParameter('show_tmp_dir'), DIRECTORY_SEPARATOR).DIRECTORY_SEPARATOR.uniqid().'.html';
file_put_contents($filename, $this->getSession()->getPage()->getContent());
system(sprintf($this->getParameter('show_cmd'), $filename));
}
Expand All @@ -632,7 +633,7 @@ public function prepareMinkSession($event)
}

if ($scenario->hasTag('insulated')) {
$this->getMink()->restartSessions();
$this->getMink()->stopSessions();
} else {
$this->getMink()->resetSessions();
}
Expand All @@ -652,6 +653,7 @@ public function getTranslationResources()
__DIR__ . '/translations/fr.xliff',
__DIR__ . '/translations/ja.xliff',
__DIR__ . '/translations/es.xliff',
__DIR__ . '/translations/nl.xliff',
);
}

Expand Down
131 changes: 131 additions & 0 deletions src/Behat/Mink/Behat/Context/translations/nl.xliff
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
<xliff version="1.2" xmlns="urn:oasis:names:tc:xliff:document:1.2">
<file original="global" source-language="en" target-language="nl" datatype="plaintext">
<header />
<body>
<trans-unit id="i-am-on-page">
<source><![CDATA[/^(?:|I )am on "(?P<page>[^"]+)"$/]]></source>
<target><![CDATA[/^dat ik op "(?P<page>[^"]+)" ben$/]]></target>
</trans-unit>
<trans-unit id="i-go-to-page">
<source><![CDATA[/^(?:|I )go to "(?P<page>[^"]+)"$/]]></source>
<target><![CDATA[/^(?:|ik )naar "(?P<page>[^"]+)" ga$/]]></target>
</trans-unit>
<trans-unit id="reload-the-page">
<source><![CDATA[/^(?:|I )reload the page$/]]></source>
<target><![CDATA[/^(?:|ik )de pagina herlaad$/]]></target>
</trans-unit>
<trans-unit id="move-backward-one-page">
<source><![CDATA[/^(?:|I )move backward one page$/]]></source>
<target><![CDATA[/^(?:|ik )een pagina terugga$/]]></target>
</trans-unit>
<trans-unit id="move-forward-one-page">
<source><![CDATA[/^(?:|I )move forward one page$/]]></source>
<target><![CDATA[/^(?:|ik )een pagina vooruit ga$/]]></target>
</trans-unit>
<trans-unit id="i-press-button">
<source><![CDATA[/^(?:|I )press "(?P<button>(?:[^"]|\\")*)"$/]]></source>
<target><![CDATA[/^(?:|ik )druk op "(?P<button>(?:[^"]|\\")*)"$/]]></target>
</trans-unit>
<trans-unit id="i-follow-link">
<source><![CDATA[/^(?:|I )follow "(?P<link>(?:[^"]|\\")*)"$/]]></source>
<target><![CDATA[/^(?:|ik )"(?P<link>(?:[^"]|\\")*)" volg$/]]></target>
</trans-unit>
<trans-unit id="i-fill-in-field-with-value">
<source><![CDATA[/^(?:|I )fill in "(?P<field>(?:[^"]|\\")*)" with "(?P<value>(?:[^"]|\\")*)"$/]]></source>
<target><![CDATA[/^(?:|ik )het veld "(?P<field>(?:[^"]|\\")*)" invul met "(?P<value>(?:[^"]|\\")*)"$/]]></target>
</trans-unit>
<trans-unit id="i-fill-in-value-for-field">
<source><![CDATA[/^(?:|I )fill in "(?P<value>(?:[^"]|\\")*)" for "(?P<field>(?:[^"]|\\")*)"$/]]></source>
<target><![CDATA[/^(?:|ik )de waarde "(?P<value>(?:[^"]|\\")*)" invul in "(?P<field>(?:[^"]|\\")*)"$/]]></target>
</trans-unit>
<trans-unit id="i-fill-in-the-following">
<source><![CDATA[/^(?:|I )fill in the following:$/]]></source>
<target><![CDATA[/^(?:|ik )het volgende invul:$/]]></target>
</trans-unit>
<trans-unit id="i-select-option-from-select">
<source><![CDATA[/^(?:|I )select "(?P<option>(?:[^"]|\\")*)" from "(?P<select>(?:[^"]|\\")*)"$/]]></source>
<target><![CDATA[/^(?:|ik )de optie "(?P<option>(?:[^"]|\\")*)" selecteer voor "(?P<select>(?:[^"]|\\")*)"$/]]></target>
</trans-unit>
<trans-unit id="i-check-option">
<source><![CDATA[/^(?:|I )check "(?P<option>(?:[^"]|\\")*)"$/]]></source>
<target><![CDATA[/^(?:|ik )"(?P<option>(?:[^"]|\\")*)" aanvink$/]]></target>
</trans-unit>
<trans-unit id="i-uncheck-option">
<source><![CDATA[/^(?:|I )uncheck "(?P<option>(?:[^"]|\\")*)"$/]]></source>
<target><![CDATA[/^(?:|ik )"(?P<option>(?:[^"]|\\")*)" uitvink$/]]></target>
</trans-unit>
<trans-unit id="i-attach-the-file-to-field">
<source><![CDATA[/^(?:|I )attach the file "(?P<path>[^"]*)" to "(?P<field>(?:[^"]|\\")*)"$/]]></source>
<target><![CDATA[/^(?:|ik )het bestand "(?P<path>[^"]*)" toevoeg aan "(?P<field>(?:[^"]|\\")*)"$/]]></target>
</trans-unit>
<trans-unit id="i-should-see-text">
<source><![CDATA[/^(?:|I )should see "(?P<text>(?:[^"]|\\")*)"$/]]></source>
<target><![CDATA[/^moet (?:|ik )"(?P<text>(?:[^"]|\\")*)" zien$/]]></target>
</trans-unit>
<trans-unit id="the-response-should-contain">
<source><![CDATA[/^the response should contain "(?P<text>(?:[^"]|\\")*)"$/]]></source>
<target><![CDATA[/^moet het antwoord "(?P<text>(?:[^"]|\\")*)" bevatten$/]]></target>
</trans-unit>
<trans-unit id="i-should-not-see-text">
<source><![CDATA[/^(?:|I )should not see "(?P<text>(?:[^"]|\\")*)"$/]]></source>
<target><![CDATA[/^moet (?:|ik )niet "(?P<text>(?:[^"]|\\")*)" zien$/]]></target>
</trans-unit>
<trans-unit id="the-response-should-not-contain">
<source><![CDATA[/^the response should not contain "(?P<text>(?:[^"]|\\")*)"$/]]></source>
<target><![CDATA[/^moet het antwoord "(?P<text>(?:[^"]|\\")*)" niet bevatten$/]]></target>
</trans-unit>
<trans-unit id="the-field-should-contain-value">
<source><![CDATA[/^the "(?P<field>(?:[^"]|\\")*)" field should contain "(?P<value>(?:[^"]|\\")*)"$/]]></source>
<target><![CDATA[/^moet "(?P<field>(?:[^"]|\\")*)" "(?P<value>(?:[^"]|\\")*)" bevatten$/]]></target>
</trans-unit>
<trans-unit id="the-field-should-not-contain-value">
<source><![CDATA[/^the "(?P<field>(?:[^"]|\\")*)" field should not contain "(?P<value>(?:[^"]|\\")*)"$/]]></source>
<target><![CDATA[/^moet "(?P<field>(?:[^"]|\\")*)" "(?P<value>(?:[^"]|\\")*)" niet bevatten$/]]></target>
</trans-unit>
<trans-unit id="the-checkbox-should-be-checked">
<source><![CDATA[/^the "(?P<checkbox>(?:[^"]|\\")*)" checkbox should be checked$/]]></source>
<target><![CDATA[/^moet "(?P<checkbox>(?:[^"]|\\")*)" aangevinkt zijn$/]]></target>
</trans-unit>
<trans-unit id="the-checkbox-should-not-be-checked">
<source><![CDATA[/^the "(?P<checkbox>(?:[^"]|\\")*)" checkbox should not be checked$/]]></source>
<target><![CDATA[/^moet "(?P<checkbox>(?:[^"]|\\")*)" niet aangevinkt zijn$/]]></target>
</trans-unit>
<trans-unit id="i-should-be-on-page">
<source><![CDATA[/^(?:|I )should be on "(?P<page>[^"]+)"$/]]></source>
<target><![CDATA[/^moet (?:|ik )op "(?P<page>[^"]+)" zijn$/]]></target>
</trans-unit>
<trans-unit id="the-url-should-match">
<source><![CDATA[/^the url should match "(?P<pattern>(?:[^"]|\\")*)"$/]]></source>
<target><![CDATA[/^moet de url overeenkomen met "(?P<pattern>(?:[^"]|\\")*)"$/]]></target>
</trans-unit>
<trans-unit id="the-element-should-contain">
<source><![CDATA[/^the "(?P<element>[^"]*)" element should contain "(?P<value>(?:[^"]|\\")*)"$/]]></source>
<target><![CDATA[/^moet het element "(?P<element>[^"]*)" "(?P<value>(?:[^"]|\\")*)" bevatten$/]]></target>
</trans-unit>
<trans-unit id="i-should-see-text-in-element">
<source><![CDATA[/^(?:|I )should see "(?P<text>(?:[^"]|\\")*)" in the "(?P<element>[^"]*)" element$/]]></source>
<target><![CDATA[/^moet (?:|ik )"(?P<text>(?:[^"]|\\")*)" zien in "(?P<element>[^"]*)"$/]]></target>
</trans-unit>
<trans-unit id="i-should-see-element">
<source><![CDATA[/^(?:|I )should see an? "(?P<element>[^"]*)" element$/]]></source>
<target><![CDATA[/^moet (?:|ik )een element "(?P<element>[^"]*)" zien$/]]></target>
</trans-unit>
<trans-unit id="i-should-not-see-element">
<source><![CDATA[/^(?:|I )should not see an? "(?P<element>[^"]*)" element$/]]></source>
<target><![CDATA[/^moet (?:|ik )een element "(?P<element>[^"]*)" niet zien$/]]></target>
</trans-unit>
<trans-unit id="the-response-status-code-should-be">
<source><![CDATA[/^the response status code should be (?P<code>\d+)$/]]></source>
<target><![CDATA[/^moet de statuscode van het antwoord (?P<code>\d+) zijn$/]]></target>
</trans-unit>
<trans-unit id="print-last-response">
<source><![CDATA[/^print last response$/]]></source>
<target><![CDATA[/^print het laatste antwoord$/]]></target>
</trans-unit>
<trans-unit id="show-last-response">
<source><![CDATA[/^show last response$/]]></source>
<target><![CDATA[/^toon het laatste antwoord$/]]></target>
</trans-unit>
</body>
</file>
</xliff>
4 changes: 0 additions & 4 deletions src/Behat/Mink/Compiler/PearCompiler.php
Original file line number Diff line number Diff line change
Expand Up @@ -197,22 +197,18 @@ protected function getPackageTemplate()
<package>
<name>BrowserKit</name>
<channel>pear.symfony.com</channel>
<recommended>2.0.0RC1</recommended>
</package>
<package>
<name>CssSelector</name>
<channel>pear.symfony.com</channel>
<recommended>2.0.0RC1</recommended>
</package>
<package>
<name>DomCrawler</name>
<channel>pear.symfony.com</channel>
<recommended>2.0.0RC1</recommended>
</package>
<package>
<name>Process</name>
<channel>pear.symfony.com</channel>
<recommended>2.0.0RC1</recommended>
</package>
<extension>
<name>pcre</name>
Expand Down
9 changes: 7 additions & 2 deletions src/Behat/Mink/Driver/GoutteDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -328,10 +328,11 @@ public function click($xpath)
);
}
$node = $nodes->eq(0);
$type = $this->getCrawlerNode($node)->nodeName;

if ('a' === $this->getCrawlerNode($node)->nodeName) {
if ('a' === $type) {
$this->client->click($node->link());
} else {
} elseif('input' === $type) {
$buttonForm = $node->form();
foreach ($this->forms as $form) {
if ($buttonForm->getFormNode()->getLineNo() === $form->getFormNode()->getLineNo()) {
Expand All @@ -341,6 +342,10 @@ public function click($xpath)
}
}
$this->client->submit($buttonForm);
} else {
throw new DriverException(sprintf(
'Goutte driver supports clicking on inputs and links only. But "%s" provided', $type
));
}

$this->forms = array();
Expand Down
10 changes: 10 additions & 0 deletions tests/Behat/Mink/Driver/GeneralDriverTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,16 @@ public function testBasicForm()

public function testAdvancedForm()
{
$this->getSession()->visit($this->pathTo('/advanced_form.php'));
$page = $this->getSession()->getPage();

$page->fillField('first_name', 'ever');
$page->fillField('last_name', 'zet');

$page->pressButton('Register');

$this->assertContains('no file', $page->getContent());

$this->getSession()->visit($this->pathTo('/advanced_form.php'));

$page = $this->getSession()->getPage();
Expand Down
7 changes: 6 additions & 1 deletion tests/Behat/Mink/Driver/web-fixtures/advanced_form_post.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,15 @@
</head>
<body>
<?php
error_reporting(0);

$_POST['agreement'] = ('1' === $_POST['agreement'] || 'on' === $_POST['agreement']) ? 'on' : 'off';
print_r($_POST);
echo count($_FILES) . ' ' . file_get_contents($_FILES['about']['tmp_name']);
if (file_exists($_FILES['about']['tmp_name'])) {
echo file_get_contents($_FILES['about']['tmp_name']);
} else {
echo "no file";
}

?>
</body>
Expand Down
2 changes: 1 addition & 1 deletion tests/Behat/Mink/Driver/web-fixtures/some_file.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
uploaded file
1 uploaded file
2 changes: 1 addition & 1 deletion vendor/Goutte
Submodule Goutte updated from 63f57a to 650e1d
2 changes: 1 addition & 1 deletion vendor/SahiClient
2 changes: 1 addition & 1 deletion vendor/Symfony/Component/BrowserKit
Submodule BrowserKit updated from 66eadd to fd0cb9
2 changes: 1 addition & 1 deletion vendor/Symfony/Component/Process
Submodule Process updated 1 files
+3 −10 Process.php

0 comments on commit d8053c0

Please sign in to comment.