123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566 |
- <?php
- /**
- * @file
- * MyAwesomeExtension.php
- *
- * @author: marand
- *
- * @copyright (c) 2014 Ouest Systèmes Informatiques (OSInet).
- *
- * @license General Public License version 2 or later
- */
- use Behat\Behat\Context\BehatContext;
- use Behat\Behat\Context\ClassGuesser\ClassGuesserInterface;
- use Behat\Behat\Context\ContextInterface;
- use Behat\Behat\Context\Initializer\InitializerInterface;
- use Behat\Behat\Extension\Extension;
- use Behat\Mink\Mink;
- use Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition;
- use Symfony\Component\Config\FileLocator;
- use Symfony\Component\DependencyInjection\ContainerBuilder;
- use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
- class MyAwesomeExtension extends Extension {
- public function load(array $config, ContainerBuilder $container) {
- print_r($config);
- $loader = new XmlFileLoader($container, new FileLocator(__DIR__));
- $loader->load('services.xml');
- }
- }
- class YourCustomContext extends BehatContext {
- /**
- * @beforeSuite
- */
- public static function bS() {
- echo __METHOD__ . "\n";
- }
- }
- class MinkAwareInitializer implements InitializerInterface {
- private $mink;
- public function __construct(Mink $mink) {
- $this->mink = $mink;
- }
- public function supports(ContextInterface $context) {
- // in real life you should use interface for that
- return method_exists($context, 'setMink');
- }
- public function initialize(ContextInterface $context) {
- $context->setMink($this->mink);
- }
- }
- class MinkContextClassGuesser implements ClassGuesserInterface {
- public function guess() {
- return "YourCustomContext";
- }
- }
- #return new MyAwesomeExtension();
|