-
Notifications
You must be signed in to change notification settings - Fork 349
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
BAP-13634: Incorrect Email Messages Id and UID usage in IMAP integrat…
…ion (#7240)
- Loading branch information
1 parent
70b6f33
commit c22b7d1
Showing
3 changed files
with
115 additions
and
0 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
78 changes: 78 additions & 0 deletions
78
src/Oro/Bundle/ImapBundle/Tests/Unit/Mail/Storage/ImapTest.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,78 @@ | ||
<?php | ||
|
||
namespace Oro\Bundle\ImapBundle\Tests\Unit\Mail\Storage; | ||
|
||
use Zend\Mail\Storage\Exception\InvalidArgumentException; | ||
|
||
use Oro\Bundle\ImapBundle\Mail\Storage\Imap; | ||
|
||
class ImapTest extends \PHPUnit_Framework_TestCase | ||
{ | ||
public function testCacheForGetNumberByUniqueId() | ||
{ | ||
$ids = [ | ||
1 => 1, | ||
2 => 2, | ||
3 => 3, | ||
4 => 4, | ||
5 => 5 | ||
]; | ||
|
||
$protocolImap = $this->getMockBuilder('Oro\Bundle\ImapBundle\Mail\Protocol\Imap') | ||
->disableOriginalConstructor()->getMock(); | ||
$protocolImap->expects(self::once())->method('select')->willReturn(['uidvalidity'=>'']); | ||
$protocolImap->expects(self::once())->method('fetch')->willReturn($ids); | ||
|
||
$imap = new Imap($protocolImap); | ||
|
||
$id = '3'; | ||
self::assertEquals(3, $imap->getNumberByUniqueId($id)); | ||
|
||
$protocolImap->expects(self::never())->method('fetch'); | ||
self::assertEquals(3, $imap->getNumberByUniqueId($id)); | ||
} | ||
|
||
/** | ||
* @expectedException InvalidArgumentException | ||
* @expectedExceptionMessage unique id not found | ||
*/ | ||
public function testExceptionForGetNumberByUniqueId() | ||
{ | ||
$ids = [ | ||
1 => 1, | ||
2 => 2, | ||
3 => 3, | ||
4 => 4, | ||
5 => 5 | ||
]; | ||
|
||
$protocolImap = $this->getMockBuilder('Oro\Bundle\ImapBundle\Mail\Protocol\Imap') | ||
->disableOriginalConstructor()->getMock(); | ||
$protocolImap->expects(self::once())->method('select')->willReturn(['uidvalidity'=>'']); | ||
$protocolImap->expects(self::once())->method('fetch')->willReturn($ids); | ||
|
||
$imap = new Imap($protocolImap); | ||
|
||
$id = '6'; | ||
$imap->getNumberByUniqueId($id); | ||
} | ||
|
||
/** | ||
* @expectedException InvalidArgumentException | ||
* @expectedExceptionMessage unique id not found | ||
*/ | ||
public function testCacheForGetNumberByUniqueIdNotArray() | ||
{ | ||
$ids = 3; | ||
|
||
$protocolImap = $this->getMockBuilder('Oro\Bundle\ImapBundle\Mail\Protocol\Imap') | ||
->disableOriginalConstructor()->getMock(); | ||
$protocolImap->expects(self::once())->method('select')->willReturn(['uidvalidity'=>'']); | ||
$protocolImap->expects(self::once())->method('fetch')->willReturn($ids); | ||
|
||
$imap = new Imap($protocolImap); | ||
|
||
$id = '3'; | ||
$imap->getNumberByUniqueId($id); | ||
} | ||
} |