-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add basic test coverage for
message_compose
hook. (#45)
- Loading branch information
Showing
3 changed files
with
106 additions
and
16 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -62,16 +62,51 @@ public static function storage_init_should_fetch_headers_provider(): array | |
#[DataProvider('storage_init_should_fetch_headers_provider')] | ||
public function test_storage_init_should_fetch_headers($config_values, $user_prefs, $expected): void | ||
{ | ||
$plugin = self::create_plugin($config_values, $user_prefs); | ||
$rcmail = rcmail::mock(); | ||
$rcmail->mock_config($config_values); | ||
$rcmail->mock_user(array(), $user_prefs); | ||
|
||
$plugin = self::create_plugin(); | ||
$params = $plugin->storage_init(array()); | ||
|
||
$this->assertSame($params['fetch_headers'], $expected); | ||
} | ||
|
||
private static function create_plugin($config_values, $user_prefs) | ||
public static function message_compose_should_set_state_provider(): array | ||
{ | ||
rcmail::mock_instance($config_values, $user_prefs); | ||
return array( | ||
array( | ||
array('to' => '[email protected]'), | ||
null, | ||
), | ||
array( | ||
array('to' => '[email protected]'), | ||
'[email protected]', | ||
) | ||
); | ||
} | ||
|
||
#[DataProvider('message_compose_should_set_state_provider')] | ||
public function test_message_compose_should_set_state($message, $expected): void | ||
{ | ||
$identity1 = array('email' => '[email protected]', 'name' => 'Primary', 'standard' => '1'); | ||
$identity2 = array('email' => '[email protected]', 'name' => 'Secondary', 'standard' => '0'); | ||
|
||
$id = 17; | ||
$uid = '42'; | ||
$rcmail = rcmail::mock(); | ||
$rcmail->mock_config(array()); | ||
$rcmail->mock_message($uid, $message); | ||
$rcmail->mock_user(array($identity1, $identity2), array()); | ||
|
||
$plugin = self::create_plugin(); | ||
$plugin->message_compose(array('id' => $id, 'param' => array('uid' => $uid))); | ||
|
||
$this->assertSame($_SESSION["custom_from_$id"], $expected); | ||
} | ||
|
||
private static function create_plugin() | ||
{ | ||
$plugin = new custom_from(null); | ||
$plugin->init(); | ||
|
||
|
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