This repository has been archived by the owner on Jan 30, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 51
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merging develop to master in preparation for 2.12.0 release.
- Loading branch information
Showing
9 changed files
with
211 additions
and
28 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<?php | ||
/** | ||
* Zend Framework (http://framework.zend.com/) | ||
* | ||
* @link http://github.com/zendframework/zend-log for the canonical source repository | ||
* @copyright Copyright (c) 2019 Zend Technologies USA Inc. (http://www.zend.com) | ||
* @license http://framework.zend.com/license/new-bsd New BSD License | ||
*/ | ||
|
||
namespace Zend\Log; | ||
|
||
use Interop\Container\ContainerInterface; | ||
|
||
/** | ||
* PSR Logger abstract service factory. | ||
* | ||
* Allow to configure multiple loggers for application. | ||
*/ | ||
class PsrLoggerAbstractAdapterFactory extends LoggerAbstractServiceFactory | ||
{ | ||
/** | ||
* Configuration key holding logger configuration | ||
* | ||
* @var string | ||
*/ | ||
protected $configKey = 'psr_log'; | ||
|
||
public function __invoke(ContainerInterface $container, $requestedName, array $options = null) | ||
{ | ||
$logger = parent::__invoke($container, $requestedName, $options); | ||
|
||
return new PsrLoggerAdapter($logger); | ||
} | ||
} |
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,88 @@ | ||
<?php | ||
/** | ||
* Zend Framework (http://framework.zend.com/) | ||
* | ||
* @link http://github.com/zendframework/zend-log for the canonical source repository | ||
* @copyright Copyright (c) 2019 Zend Technologies USA Inc. (http://www.zend.com) | ||
* @license http://framework.zend.com/license/new-bsd New BSD License | ||
*/ | ||
|
||
namespace ZendTest\Log; | ||
|
||
use PHPUnit\Framework\TestCase; | ||
use Zend\Log\PsrLoggerAbstractAdapterFactory; | ||
use Zend\ServiceManager\Config; | ||
use Zend\ServiceManager\Exception\ServiceNotFoundException; | ||
use Zend\ServiceManager\ServiceManager; | ||
|
||
class PsrLoggerAbstractAdapterFactoryTest extends TestCase | ||
{ | ||
/** | ||
* @var \Zend\ServiceManager\ServiceLocatorInterface | ||
*/ | ||
protected $serviceManager; | ||
|
||
/** | ||
* Set up LoggerAbstractServiceFactory and loggers configuration. | ||
*/ | ||
protected function setUp() | ||
{ | ||
$this->serviceManager = new ServiceManager(); | ||
$config = new Config([ | ||
'abstract_factories' => [PsrLoggerAbstractAdapterFactory::class], | ||
'services' => [ | ||
'config' => [ | ||
'psr_log' => [ | ||
'Application\Frontend' => [], | ||
'Application\Backend' => [], | ||
], | ||
], | ||
], | ||
]); | ||
$config->configureServiceManager($this->serviceManager); | ||
} | ||
|
||
/** | ||
* @return array | ||
*/ | ||
public function providerValidLoggerService() | ||
{ | ||
return [ | ||
['Application\Frontend'], | ||
['Application\Backend'], | ||
]; | ||
} | ||
|
||
/** | ||
* @return array | ||
*/ | ||
public function providerInvalidLoggerService() | ||
{ | ||
return [ | ||
['Logger\Application\Unknown'], | ||
['Logger\Application\Frontend'], | ||
['Application\Backend\Logger'], | ||
]; | ||
} | ||
|
||
/** | ||
* @param string $service | ||
* @dataProvider providerValidLoggerService | ||
*/ | ||
public function testValidLoggerService($service) | ||
{ | ||
$actual = $this->serviceManager->get($service); | ||
$this->assertInstanceOf('Zend\Log\PsrLoggerAdapter', $actual); | ||
} | ||
|
||
/** | ||
* @dataProvider providerInvalidLoggerService | ||
* | ||
* @param string $service | ||
*/ | ||
public function testInvalidLoggerService($service) | ||
{ | ||
$this->expectException(ServiceNotFoundException::class); | ||
$this->serviceManager->get($service); | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.