Add TestCase base class that will setup users, and in future also domains, ..
This commit is contained in:
parent
c3171b972f
commit
ffbf29eb4c
1 changed files with 77 additions and 0 deletions
77
tests/TestCase.php
Normal file
77
tests/TestCase.php
Normal file
|
@ -0,0 +1,77 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @covers Auth
|
||||
*/
|
||||
abstract class TestCase extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
const USER_ROLE_ADMIN_ID = 100001;
|
||||
const USER_ROLE_ADMIN_ID_LIMITED_NO_ACCESS = 100002;
|
||||
const USER_ROLE_ADMIN_ID_LIMITED_HAS_ACCESS = 100003;
|
||||
const USER_ROLE_USER_ID = 100013;
|
||||
|
||||
|
||||
public static function setUpBeforeClass()
|
||||
{
|
||||
|
||||
Database::getInstance()->insert(
|
||||
'users',
|
||||
array(
|
||||
'id' => static::USER_ROLE_ADMIN_ID,
|
||||
'username' => 'admin',
|
||||
'domain' => 'domain.tld',
|
||||
'password' => Auth::generatePasswordHash('testtest'),
|
||||
'mailbox_limit' => 0,
|
||||
)
|
||||
);
|
||||
|
||||
Database::getInstance()->insert(
|
||||
'users',
|
||||
array(
|
||||
'id' => static::USER_ROLE_ADMIN_ID_LIMITED_NO_ACCESS,
|
||||
'username' => 'no-access-limited-admin',
|
||||
'domain' => 'domain.tld',
|
||||
'password' => Auth::generatePasswordHash('testtest'),
|
||||
'mailbox_limit' => 0,
|
||||
)
|
||||
);
|
||||
|
||||
Database::getInstance()->insert(
|
||||
'users',
|
||||
array(
|
||||
'id' => static::USER_ROLE_ADMIN_ID_LIMITED_HAS_ACCESS,
|
||||
'username' => 'has-access-limited-admin',
|
||||
'domain' => 'domain.tld',
|
||||
'password' => Auth::generatePasswordHash('testtest'),
|
||||
'mailbox_limit' => 0,
|
||||
)
|
||||
);
|
||||
|
||||
Database::getInstance()->insert(
|
||||
'users',
|
||||
array(
|
||||
'id' => static::USER_ROLE_USER_ID,
|
||||
'username' => 'user',
|
||||
'domain' => 'domain.tld',
|
||||
'password' => Auth::generatePasswordHash('testtest'),
|
||||
'mailbox_limit' => 64,
|
||||
)
|
||||
);
|
||||
|
||||
Config::set('admins', array('admin@domain.tld', 'limited-admin@domain.tld'));
|
||||
Config::set('admin_domain_limits', array(
|
||||
'no-access-limited-admin@domain.tld' => array(),
|
||||
'has-access-limited-admin@domain.tld' => array('his-domain.tld'),
|
||||
));
|
||||
}
|
||||
|
||||
|
||||
public static function tearDownAfterClass()
|
||||
{
|
||||
Database::getInstance()->delete('users', 'id', static::USER_ROLE_ADMIN_ID);
|
||||
Database::getInstance()->delete('users', 'id', static::USER_ROLE_ADMIN_ID_LIMITED_NO_ACCESS);
|
||||
Database::getInstance()->delete('users', 'id', static::USER_ROLE_ADMIN_ID_LIMITED_HAS_ACCESS);
|
||||
Database::getInstance()->delete('users', 'id', static::USER_ROLE_USER_ID);
|
||||
}
|
||||
|
||||
}
|
Loading…
Add table
Reference in a new issue