This repository has been archived by the owner on Nov 27, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
236 additions
and
8 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
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
21 changes: 21 additions & 0 deletions
21
spec/Phpro/MailManager/Service/Factory/MailPluginManagerSpec.php
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,21 @@ | ||
<?php | ||
|
||
namespace spec\Phpro\MailManager\Service\Factory; | ||
|
||
use PhpSpec\ObjectBehavior; | ||
use Prophecy\Argument; | ||
|
||
class MailPluginManagerSpec extends ObjectBehavior | ||
{ | ||
|
||
public function it_is_initializable() | ||
{ | ||
$this->shouldHaveType('Phpro\MailManager\Service\Factory\MailPluginManager'); | ||
} | ||
|
||
public function it_is_a_abstract_plugin_manager_factory() | ||
{ | ||
$this->shouldHaveType('Zend\Mvc\Service\AbstractPluginManagerFactory'); | ||
} | ||
|
||
} |
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 | ||
|
||
namespace spec\Phpro\MailManager\Service; | ||
|
||
use PhpSpec\ObjectBehavior; | ||
use Prophecy\Argument; | ||
|
||
class MailPluginManagerSpec extends ObjectBehavior | ||
{ | ||
/** | ||
* @param \Zend\ServiceManager\ConfigInterface $configuration | ||
*/ | ||
public function let($configuration) | ||
{ | ||
$this->beConstructedWith($configuration); | ||
} | ||
|
||
public function it_is_initializable() | ||
{ | ||
$this->shouldHaveType('Phpro\MailManager\Service\MailPluginManager'); | ||
} | ||
|
||
public function it_is_an_abstract_plugin_manager() | ||
{ | ||
$this->shouldHaveType('Zend\ServiceManager\AbstractPluginManager'); | ||
} | ||
|
||
/** | ||
* @param \Phpro\MailManager\Mail\MailInterface $plugin | ||
* @param \stdClass $invalid | ||
*/ | ||
public function it_should_validate_loaded_instace($plugin, $invalid) | ||
{ | ||
$this->shouldNotThrow()->duringValidatePlugin($plugin); | ||
$this->shouldThrow('\Zend\ServiceManager\Exception\RuntimeException')->duringValidatePlugin($invalid); | ||
} | ||
} |
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
15 changes: 15 additions & 0 deletions
15
src/Phpro/MailManager/Service/Factory/MailPluginManager.php
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,15 @@ | ||
<?php | ||
|
||
namespace Phpro\MailManager\Service\Factory; | ||
|
||
use Zend\Mvc\Service\AbstractPluginManagerFactory; | ||
|
||
/** | ||
* Class TaskPluginManager | ||
* | ||
* @package TaskManager\Service\Factory | ||
*/ | ||
class MailPluginManager extends AbstractPluginManagerFactory | ||
{ | ||
const PLUGIN_MANAGER_CLASS = 'Phpro\MailManager\Service\MailPluginManager'; | ||
} |
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,40 @@ | ||
<?php | ||
|
||
namespace Phpro\MailManager\Service; | ||
|
||
use Phpro\MailManager\Mail\MailInterface; | ||
use Zend\ServiceManager\AbstractPluginManager; | ||
use Zend\ServiceManager\Exception\RuntimeException; | ||
|
||
/** | ||
* Class TaskPluginManager | ||
* | ||
* @package TaskManager\Service | ||
*/ | ||
class MailPluginManager extends AbstractPluginManager | ||
{ | ||
|
||
/** | ||
* Whether or not to share by default | ||
* | ||
* @var bool | ||
*/ | ||
protected $shareByDefault = false; | ||
|
||
/** | ||
* {@inheritDoc} | ||
*/ | ||
public function validatePlugin($plugin) | ||
{ | ||
if ($plugin instanceof MailInterface) { | ||
// we're okay | ||
return; | ||
} | ||
|
||
throw new RuntimeException(sprintf( | ||
'Plugin of type %s is invalid; must implement MailInterface', | ||
(is_object($plugin) ? get_class($plugin) : gettype($plugin)) | ||
)); | ||
} | ||
|
||
} |