Skip to content

Commit

Permalink
Revert "Mailbox: add renaming capability (ddeboer#540)"
Browse files Browse the repository at this point in the history
This reverts commit c2e4d72.
  • Loading branch information
vladimir.kaprielov committed Oct 27, 2022
1 parent 954e7c2 commit 1913ce7
Show file tree
Hide file tree
Showing 5 changed files with 0 additions and 53 deletions.
9 changes: 0 additions & 9 deletions src/Exception/RenameMailboxException.php

This file was deleted.

18 changes: 0 additions & 18 deletions src/Mailbox.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
use Ddeboer\Imap\Exception\InvalidSearchCriteriaException;
use Ddeboer\Imap\Exception\MessageCopyException;
use Ddeboer\Imap\Exception\MessageMoveException;
use Ddeboer\Imap\Exception\RenameMailboxException;
use Ddeboer\Imap\Search\ConditionInterface;
use Ddeboer\Imap\Search\LogicalOperator\All;

Expand Down Expand Up @@ -42,23 +41,6 @@ public function getName(): string
return $this->name;
}

public function renameTo(string $name): bool
{
$encodedName = \mb_convert_encoding($name, 'UTF7-IMAP', 'UTF-8');
$oldFullName = $this->getFullEncodedName();
$newFullName = \preg_replace('/' . \preg_quote(\mb_convert_encoding($this->name, 'UTF7-IMAP', 'UTF-8')) . '$/', $encodedName, $oldFullName);
\assert(null !== $newFullName);

$return = \imap_renamemailbox($this->resource->getStream(), $oldFullName, $newFullName);
if (false === $return) {
throw new RenameMailboxException('Could not rename mailbox');
}
$this->name = $name;
$this->info->name = $newFullName;

return true;
}

public function getEncodedName(): string
{
/** @var string $name */
Expand Down
5 changes: 0 additions & 5 deletions src/MailboxInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,6 @@ interface MailboxInterface extends \Countable, \IteratorAggregate
*/
public function getName(): string;

/**
* Set new mailbox name.
*/
public function renameTo(string $name): bool;

/**
* Get mailbox encoded path.
*/
Expand Down
2 changes: 0 additions & 2 deletions tests/AbstractTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ abstract class AbstractTest extends TestCase
public const SPECIAL_CHARS = 'A_\\|!"£$%&()=?àèìòùÀÈÌÒÙ<>-@#[]_ß_б_π_€_✔_你_يد_Z_';

protected ?string $mailboxName;
protected ?string $altName;

final protected function getConnection(): ConnectionInterface
{
Expand All @@ -41,7 +40,6 @@ final protected function createMailbox(ConnectionInterface $connection = null):
{
$connection = $connection ?? $this->getConnection();
$this->mailboxName = \uniqid('mailbox_' . self::SPECIAL_CHARS);
$this->altName = \uniqid('mailbox_' . self::SPECIAL_CHARS);

return $connection->createMailbox($this->mailboxName);
}
Expand Down
19 changes: 0 additions & 19 deletions tests/MailboxTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
use Ddeboer\Imap\Exception\MessageCopyException;
use Ddeboer\Imap\Exception\MessageDoesNotExistException;
use Ddeboer\Imap\Exception\MessageMoveException;
use Ddeboer\Imap\Exception\RenameMailboxException;
use Ddeboer\Imap\Exception\ReopenMailboxException;
use Ddeboer\Imap\MailboxInterface;
use Ddeboer\Imap\MessageIterator;
Expand Down Expand Up @@ -40,24 +39,6 @@ public function testGetName(): void
static::assertSame($this->mailboxName, $this->mailbox->getName());
}

public function testRenameTo(): void
{
static::assertNotSame($this->mailboxName, $this->altName);

/** @var string $altName */
$altName = $this->altName;
static::assertTrue($this->mailbox->renameTo($altName));
static::assertSame($this->altName, $this->mailbox->getName());

/** @var string $mailboxName */
$mailboxName = $this->mailboxName;
static::assertTrue($this->mailbox->renameTo($mailboxName));
static::assertSame($this->mailboxName, $this->mailbox->getName());

static::expectException(RenameMailboxException::class);
$this->mailbox->renameTo($mailboxName);
}

public function testGetFullEncodedName(): void
{
static::assertIsString($this->mailboxName);
Expand Down

0 comments on commit 1913ce7

Please sign in to comment.