Neos\Flow\I18n\FormatResolver::injectObjectManager PHP Method

injectObjectManager() public method

public injectObjectManager ( Neos\Flow\ObjectManagement\ObjectManagerInterface $objectManager ) : void
$objectManager Neos\Flow\ObjectManagement\ObjectManagerInterface
return void
    public function injectObjectManager(ObjectManagerInterface $objectManager)
    {
        $this->objectManager = $objectManager;
    }

Usage Example

 /**
  * @test
  */
 public function fullyQualifiedFormatterWithLowercaseVendorNameIsCorrectlyBeingUsed()
 {
     $mockFormatter = $this->createMock(I18n\Formatter\FormatterInterface::class);
     $mockFormatter->expects($this->once())->method('format')->with(123, $this->sampleLocale, [])->will($this->returnValue('FormatterOutput42'));
     $mockObjectManager = $this->createMock(ObjectManagerInterface::class);
     $mockObjectManager->expects($this->once())->method('isRegistered')->with('acme\\Foo\\SampleFormatter')->will($this->returnValue(true));
     $mockObjectManager->expects($this->once())->method('get')->with('acme\\Foo\\SampleFormatter')->will($this->returnValue($mockFormatter));
     $mockReflectionService = $this->createMock(ReflectionService::class);
     $mockReflectionService->expects($this->once())->method('isClassImplementationOf')->with('acme\\Foo\\SampleFormatter', I18n\Formatter\FormatterInterface::class)->will($this->returnValue(true));
     $formatResolver = new I18n\FormatResolver();
     $formatResolver->injectObjectManager($mockObjectManager);
     $this->inject($formatResolver, 'reflectionService', $mockReflectionService);
     $actual = $formatResolver->resolvePlaceholders('{0,acme\\Foo\\SampleFormatter}', [123], $this->sampleLocale);
     $this->assertEquals('FormatterOutput42', $actual);
 }