forked from jhedstrom/drupalextension
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request jhedstrom#628 from claudiu-cristea/use-guzzle
Use BrowserKit with Guzzle client
- Loading branch information
Showing
7 changed files
with
67 additions
and
3 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
@api | ||
Feature: Upload test. | ||
|
||
Scenario: Upload an image. | ||
Given I am logged in as a user with the "administrator" role | ||
|
||
When I go to "/node/add/article" | ||
And I fill in "Title" with "This!" | ||
And I attach the file "image.png" to "files[field_image_0]" | ||
And I press "Upload" | ||
And I fill in "field_image[0][alt]" with "Nothing" | ||
And I press "Save" | ||
Then I should see the heading "This!" |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
39 changes: 39 additions & 0 deletions
39
src/Drupal/MinkExtension/ServiceContainer/Driver/BrowserKitFactory.php
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
<?php | ||
|
||
namespace Drupal\MinkExtension\ServiceContainer\Driver; | ||
|
||
use Behat\MinkExtension\ServiceContainer\Driver\BrowserKitFactory as BrowserKitFactoryOriginal; | ||
use Behat\Mink\Driver\BrowserKitDriver; | ||
use DrupalFinder\DrupalFinder; | ||
use Symfony\Component\DependencyInjection\Definition; | ||
|
||
class BrowserKitFactory extends BrowserKitFactoryOriginal | ||
{ | ||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function buildDriver(array $config): Definition | ||
{ | ||
if (!class_exists(BrowserKitDriver::class)) { | ||
throw new \RuntimeException( | ||
'Install behat/mink-browserkit-driver in order to use the browserkit_http driver.' | ||
); | ||
} | ||
|
||
$drupalFinder = new DrupalFinder(); | ||
$drupalFinder->locateRoot(getcwd()); | ||
$drupalRoot = $drupalFinder->getDrupalRoot(); | ||
require_once "$drupalRoot/core/tests/Drupal/Tests/DrupalTestBrowser.php"; | ||
|
||
if (!class_exists('Drupal\Tests\DrupalTestBrowser')) { | ||
throw new \RuntimeException( | ||
'Class Drupal\Tests\DrupalTestBrowser not found' | ||
); | ||
} | ||
|
||
return new Definition(BrowserKitDriver::class, [ | ||
new Definition('Drupal\Tests\DrupalTestBrowser'), | ||
'%mink.base_url%', | ||
]); | ||
} | ||
} |
This file contains 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