Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[DependencyInjection] use/fix newest Definition::setFactory
- Loading branch information
1 parent
72c169e
commit f683a7a
Showing
8 changed files
with
102 additions
and
64 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,9 +16,12 @@ | |
</parameters> | ||
|
||
<services> | ||
<service id="validator" class="%validator.class%" factory-service="validator.builder" factory-method="getValidator" /> | ||
<service id="validator" class="%validator.class%"> | ||
<factory service="validator.builder" method="getValidator" /> | ||
</service> | ||
|
||
<service id="validator.builder" class="%validator.builder.class%" factory-class="%validator.builder.factory.class%" factory-method="createValidatorBuilder"> | ||
<service id="validator.builder" class="%validator.builder.class%"> | ||
<factory class="%validator.builder.factory.class%" method="createValidatorBuilder" /> | ||
<call method="setConstraintValidatorFactory"> | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
nicolas-grekas
Author
Member
|
||
<argument type="service" id="validator.validator_factory" /> | ||
</call> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
src/Symfony/Component/DependencyInjection/Tests/LegacyContainerBuilderTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the Symfony package. | ||
* | ||
* (c) Fabien Potencier <fabien@symfony.com> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Symfony\Component\DependencyInjection\Tests; | ||
|
||
use Symfony\Component\DependencyInjection\ContainerBuilder; | ||
use Symfony\Component\DependencyInjection\Reference; | ||
|
||
class LegacyContainerBuilderTest extends \PHPUnit_Framework_TestCase | ||
{ | ||
/** | ||
* @covers Symfony\Component\DependencyInjection\ContainerBuilder::createService | ||
*/ | ||
public function testCreateServiceFactoryMethod() | ||
{ | ||
$builder = new ContainerBuilder(); | ||
$builder->register('bar', 'stdClass'); | ||
$builder->register('foo1', 'Bar\FooClass')->setFactoryClass('Bar\FooClass')->setFactoryMethod('getInstance')->addArgument(array('foo' => '%value%', '%value%' => 'foo', new Reference('bar'))); | ||
$builder->setParameter('value', 'bar'); | ||
$this->assertTrue($builder->get('foo1')->called, '->createService() calls the factory method to create the service instance'); | ||
$this->assertEquals(array('foo' => 'bar', 'bar' => 'foo', $builder->get('bar')), $builder->get('foo1')->arguments, '->createService() passes the arguments to the factory method'); | ||
} | ||
|
||
/** | ||
* @covers Symfony\Component\DependencyInjection\ContainerBuilder::createService | ||
*/ | ||
public function testCreateServiceFactoryService() | ||
{ | ||
$builder = new ContainerBuilder(); | ||
$builder->register('baz_service')->setFactoryService('baz_factory')->setFactoryMethod('getInstance'); | ||
$builder->register('baz_factory', 'BazClass'); | ||
|
||
$this->assertInstanceOf('BazClass', $builder->get('baz_service')); | ||
} | ||
} |
41 changes: 41 additions & 0 deletions
41
src/Symfony/Component/DependencyInjection/Tests/LegacyDefinitionTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the Symfony package. | ||
* | ||
* (c) Fabien Potencier <fabien@symfony.com> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Symfony\Component\DependencyInjection\Tests; | ||
|
||
use Symfony\Component\DependencyInjection\Definition; | ||
|
||
class LegacyDefinitionTest extends \PHPUnit_Framework_TestCase | ||
{ | ||
public function testSetGetFactoryClass() | ||
{ | ||
$def = new Definition('stdClass'); | ||
$this->assertNull($def->getFactoryClass()); | ||
$this->assertSame($def, $def->setFactoryClass('stdClass2'), "->setFactoryClass() implements a fluent interface."); | ||
$this->assertEquals('stdClass2', $def->getFactoryClass(), "->getFactoryClass() returns current class to construct this service."); | ||
} | ||
|
||
public function testSetGetFactoryMethod() | ||
{ | ||
$def = new Definition('stdClass'); | ||
$this->assertNull($def->getFactoryMethod()); | ||
$this->assertSame($def, $def->setFactoryMethod('foo'), '->setFactoryMethod() implements a fluent interface'); | ||
$this->assertEquals('foo', $def->getFactoryMethod(), '->getFactoryMethod() returns the factory method name'); | ||
} | ||
|
||
public function testSetGetFactoryService() | ||
{ | ||
$def = new Definition('stdClass'); | ||
$this->assertNull($def->getFactoryService()); | ||
$this->assertSame($def, $def->setFactoryService('foo.bar'), "->setFactoryService() implements a fluent interface."); | ||
$this->assertEquals('foo.bar', $def->getFactoryService(), "->getFactoryService() returns current service to construct this service."); | ||
} | ||
} |
I believe this is the source of the error I am getting right now when I do
composer update
: