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 111
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.7.0
- Loading branch information
Showing
9 changed files
with
244 additions
and
1 deletion.
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
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,37 @@ | ||
<?php | ||
/** | ||
* @link http://github.com/zendframework/zend-mail for the canonical source repository | ||
* @copyright Copyright (c) 2005-2016 Zend Technologies USA Inc. (http://www.zend.com) | ||
* @license http://framework.zend.com/license/new-bsd New BSD License | ||
*/ | ||
|
||
namespace Zend\Mail; | ||
|
||
class ConfigProvider | ||
{ | ||
/** | ||
* Retrieve configuration for zend-mail package. | ||
* | ||
* @return array | ||
*/ | ||
public function __invoke() | ||
{ | ||
return [ | ||
'dependencies' => $this->getDependencyConfig(), | ||
]; | ||
} | ||
|
||
/** | ||
* Retrieve dependency settings for zend-mail package. | ||
* | ||
* @return array | ||
*/ | ||
public function getDependencyConfig() | ||
{ | ||
return [ | ||
'factories' => [ | ||
Protocol\SmtpPluginManager::class => Protocol\SmtpPluginManagerFactory::class, | ||
], | ||
]; | ||
} | ||
} |
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,24 @@ | ||
<?php | ||
/** | ||
* @link http://github.com/zendframework/zend-mail for the canonical source repository | ||
* @copyright Copyright (c) 2005-2016 Zend Technologies USA Inc. (http://www.zend.com) | ||
* @license http://framework.zend.com/license/new-bsd New BSD License | ||
*/ | ||
|
||
namespace Zend\Mail; | ||
|
||
class Module | ||
{ | ||
/** | ||
* Retrieve zend-mail package configuration for zend-mvc context. | ||
* | ||
* @return array | ||
*/ | ||
public function getConfig() | ||
{ | ||
$provider = new ConfigProvider(); | ||
return [ | ||
'service_manager' => $provider->getDependencyConfig(), | ||
]; | ||
} | ||
} |
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,53 @@ | ||
<?php | ||
/** | ||
* @link http://github.com/zendframework/zend-mail for the canonical source repository | ||
* @copyright Copyright (c) 2005-2016 Zend Technologies USA Inc. (http://www.zend.com) | ||
* @license http://framework.zend.com/license/new-bsd New BSD License | ||
*/ | ||
|
||
namespace Zend\Mail\Protocol; | ||
|
||
use Interop\Container\ContainerInterface; | ||
use Zend\ServiceManager\FactoryInterface; | ||
use Zend\ServiceManager\ServiceLocatorInterface; | ||
|
||
class SmtpPluginManagerFactory implements FactoryInterface | ||
{ | ||
/** | ||
* zend-servicemanager v2 support for invocation options. | ||
* | ||
* @param array | ||
*/ | ||
protected $creationOptions; | ||
|
||
/** | ||
* {@inheritDoc} | ||
* | ||
* @return SmtpPluginManager | ||
*/ | ||
public function __invoke(ContainerInterface $container, $name, array $options = null) | ||
{ | ||
return new SmtpPluginManager($container, $options ?: []); | ||
} | ||
|
||
/** | ||
* {@inheritDoc} | ||
* | ||
* @return SmtpPluginManager | ||
*/ | ||
public function createService(ServiceLocatorInterface $container, $name = null, $requestedName = null) | ||
{ | ||
return $this($container, $requestedName ?: SmtpPluginManager::class, $this->creationOptions); | ||
} | ||
|
||
/** | ||
* zend-servicemanager v2 support for invocation options. | ||
* | ||
* @param array $options | ||
* @return void | ||
*/ | ||
public function setCreationOptions(array $options) | ||
{ | ||
$this->creationOptions = $options; | ||
} | ||
} |
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,73 @@ | ||
<?php | ||
/** | ||
* @link http://github.com/zendframework/zend-mail for the canonical source repository | ||
* @copyright Copyright (c) 2005-2016 Zend Technologies USA Inc. (http://www.zend.com) | ||
* @license http://framework.zend.com/license/new-bsd New BSD License | ||
*/ | ||
|
||
namespace ZendTest\Mail\Protocol; | ||
|
||
use Interop\Container\ContainerInterface; | ||
use PHPUnit_Framework_TestCase as TestCase; | ||
use Zend\Mail\Protocol\Smtp; | ||
use Zend\Mail\Protocol\SmtpPluginManager; | ||
use Zend\Mail\Protocol\SmtpPluginManagerFactory; | ||
use Zend\ServiceManager\ServiceLocatorInterface; | ||
|
||
class SmtpPluginManagerFactoryTest extends TestCase | ||
{ | ||
public function testFactoryReturnsPluginManager() | ||
{ | ||
$container = $this->prophesize(ContainerInterface::class)->reveal(); | ||
$factory = new SmtpPluginManagerFactory(); | ||
|
||
$plugins = $factory($container, SmtpPluginManager::class); | ||
$this->assertInstanceOf(SmtpPluginManager::class, $plugins); | ||
|
||
if (method_exists($plugins, 'configure')) { | ||
// zend-servicemanager v3 | ||
$this->assertAttributeSame($container, 'creationContext', $plugins); | ||
} else { | ||
// zend-servicemanager v2 | ||
$this->assertSame($container, $plugins->getServiceLocator()); | ||
} | ||
} | ||
|
||
/** | ||
* @depends testFactoryReturnsPluginManager | ||
*/ | ||
public function testFactoryConfiguresPluginManagerUnderContainerInterop() | ||
{ | ||
$container = $this->prophesize(ContainerInterface::class)->reveal(); | ||
$smtp = $this->prophesize(Smtp::class)->reveal(); | ||
|
||
$factory = new SmtpPluginManagerFactory(); | ||
$plugins = $factory($container, SmtpPluginManager::class, [ | ||
'services' => [ | ||
'test' => $smtp, | ||
], | ||
]); | ||
$this->assertSame($smtp, $plugins->get('test')); | ||
} | ||
|
||
/** | ||
* @depends testFactoryReturnsPluginManager | ||
*/ | ||
public function testFactoryConfiguresPluginManagerUnderServiceManagerV2() | ||
{ | ||
$container = $this->prophesize(ServiceLocatorInterface::class); | ||
$container->willImplement(ContainerInterface::class); | ||
|
||
$smtp = $this->prophesize(Smtp::class)->reveal(); | ||
|
||
$factory = new SmtpPluginManagerFactory(); | ||
$factory->setCreationOptions([ | ||
'services' => [ | ||
'test' => $smtp, | ||
], | ||
]); | ||
|
||
$plugins = $factory->createService($container->reveal()); | ||
$this->assertSame($smtp, $plugins->get('test')); | ||
} | ||
} |
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