Skip to content

Commit

Permalink
Merge branch 'phcorp-feat/all-panther-options'
Browse files Browse the repository at this point in the history
  • Loading branch information
robertfausk committed Mar 14, 2021
2 parents b540bfd + 0c111b1 commit c163b73
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 1 deletion.
4 changes: 4 additions & 0 deletions src/ServiceContainer/Driver/PantherFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ public function configure(ArrayNodeDefinition $builder)
{
$configuration = new PantherConfiguration();
$builder->append($configuration->addOptionsNode());
$builder->append($configuration->addKernelOptionsNode());
$builder->append($configuration->addManagerOptionsNode());
}

/**
Expand All @@ -53,6 +55,8 @@ public function buildDriver(array $config)
'Behat\Mink\Driver\PantherDriver',
array(
$config['options'] ?? [],
$config['kernel_options'] ?? [],
$config['manager_options'] ?? [],
)
);
}
Expand Down
50 changes: 49 additions & 1 deletion src/ServiceContainer/PantherConfiguration.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,11 @@ public function getConfigTreeBuilder()
$root = $treeBuilder->root('panther');
}

$root->append($this->addOptionsNode());
$root->children()
->append($this->addOptionsNode())
->append($this->addKernelOptionsNode())
->append($this->addManagerOptionsNode())
->end();

return $treeBuilder;
}
Expand All @@ -50,4 +54,48 @@ public function addOptionsNode(): ArrayNodeDefinition

return $node;
}

public function addKernelOptionsNode(): ArrayNodeDefinition
{
$treeBuilder = new TreeBuilder('kernel_options');

if (\method_exists($treeBuilder, 'getRootNode')) {
$root = $treeBuilder->getRootNode();
} else {
$root = $treeBuilder->root('kernel_options');
}

$node = $root
->info(
"These are the options passed as second argument to PantherTestCaseTrait::createPantherClient client constructor."
)
->ignoreExtraKeys()
->scalarPrototype()
->end()
;

return $node;
}

public function addManagerOptionsNode(): ArrayNodeDefinition
{
$treeBuilder = new TreeBuilder('manager_options');

if (\method_exists($treeBuilder, 'getRootNode')) {
$root = $treeBuilder->getRootNode();
} else {
$root = $treeBuilder->root('manager_options');
}

$node = $root
->info(
"These are the options passed as third argument to PantherTestCaseTrait::createPantherClient client constructor."
)
->ignoreExtraKeys()
->scalarPrototype()
->end()
;

return $node;
}
}
2 changes: 2 additions & 0 deletions tests/Unit/PantherConfigurationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ public function test_processed_configuration(): void
'options' => [
'hostname' => '127.0.0.1',
],
'kernel_options' => [],
'manager_options' => [],
]
);
}
Expand Down

0 comments on commit c163b73

Please sign in to comment.