Skip to content
This repository has been archived by the owner on Jan 30, 2020. It is now read-only.

Commit

Permalink
Merging develop to master in preparation for 2.7.0
Browse files Browse the repository at this point in the history
  • Loading branch information
weierophinney committed Apr 11, 2016
2 parents 4e99454 + 292a06a commit a896856
Show file tree
Hide file tree
Showing 9 changed files with 244 additions and 1 deletion.
25 changes: 25 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,31 @@

All notable changes to this project will be documented in this file, in reverse chronological order by release.

## 2.7.0 - TBD

### Added

- [#41](https://github.com/zendframework/zend-mail/pull/41) adds support for
IMAP delimiters in the IMAP storage adapter.
- [#80](https://github.com/zendframework/zend-mail/pull/80) adds:
- `Zend\Mail\Protocol\SmtpPluginManagerFactory`, for creating and returning an
`SmtpPluginManagerFactory` instance.
- `Zend\Mail\ConfigProvider`, which maps the `SmtpPluginManager` to the above
factory.
- `Zend\Mail\Module`, which does the same, for zend-mvc contexts.

### Deprecated

- Nothing.

### Removed

- Nothing.

### Fixed

- Nothing.

## 2.6.2 - 2016-04-11

### Added
Expand Down
4 changes: 4 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@
"branch-alias": {
"dev-master": "2.6-dev",
"dev-develop": "2.7-dev"
},
"zf": {
"component": "Zend\\Mail",
"config-provider": "Zend\\Mail\\ConfigProvider"
}
},
"autoload-dev": {
Expand Down
37 changes: 37 additions & 0 deletions src/ConfigProvider.php
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,
],
];
}
}
24 changes: 24 additions & 0 deletions src/Module.php
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(),
];
}
}
2 changes: 1 addition & 1 deletion src/Protocol/SmtpPluginManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ class SmtpPluginManager extends AbstractPluginManager
'zendmailprotocolsmtpauthcrammd5' => InvokableFactory::class,
'zendmailprotocolsmtpauthlogin' => InvokableFactory::class,
'zendmailprotocolsmtpauthplain' => InvokableFactory::class,
'zendmailprotocolsmtp' => InvokableFactory::class,
'zendmailprotocolsmtp' => InvokableFactory::class,
];

/**
Expand Down
53 changes: 53 additions & 0 deletions src/Protocol/SmtpPluginManagerFactory.php
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;
}
}
20 changes: 20 additions & 0 deletions src/Storage/Imap.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,12 @@ class Imap extends AbstractStorage implements Folder\FolderInterface, Writable\W
*/
protected $currentFolder = '';

/**
* IMAP folder delimiter character
* @var null|string
*/
protected $delimiter;

/**
* IMAP flags to constants translation
* @var array
Expand Down Expand Up @@ -331,6 +337,7 @@ public function getFolders($rootFolder = null)
$parentFolder->$localName = $folder;
array_push($folderStack, $parentFolder);
$parentFolder = $folder;
$this->delimiter = $data['delim'];
break;
} elseif ($stack) {
$parent = array_pop($stack);
Expand Down Expand Up @@ -504,4 +511,17 @@ public function setFlags($id, $flags)
throw new Exception\RuntimeException('cannot set flags, have you tried to set the recent flag or special chars?');
}
}

/**
* get IMAP delimiter
*
* @return string|null
*/
public function delimiter()
{
if (!isset($this->delimiter)) {
$this->getFolders();
}
return $this->delimiter;
}
}
73 changes: 73 additions & 0 deletions test/Protocol/SmtpPluginManagerFactoryTest.php
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'));
}
}
7 changes: 7 additions & 0 deletions test/Storage/ImapTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -700,4 +700,11 @@ public function testCountFlags()
$this->assertEquals($mail->countMessages([Storage::FLAG_SEEN, Storage::FLAG_FLAGGED]), 0);
$this->assertEquals($mail->countMessages(Storage::FLAG_FLAGGED), 0);
}

public function testDelimiter()
{
$mail = new Storage\Imap($this->params);
$delimiter = $mail->delimiter();
$this->assertEquals(strlen($delimiter), 1);
}
}

0 comments on commit a896856

Please sign in to comment.