Security update for permissions_by_term
[yaffs-website] / vendor / drupal / drupal-extension / src / Drupal / DrupalExtension / Context / ContextClass / ClassGenerator.php
1 <?php
2
3 namespace Drupal\DrupalExtension\Context\ContextClass;
4
5 use Behat\Behat\Context\ContextClass\ClassGenerator as BehatClassGenerator;
6 use Behat\Testwork\Suite\Suite;
7
8 /**
9  * Generates a starting class that extends the RawDrupalContext.
10  */
11 class ClassGenerator implements BehatClassGenerator {
12
13   /**
14    * @var string
15    */
16   protected static $template = <<<'PHP'
17 <?php
18
19 {namespace}use Drupal\DrupalExtension\Context\RawDrupalContext;
20 use Behat\Behat\Context\SnippetAcceptingContext;
21 use Behat\Gherkin\Node\PyStringNode;
22 use Behat\Gherkin\Node\TableNode;
23 use Behat\Behat\Tester\Exception\PendingException;
24
25 /**
26  * Defines application features from the specific context.
27  */
28 class {className} extends RawDrupalContext implements SnippetAcceptingContext {
29
30   /**
31    * Initializes context.
32    *
33    * Every scenario gets its own context instance.
34    * You can also pass arbitrary arguments to the
35    * context constructor through behat.yml.
36    */
37   public function __construct() {
38   }
39
40 }
41
42 PHP;
43
44   /**
45    * {@inheritdoc}
46    */
47   public function supportsSuiteAndClass(Suite $suite, $contextClass) {
48     return TRUE;
49   }
50
51   /**
52    * {@inheritdoc}
53    */
54   public function generateClass(Suite $suite, $contextClass) {
55     $fqn = $contextClass;
56
57     $namespace = '';
58     if (false !== $pos = strrpos($fqn, '\\')) {
59       $namespace = 'namespace ' . substr($fqn, 0, $pos) . ";\n\n";
60       $contextClass = substr($fqn, $pos + 1);
61     }
62
63     return strtr(
64       static::$template,
65       array(
66         '{namespace}' => $namespace,
67         '{className}' => $contextClass,
68       )
69     );
70   }
71 }