Skip to content

Commit

Permalink
Horde-style test configuration.
Browse files Browse the repository at this point in the history
  • Loading branch information
yunosh committed Jan 26, 2015
1 parent 622129b commit d8c64ff
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 14 deletions.
29 changes: 19 additions & 10 deletions framework/ManageSieve/test/Horde/ManageSieve/SieveTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,13 @@ class SieveTest extends Horde_Test_Case
*/
protected $fixture;

/**
* Server configuration.
*
* @var array
*/
protected $config;

/**
* The tested scripts.
*
Expand All @@ -42,10 +49,12 @@ class SieveTest extends Horde_Test_Case

protected function setUp()
{
if (!file_exists(dirname(__FILE__) . '/conf.php')) {
$this->markTestSkipped('Test configuration incomplete. Copy conf.php.dist to conf.php.');
$this->config = self::getConfig('MANAGESIEVE_TEST_CONFIG');
if (!$this->config || empty($this->config['managesieve'])) {
$this->markTestSkipped('No ManageSieve configuration');
return;
}
require_once dirname(__FILE__) . '/conf.php';
$this->config = $this->config['managesieve'];

// Create a new instance of Horde\ManageSieve.
$this->fixture = new ManageSieve();
Expand All @@ -64,8 +73,8 @@ protected function tearDown()

protected function login()
{
$this->fixture->connect(HOST, PORT);
$this->fixture->login(USERNAME, PASSWORD, null, '', false);
$this->fixture->connect($this->config['host'], $this->config['port']);
$this->fixture->login($this->config['username'], $this->config['password'], null, '', false);
}

protected function logout()
Expand All @@ -92,19 +101,19 @@ protected function clear()

public function testConnect()
{
$this->fixture->connect(HOST, PORT);
$this->fixture->connect($this->config['host'], $this->config['port']);
}

public function testLogin()
{
$this->fixture->connect(HOST, PORT);
$this->fixture->login(USERNAME, PASSWORD, null, '', false);
$this->fixture->connect($this->config['host'], $this->config['port']);
$this->fixture->login($this->config['username'], $this->config['password'], null, '', false);
}

public function testDisconnect()
{
$this->fixture->connect(HOST, PORT);
$this->fixture->login(USERNAME, PASSWORD, null, '', false);
$this->fixture->connect($this->config['host'], $this->config['port']);
$this->fixture->login($this->config['username'], $this->config['password'], null, '', false);
$this->fixture->disconnect();
}

Expand Down
8 changes: 4 additions & 4 deletions framework/ManageSieve/test/Horde/ManageSieve/conf.php.dist
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?php
define('HOST', 'localhost');
define('PORT', 4190);
define('USERNAME', 'user');
define('PASSWORD', 'pass');
$conf['managesieve']['host'] = 'localhost';
$conf['managesieve']['port'] = 4190;
$conf['managesieve']['username'] = 'user';
$conf['managesieve']['password'] = 'pass';

0 comments on commit d8c64ff

Please sign in to comment.