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

Commit a896856

Browse files
committed
Merging develop to master in preparation for 2.7.0
2 parents 4e99454 + 292a06a commit a896856

File tree

9 files changed

+244
-1
lines changed

9 files changed

+244
-1
lines changed

CHANGELOG.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,31 @@
22

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

5+
## 2.7.0 - TBD
6+
7+
### Added
8+
9+
- [#41](https://github.com/zendframework/zend-mail/pull/41) adds support for
10+
IMAP delimiters in the IMAP storage adapter.
11+
- [#80](https://github.com/zendframework/zend-mail/pull/80) adds:
12+
- `Zend\Mail\Protocol\SmtpPluginManagerFactory`, for creating and returning an
13+
`SmtpPluginManagerFactory` instance.
14+
- `Zend\Mail\ConfigProvider`, which maps the `SmtpPluginManager` to the above
15+
factory.
16+
- `Zend\Mail\Module`, which does the same, for zend-mvc contexts.
17+
18+
### Deprecated
19+
20+
- Nothing.
21+
22+
### Removed
23+
24+
- Nothing.
25+
26+
### Fixed
27+
28+
- Nothing.
29+
530
## 2.6.2 - 2016-04-11
631

732
### Added

composer.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,10 @@
3636
"branch-alias": {
3737
"dev-master": "2.6-dev",
3838
"dev-develop": "2.7-dev"
39+
},
40+
"zf": {
41+
"component": "Zend\\Mail",
42+
"config-provider": "Zend\\Mail\\ConfigProvider"
3943
}
4044
},
4145
"autoload-dev": {

src/ConfigProvider.php

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
<?php
2+
/**
3+
* @link http://github.com/zendframework/zend-mail for the canonical source repository
4+
* @copyright Copyright (c) 2005-2016 Zend Technologies USA Inc. (http://www.zend.com)
5+
* @license http://framework.zend.com/license/new-bsd New BSD License
6+
*/
7+
8+
namespace Zend\Mail;
9+
10+
class ConfigProvider
11+
{
12+
/**
13+
* Retrieve configuration for zend-mail package.
14+
*
15+
* @return array
16+
*/
17+
public function __invoke()
18+
{
19+
return [
20+
'dependencies' => $this->getDependencyConfig(),
21+
];
22+
}
23+
24+
/**
25+
* Retrieve dependency settings for zend-mail package.
26+
*
27+
* @return array
28+
*/
29+
public function getDependencyConfig()
30+
{
31+
return [
32+
'factories' => [
33+
Protocol\SmtpPluginManager::class => Protocol\SmtpPluginManagerFactory::class,
34+
],
35+
];
36+
}
37+
}

src/Module.php

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<?php
2+
/**
3+
* @link http://github.com/zendframework/zend-mail for the canonical source repository
4+
* @copyright Copyright (c) 2005-2016 Zend Technologies USA Inc. (http://www.zend.com)
5+
* @license http://framework.zend.com/license/new-bsd New BSD License
6+
*/
7+
8+
namespace Zend\Mail;
9+
10+
class Module
11+
{
12+
/**
13+
* Retrieve zend-mail package configuration for zend-mvc context.
14+
*
15+
* @return array
16+
*/
17+
public function getConfig()
18+
{
19+
$provider = new ConfigProvider();
20+
return [
21+
'service_manager' => $provider->getDependencyConfig(),
22+
];
23+
}
24+
}

src/Protocol/SmtpPluginManager.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ class SmtpPluginManager extends AbstractPluginManager
5555
'zendmailprotocolsmtpauthcrammd5' => InvokableFactory::class,
5656
'zendmailprotocolsmtpauthlogin' => InvokableFactory::class,
5757
'zendmailprotocolsmtpauthplain' => InvokableFactory::class,
58-
'zendmailprotocolsmtp' => InvokableFactory::class,
58+
'zendmailprotocolsmtp' => InvokableFactory::class,
5959
];
6060

6161
/**
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
<?php
2+
/**
3+
* @link http://github.com/zendframework/zend-mail for the canonical source repository
4+
* @copyright Copyright (c) 2005-2016 Zend Technologies USA Inc. (http://www.zend.com)
5+
* @license http://framework.zend.com/license/new-bsd New BSD License
6+
*/
7+
8+
namespace Zend\Mail\Protocol;
9+
10+
use Interop\Container\ContainerInterface;
11+
use Zend\ServiceManager\FactoryInterface;
12+
use Zend\ServiceManager\ServiceLocatorInterface;
13+
14+
class SmtpPluginManagerFactory implements FactoryInterface
15+
{
16+
/**
17+
* zend-servicemanager v2 support for invocation options.
18+
*
19+
* @param array
20+
*/
21+
protected $creationOptions;
22+
23+
/**
24+
* {@inheritDoc}
25+
*
26+
* @return SmtpPluginManager
27+
*/
28+
public function __invoke(ContainerInterface $container, $name, array $options = null)
29+
{
30+
return new SmtpPluginManager($container, $options ?: []);
31+
}
32+
33+
/**
34+
* {@inheritDoc}
35+
*
36+
* @return SmtpPluginManager
37+
*/
38+
public function createService(ServiceLocatorInterface $container, $name = null, $requestedName = null)
39+
{
40+
return $this($container, $requestedName ?: SmtpPluginManager::class, $this->creationOptions);
41+
}
42+
43+
/**
44+
* zend-servicemanager v2 support for invocation options.
45+
*
46+
* @param array $options
47+
* @return void
48+
*/
49+
public function setCreationOptions(array $options)
50+
{
51+
$this->creationOptions = $options;
52+
}
53+
}

src/Storage/Imap.php

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,12 @@ class Imap extends AbstractStorage implements Folder\FolderInterface, Writable\W
2929
*/
3030
protected $currentFolder = '';
3131

32+
/**
33+
* IMAP folder delimiter character
34+
* @var null|string
35+
*/
36+
protected $delimiter;
37+
3238
/**
3339
* IMAP flags to constants translation
3440
* @var array
@@ -331,6 +337,7 @@ public function getFolders($rootFolder = null)
331337
$parentFolder->$localName = $folder;
332338
array_push($folderStack, $parentFolder);
333339
$parentFolder = $folder;
340+
$this->delimiter = $data['delim'];
334341
break;
335342
} elseif ($stack) {
336343
$parent = array_pop($stack);
@@ -504,4 +511,17 @@ public function setFlags($id, $flags)
504511
throw new Exception\RuntimeException('cannot set flags, have you tried to set the recent flag or special chars?');
505512
}
506513
}
514+
515+
/**
516+
* get IMAP delimiter
517+
*
518+
* @return string|null
519+
*/
520+
public function delimiter()
521+
{
522+
if (!isset($this->delimiter)) {
523+
$this->getFolders();
524+
}
525+
return $this->delimiter;
526+
}
507527
}
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
<?php
2+
/**
3+
* @link http://github.com/zendframework/zend-mail for the canonical source repository
4+
* @copyright Copyright (c) 2005-2016 Zend Technologies USA Inc. (http://www.zend.com)
5+
* @license http://framework.zend.com/license/new-bsd New BSD License
6+
*/
7+
8+
namespace ZendTest\Mail\Protocol;
9+
10+
use Interop\Container\ContainerInterface;
11+
use PHPUnit_Framework_TestCase as TestCase;
12+
use Zend\Mail\Protocol\Smtp;
13+
use Zend\Mail\Protocol\SmtpPluginManager;
14+
use Zend\Mail\Protocol\SmtpPluginManagerFactory;
15+
use Zend\ServiceManager\ServiceLocatorInterface;
16+
17+
class SmtpPluginManagerFactoryTest extends TestCase
18+
{
19+
public function testFactoryReturnsPluginManager()
20+
{
21+
$container = $this->prophesize(ContainerInterface::class)->reveal();
22+
$factory = new SmtpPluginManagerFactory();
23+
24+
$plugins = $factory($container, SmtpPluginManager::class);
25+
$this->assertInstanceOf(SmtpPluginManager::class, $plugins);
26+
27+
if (method_exists($plugins, 'configure')) {
28+
// zend-servicemanager v3
29+
$this->assertAttributeSame($container, 'creationContext', $plugins);
30+
} else {
31+
// zend-servicemanager v2
32+
$this->assertSame($container, $plugins->getServiceLocator());
33+
}
34+
}
35+
36+
/**
37+
* @depends testFactoryReturnsPluginManager
38+
*/
39+
public function testFactoryConfiguresPluginManagerUnderContainerInterop()
40+
{
41+
$container = $this->prophesize(ContainerInterface::class)->reveal();
42+
$smtp = $this->prophesize(Smtp::class)->reveal();
43+
44+
$factory = new SmtpPluginManagerFactory();
45+
$plugins = $factory($container, SmtpPluginManager::class, [
46+
'services' => [
47+
'test' => $smtp,
48+
],
49+
]);
50+
$this->assertSame($smtp, $plugins->get('test'));
51+
}
52+
53+
/**
54+
* @depends testFactoryReturnsPluginManager
55+
*/
56+
public function testFactoryConfiguresPluginManagerUnderServiceManagerV2()
57+
{
58+
$container = $this->prophesize(ServiceLocatorInterface::class);
59+
$container->willImplement(ContainerInterface::class);
60+
61+
$smtp = $this->prophesize(Smtp::class)->reveal();
62+
63+
$factory = new SmtpPluginManagerFactory();
64+
$factory->setCreationOptions([
65+
'services' => [
66+
'test' => $smtp,
67+
],
68+
]);
69+
70+
$plugins = $factory->createService($container->reveal());
71+
$this->assertSame($smtp, $plugins->get('test'));
72+
}
73+
}

test/Storage/ImapTest.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -700,4 +700,11 @@ public function testCountFlags()
700700
$this->assertEquals($mail->countMessages([Storage::FLAG_SEEN, Storage::FLAG_FLAGGED]), 0);
701701
$this->assertEquals($mail->countMessages(Storage::FLAG_FLAGGED), 0);
702702
}
703+
704+
public function testDelimiter()
705+
{
706+
$mail = new Storage\Imap($this->params);
707+
$delimiter = $mail->delimiter();
708+
$this->assertEquals(strlen($delimiter), 1);
709+
}
703710
}

0 commit comments

Comments
 (0)