public function testBasicUsage() { $serviceLocator = $this->getMockBuilder(ServiceLocatorInterface::class)->getMock(); $serviceLocator->expects($this->any())->method('get')->willReturn(['email' => ['from' => '*****@*****.**', 'transport' => ['type' => 'null', 'options' => []]]]); $serviceFactory = new EmailServiceFactory(); $this->assertInstanceOf(EmailInterface::class, $serviceFactory->createService($serviceLocator)); }
/** * @param ContainerInterface $container * @param string $requestedName * @param array|null $options * @return \Webowy\Email\EmailInterface */ public function __invoke(ContainerInterface $container, $requestedName, array $options = null) { $config = $this->getConfig($container); $config = $config[$requestedName]; $factory = new EmailServiceFactory(); return $factory->createEmail(new EmailOptions($config)); }