LegacyDefinitionTest.php 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. <?php
  2. /*
  3. * This file is part of the Symfony package.
  4. *
  5. * (c) Fabien Potencier <fabien@symfony.com>
  6. *
  7. * For the full copyright and license information, please view the LICENSE
  8. * file that was distributed with this source code.
  9. */
  10. namespace Symfony\Component\DependencyInjection\Tests;
  11. use PHPUnit\Framework\TestCase;
  12. use Symfony\Component\DependencyInjection\Definition;
  13. /**
  14. * @group legacy
  15. */
  16. class LegacyDefinitionTest extends TestCase
  17. {
  18. public function testSetGetFactoryClass()
  19. {
  20. $def = new Definition('stdClass');
  21. $this->assertNull($def->getFactoryClass());
  22. $this->assertSame($def, $def->setFactoryClass('stdClass2'), '->setFactoryClass() implements a fluent interface.');
  23. $this->assertEquals('stdClass2', $def->getFactoryClass(), '->getFactoryClass() returns current class to construct this service.');
  24. }
  25. public function testSetGetFactoryMethod()
  26. {
  27. $def = new Definition('stdClass');
  28. $this->assertNull($def->getFactoryMethod());
  29. $this->assertSame($def, $def->setFactoryMethod('foo'), '->setFactoryMethod() implements a fluent interface');
  30. $this->assertEquals('foo', $def->getFactoryMethod(), '->getFactoryMethod() returns the factory method name');
  31. }
  32. public function testSetGetFactoryService()
  33. {
  34. $def = new Definition('stdClass');
  35. $this->assertNull($def->getFactoryService());
  36. $this->assertSame($def, $def->setFactoryService('foo.bar'), '->setFactoryService() implements a fluent interface.');
  37. $this->assertEquals('foo.bar', $def->getFactoryService(), '->getFactoryService() returns current service to construct this service.');
  38. }
  39. }