2012-08-15 16:50:19 +02:00
|
|
|
<?php
|
|
|
|
|
2012-10-16 22:01:16 +02:00
|
|
|
namespace SilverStripe\BehatExtension\Compiler;
|
2012-08-15 16:50:19 +02:00
|
|
|
|
|
|
|
use Symfony\Component\DependencyInjection\ContainerBuilder,
|
|
|
|
Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
|
|
|
|
|
|
|
|
/*
|
2012-10-16 22:01:16 +02:00
|
|
|
* This file is part of the SilverStripe\BehatExtension
|
2012-08-15 16:50:19 +02:00
|
|
|
*
|
|
|
|
* (c) Michał Ochman <ochman.d.michal@gmail.com>
|
|
|
|
*
|
|
|
|
* This source file is subject to the MIT license that is bundled
|
|
|
|
* with this source code in the file LICENSE.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Behat\SilverStripe container compilation pass.
|
|
|
|
* Passes Base URL available in MinkExtension config.
|
|
|
|
*
|
|
|
|
* @author Michał Ochman <ochman.d.michal@gmail.com>
|
|
|
|
*/
|
|
|
|
class MinkExtensionBaseUrlPass implements CompilerPassInterface
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* Passes MinkExtension's base_url parameter
|
|
|
|
*
|
|
|
|
* @param ContainerBuilder $container
|
|
|
|
*/
|
|
|
|
public function process(ContainerBuilder $container)
|
|
|
|
{
|
|
|
|
if (!$container->hasDefinition('behat.mink')) {
|
|
|
|
throw new \Exception('MinkExtension not defined');
|
|
|
|
}
|
|
|
|
if (!$container->hasParameter('behat.mink.base_url')) {
|
|
|
|
throw new \Exception('MinkExtension improperly configured. Missing base_url parameter.');
|
|
|
|
}
|
2012-11-15 18:12:21 +01:00
|
|
|
$baseUrl = $container->getParameter('behat.mink.base_url');
|
|
|
|
if (empty($baseUrl)) {
|
2012-08-15 16:50:19 +02:00
|
|
|
throw new \Exception('MinkExtension improperly configured. Missing or empty base_url parameter.');
|
|
|
|
}
|
2012-11-15 18:12:21 +01:00
|
|
|
$container->setParameter('behat.silverstripe_extension.framework_host', $baseUrl);
|
2012-08-15 16:50:19 +02:00
|
|
|
}
|
|
|
|
}
|