php-src/ext/imap/tests/imap_constructor.phpt
Ayesh Karunaratne 7f1659afcb IMAP: Disallow direct new IMAPConnection() construct
Disallows constructing an `IMAPConnection` class directly with `new IMAPConnection` construct, by throwing an `Error` exception if attempted.
`imap_open` is still the only way to create `IMAPConnection` objects.
2020-12-23 21:21:32 +01:00

15 lines
369 B
PHP

--TEST--
Attempt to instantiate an IMAPConnection directly
--SKIPIF--
<?php
extension_loaded('imap') or die('skip imap extension not available in this build');
--FILE--
<?php
try {
new IMAPConnection();
} catch (Error $ex) {
echo "Exception: ", $ex->getMessage(), "\n";
}
--EXPECT--
Exception: Cannot directly construct IMAPConnection, use imap_open() instead