Merge pull request #493 from tgallice/url_parameter_fix
Rework configuration validation to fix #461
This commit is contained in:
commit
245732781b
|
@ -103,8 +103,8 @@ class Configuration implements ConfigurationInterface
|
|||
->children()
|
||||
->scalarNode('url')
|
||||
->validate()
|
||||
->ifTrue(function($v) { return substr($v['url'], -1) !== '/'; })
|
||||
->then(function($v) { return $v['url'].'/'; })
|
||||
->ifTrue(function($url) { return substr($url, -1) !== '/'; })
|
||||
->then(function($url) { return $url.'/'; })
|
||||
->end()
|
||||
->end()
|
||||
->scalarNode('host')->end()
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
namespace FOS\ElasticaBundle\Tests\Resetter\DependencyInjection;
|
||||
|
||||
use FOS\ElasticaBundle\DependencyInjection\Configuration;
|
||||
use Symfony\Component\Config\Definition\Processor;
|
||||
|
||||
/**
|
||||
* ConfigurationTest
|
||||
|
@ -85,4 +86,21 @@ class ConfigurationTest extends \PHPUnit_Framework_TestCase
|
|||
$this->assertInstanceOf('Symfony\Component\Config\Definition\ScalarNode', $mapping['index']);
|
||||
$this->assertNull($mapping['index']->getDefaultValue());
|
||||
}
|
||||
|
||||
public function testSlashIsAddedAtTheEndOfServerUrl()
|
||||
{
|
||||
$config = array(
|
||||
'clients' => array(
|
||||
'default' => array(
|
||||
'url' => 'http://www.github.com',
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
$processor = new Processor();
|
||||
|
||||
$configuration = $processor->processConfiguration($this->configuration, array($config));
|
||||
|
||||
$this->assertEquals('http://www.github.com/', $configuration['clients']['default']['servers'][0]['url']);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue