1. Go to this page and download the library: Download hostnet/symfony-config-test library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
hostnet / symfony-config-test example snippets
class ConfigurationTest extends \PHPUnit_Framework_TestCase
{
use ConfigurationTestCaseTrait;
protected function getConfiguration()
{
return new Configuration();
}
}
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
use Symfony\Component\Config\Definition\ConfigurationInterface;
class ConfigurationWithRequiredValue implements ConfigurationInterface
{
public function getConfigTreeBuilder()
{
$treeBuilder = new TreeBuilder();
$rootNode = $treeBuilder->root('root');
$rootNode
->isRequired()
->children()
->scalarNode('
class ConfigurationTest extends \PHPUnit_Framework_TestCase
{
use ConfigurationTestCaseTrait;
public function testValuesAreInvalidIfRequiredValueIsNotProvided()
{
$this->assertConfigurationIsInvalid(
array(
array() // no values at all
),
'
class ConfigurationTest extends \PHPUnit_Framework_TestCase
{
use ConfigurationTestCaseTrait;
public function testProcessedValueContainsRequiredValue()
{
$this->assertProcessedConfigurationEquals(array(
array('
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
use Symfony\Component\Config\Definition\ConfigurationInterface;
class ConfigurationWithTwoBranches implements ConfigurationInterface
{
public function getConfigTreeBuilder()
{
$treeBuilder = new TreeBuilder();
$rootNode = $treeBuilder->root('root');
$rootNode
->children()
->arrayNode('array_node_1')
->isRequired()
->children()
->scalarNode('
/**
* @test
*/
public function processed_configuration_for_array_node_1()
{
$this->assertProcessedConfigurationEquals(
array(
array('array_node_1' => array('final value'
)
),
// the path of the nodes you want to focus on in this test:
'array_node_1'
);
}
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
use Symfony\Component\Config\Definition\ConfigurationInterface;
class PrototypedConfiguration implements ConfigurationInterface
{
public function getConfigTreeBuilder()
{
$treeBuilder = new TreeBuilder();
$rootNode = $treeBuilder->root('root');
$rootNode
->children()
->arrayNode('array_node')
->useAttributeAsKey('name')
->prototype('array')
->children()
->scalarNode('default_value')->cannotBeEmpty()->defaultValue('foobar')->end()
->scalarNode('
/**
* @test
*/
public function processed_configuration_for_array_node_1()
{
$this->assertProcessedConfigurationEquals(
array(
array('array_node' => array('prototype_name' => null)),
),
array(
'array_node' => array(
'prototype_name' => array(
'default_value' => 'foobar'
)
)
),
// the path of the nodes you want to focus on in this test:
'array_node.*.default_value'
);
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.