Skip to content

Commit

Permalink
Merge pull request #18 from cap-collectif/master
Browse files Browse the repository at this point in the history
Support FQCN services names
  • Loading branch information
mcg-web authored Jul 25, 2018
2 parents c1ae88a + 8756ae2 commit a1deeca
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
2 changes: 1 addition & 1 deletion DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

class Configuration implements ConfigurationInterface
{
const SERVICE_CALLABLE_NOTATION_REGEX = '/^@(?<service_id>[a-z0-9\._]+)(?:\:(?<method>[a-zA-Z_\x7f-\xff][a-z0-9_\x7f-\xff]*))?$/i';
const SERVICE_CALLABLE_NOTATION_REGEX = '/^@(?<service_id>[a-z0-9\._\\\]+)(?:\:(?<method>[a-zA-Z_\x7f-\xff][a-z0-9_\x7f-\xff]*))?$/iu';
const PHP_CALLABLE_NOTATION_REGEX = '/^(?<function>(?:\\\\?[a-z_\x7f-\xff][a-z0-9_\x7f-\xff]*)+)(?:\:\:(?<method>[a-z_\x7f-\xff][a-z0-9_\x7f-\xff]*))?$/i';

public function getConfigTreeBuilder()
Expand Down
17 changes: 17 additions & 0 deletions Tests/DependencyInjection/OverblogDataLoaderExtensionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

namespace Overblog\DataLoaderBundle\Tests\DependencyInjection;

use Overblog\DataLoaderBundle\DependencyInjection\Configuration;
use Overblog\DataLoaderBundle\DependencyInjection\OverblogDataLoaderExtension;
use PHPUnit\Framework\TestCase;
use Symfony\Component\DependencyInjection\Alias;
Expand Down Expand Up @@ -41,6 +42,22 @@ public function tearDown()
unset($this->container, $this->extension);
}

public function testValidServiceCallableNodeValue()
{
$validValues = ['@app.user:getUsers', '@App\\Loader\\User:all'];
foreach ($validValues as $validValue) {
$this->assertRegExp(Configuration::SERVICE_CALLABLE_NOTATION_REGEX, $validValue);
}
}

public function testValidPhpCallableNodeValue()
{
$validValues = ['Image\\Loader::get', 'Post::getPosts'];
foreach ($validValues as $validValue) {
$this->assertRegExp(Configuration::PHP_CALLABLE_NOTATION_REGEX, $validValue);
}
}

public function testUsersDataLoaderConfig()
{
$this->loadValidConfig();
Expand Down

0 comments on commit a1deeca

Please sign in to comment.