Skip to content

Commit 4289d41

Browse files
committed
clone method looses account configuration Webklex#521
1 parent beb82e2 commit 4289d41

File tree

3 files changed

+36
-1
lines changed

3 files changed

+36
-1
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ Updates should follow the [Keep a CHANGELOG](http://keepachangelog.com/) princip
1616
- RFC4315 MOVE fallback added #123 (thanks @freescout-help-desk)
1717
- Content fetching RFC standard support added #510 (thanks @ybizeul)
1818
- Support unescaped dates inside the search conditions #542
19+
- `Client::clone()` looses account configuration #521 (thanks @netpok)
1920

2021
### Breaking changes
2122
- NaN

src/Client.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ public function clone(): Client {
224224
$client->default_account_config = $this->default_account_config;
225225
$config = $this->getAccountConfig();
226226
foreach($config as $key => $value) {
227-
$client->setAccountConfig($key, $this->default_account_config);
227+
$client->setAccountConfig($key, $config);
228228
}
229229
$client->default_message_mask = $this->default_message_mask;
230230
$client->default_attachment_mask = $this->default_message_mask;

tests/ClientTest.php

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,40 @@ public function testClient(): void {
8383
self::assertArrayHasKey("new", $this->client->getDefaultEvents("message"));
8484
}
8585

86+
/**
87+
* @throws MaskNotFoundException
88+
*/
89+
public function testClientClone(): void {
90+
$config = Config::make([
91+
"accounts" => [
92+
"default" => [
93+
'host' => 'example.com',
94+
'port' => 993,
95+
'protocol' => 'imap', //might also use imap, [pop3 or nntp (untested)]
96+
'encryption' => 'ssl', // Supported: false, 'ssl', 'tls'
97+
'validate_cert' => true,
98+
'username' => '[email protected]',
99+
'password' => 'foo',
100+
'authentication' => null,
101+
'rfc' => 'RFC822', // If you are using iCloud, you might want to set this to 'BODY'
102+
'proxy' => [
103+
'socket' => null,
104+
'request_fulluri' => false,
105+
'username' => null,
106+
'password' => null,
107+
],
108+
"timeout" => 30,
109+
"extensions" => []
110+
]]
111+
]);
112+
$client = new Client($config);
113+
$clone = $client->clone();
114+
self::assertInstanceOf(Client::class, $clone);
115+
self::assertSame($client->getConfig(), $clone->getConfig());
116+
self::assertSame($client->getAccountConfig(), $clone->getAccountConfig());
117+
self::assertSame($client->host, $clone->host);
118+
}
119+
86120
public function testClientLogout(): void {
87121
$this->createNewProtocolMockup();
88122

0 commit comments

Comments
 (0)