Files
postfixadmin/tests/RemoteAliasTest.php
T
Kent Riboe 2c0a06f932 Add Exec class to help refactor/reduce duplication of proc_open calls, update phpunit (see note) (#1009)
* code refactoring (adds Exec class to centralise proc_open like calls). 
* bump phpunit to ^11.0, as this is the last release that supports php8.2. Note, there is not (yet?) a phpunit release for php8.2 that fixes PKSA-z3gr-8qht-p93v or PKSA-5jz8-6tcw-pbk4, so ignore them for now in composer.json
2026-04-18 10:05:35 +01:00

49 lines
1.6 KiB
PHP

<?php
/**
* Test for Postfixadmin
*
* @package tests
*/
require_once('RemoteTest.php');
class RemoteAliasTest extends RemoteTest
{
public function testGet()
{
/* although we created an alias record, for users, this isn't returned... */
$this->assertEquals($this->alias->get(), array());
}
public function testHasStoreAndForward()
{
$this->assertTrue($this->alias->hasStoreAndForward());
}
public function testUpdateRemoteOnly()
{
$this->assertTrue($this->alias->update(array('roger@rabbit.com'), 'remote_only'));
$this->assertFalse($this->alias->hasStoreAndForward());
$this->assertTrue($this->alias->update(array('roger@rabbit.com'), 'remote_only'));
$this->assertTrue($this->alias->update(array('roger@rabbit.com', 'fish@fish.net', 'road@runner.com'), 'remote_only'));
$this->assertEquals($this->alias->get(), array('roger@rabbit.com', 'fish@fish.net', 'road@runner.com'));
$this->assertFalse($this->alias->hasStoreAndForward());
}
public function testUpdateForwardandStore()
{
$orig_aliases = $this->alias->get();
if (!is_array($orig_aliases)) {
$orig_aliases = array();
}
$orig_aliases[] = 'roger@robbit.com';
$this->assertTrue($this->alias->update($orig_aliases, 'forward_and_store'));
$this->assertEquals($this->alias->get(), $orig_aliases);
$this->assertTrue($this->alias->update(array($this->username), 'forward_and_store'));
$this->assertEquals($this->alias->get(), array());
}
}
/* vim: set expandtab softtabstop=4 tabstop=4 shiftwidth=4: */