Skip to content

Commit fb0db2c

Browse files
coverage
1 parent bcbf1d7 commit fb0db2c

File tree

4 files changed

+22
-10
lines changed

4 files changed

+22
-10
lines changed

Makefile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ dump-autoload:
1414
imap2-coverage:
1515
@docker-compose run --rm imap2 ./vendor/bin/phpunit tests --coverage-html docs/coverage
1616

17+
imap2-test:
18+
@docker-compose run --rm imap2 ./vendor/bin/phpunit tests --stop-on-failure
19+
1720
coverage:
1821
@docker-compose run --rm phpunit tests --coverage-html docs/coverage
1922

bootstrap.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,10 @@ function imap_open($mailbox, $user, $password, $flags = 0, $retries = 0, $option
183183
if (!function_exists('imap2_open')) {
184184
function imap2_open($mailbox, $user, $password, $flags = 0, $retries = 0, $options = [])
185185
{
186+
if (IMAP2_RETROFIT_MODE && !($flags & OP_XOAUTH2)) {
187+
return imap_open($mailbox, $user, $password, $flags, $retries, $options);
188+
}
189+
186190
return Connection::open($mailbox, $user, $password, $flags, $retries, $options);
187191
}
188192
}

src/Connection.php

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -50,21 +50,22 @@ public function __construct($mailbox, $user, $password, $flags = 0, $retries = 0
5050
}
5151

5252
/**
53-
* Extract input value using input name from the context otherwise get back a default value.
53+
* Open an IMAP stream to a mailbox.
54+
*
55+
* @param $mailbox
56+
* @param $user
57+
* @param $password
58+
* @param int $flags
59+
* @param int $retries
60+
* @param array $options
5461
*
55-
* @param $inputName
56-
* @param $defaultValue
5762
* @return void
5863
*/
5964
public static function open($mailbox, $user, $password, $flags = 0, $retries = 0, $options = [])
6065
{
61-
if ($flags & OP_XOAUTH2 || !function_exists('imap_open')) {
62-
$connection = new Connection($mailbox, $user, $password, $flags, $retries, $options);
63-
64-
return $connection->connect();
65-
}
66+
$connection = new Connection($mailbox, $user, $password, $flags, $retries, $options);
6667

67-
return imap_open($mailbox, $user, $password, $flags, $retries, $options);
68+
return $connection->connect();
6869
}
6970

7071
public static function reopen($imap, $mailbox, $flags = 0, $retries = 0)

tests/CompatibilityTest.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,11 @@ public function testOpenAndClose()
2121
$imap1 = imap_open($this->mailbox, $this->username, $this->password);
2222
$imap2 = imap2_open($this->mailbox, $this->username, $this->accessToken, OP_XOAUTH2);
2323

24-
$this->assertTrue(is_resource($imap1));
24+
if (IMAP2_RETROFIT_MODE) {
25+
$this->assertTrue(is_resource($imap1));
26+
} else {
27+
$this->assertInstanceOf(Connection::class, $imap1);
28+
}
2529
$this->assertInstanceOf(Connection::class, $imap2);
2630

2731
$close1 = imap_close($imap1);

0 commit comments

Comments
 (0)