forked from Behat/MinkExtension
-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
99 additions
and
0 deletions.
There are no files selected for viewing
24 changes: 24 additions & 0 deletions
24
spec/Behat/MinkExtension/ServiceContainer/Driver/BrowserKitFactorySpec.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,24 @@ | ||
<?php | ||
|
||
namespace spec\Behat\MinkExtension\ServiceContainer\Driver; | ||
|
||
use PhpSpec\ObjectBehavior; | ||
use Behat\MinkExtension\ServiceContainer\Driver\DriverFactory; | ||
|
||
class BrowserKitFactorySpec extends ObjectBehavior | ||
{ | ||
function it_is_a_driver_factory() | ||
{ | ||
$this->shouldHaveType(DriverFactory::class); | ||
} | ||
|
||
function it_is_named_browserkit() | ||
{ | ||
$this->getDriverName()->shouldReturn('browserkit'); | ||
} | ||
|
||
function it_does_not_support_javascript() | ||
{ | ||
$this->supportsJavascript()->shouldBe(false); | ||
} | ||
} |
73 changes: 73 additions & 0 deletions
73
src/Behat/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,73 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the Behat MinkExtension. | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Behat\MinkExtension\ServiceContainer\Driver; | ||
|
||
use Behat\Mink\Driver\BrowserKitDriver; | ||
use Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition; | ||
use Symfony\Component\DependencyInjection\Definition; | ||
use Symfony\Component\BrowserKit\HttpBrowser; | ||
|
||
|
||
class BrowserKitFactory implements DriverFactory | ||
{ | ||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function getDriverName() | ||
{ | ||
return 'browserkit'; | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function supportsJavascript() | ||
{ | ||
return false; | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function configure(ArrayNodeDefinition $builder) | ||
{ | ||
$builder | ||
->children() | ||
->scalarNode('class')->cannotBeEmpty()->end() | ||
->end() | ||
; | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function buildDriver(array $config) | ||
{ | ||
if (!class_exists(BrowserKitDriver::class)) { | ||
throw new \RuntimeException( | ||
'Install BrowserKit in order to use browserkit driver.' | ||
); | ||
} | ||
|
||
if (class_exists(HttpBrowser::class)) { | ||
$clientDefinition = new Definition(HttpBrowser::class); | ||
} else { | ||
throw new \RuntimeException( | ||
sprintf('No implementation of class %s found.', HttpBrowser::class) | ||
); | ||
} | ||
|
||
return new Definition(BrowserKitDriver::class, [ | ||
$clientDefinition, | ||
'%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