1<?php
2/**
3 * Copyright 2013-2017 Horde LLC (http://www.horde.org/)
4 *
5 * See the enclosed file COPYING for license information (LGPL). If you
6 * did not receive this file, see http://www.horde.org/licenses/lgpl21.
7 *
8 * @category   Horde
9 * @copyright  2013 Horde LLC
10 * @license    http://www.horde.org/licenses/lgpl21 LGPL 2.1
11 * @package    Smtp
12 * @subpackage UnitTests
13 */
14
15/**
16 * Package testing on a remote SMTP server.
17 *
18 * @author     Michael Slusarz <slusarz@horde.org>
19 * @category   Horde
20 * @copyright  2013 Horde LLC
21 * @ignore
22 * @license    http://www.horde.org/licenses/lgpl21 LGPL 2.1
23 * @package    Smtp
24 * @subpackage UnitTests
25 */
26class Horde_Smtp_RemoteServerTest extends Horde_Test_Case
27{
28    private $config;
29    private $smtp;
30
31    public function setUp()
32    {
33        $config = self::getConfig('SMTP_TEST_CONFIG');
34        if (is_null($config)) {
35            $this->markTestSkipped('Remote server not configured.');
36        }
37        $this->config = $config['smtp'];
38    }
39
40    public function tearDown()
41    {
42        if ($this->smtp) {
43            unset($this->smtp);
44        }
45    }
46
47    public function testLoginNoAuth()
48    {
49        unset($this->config['pass'], $this->config['user']);
50        $this->_createSmtp();
51        $this->smtp->login();
52    }
53
54    public function testLoginAuth()
55    {
56        if (!isset($this->config['pass']) || !isset($this->config['user'])) {
57            $this->markTestSkipped('Authentication not configured.');
58        }
59
60        $this->_createSmtp();
61        $this->smtp->login();
62    }
63
64    public function test8bitmime()
65    {
66        $this->_createSmtp();
67        $this->assertEquals(
68            $this->smtp->queryExtension('8BITMIME'),
69            $this->smtp->data_8bit
70        );
71    }
72
73    public function testBinaryMime()
74    {
75        $this->_createSmtp();
76        $this->assertEquals(
77            $this->smtp->queryExtension('BINARYMIME'),
78            $this->smtp->data_binary
79        );
80    }
81
82    public function testSize()
83    {
84        $this->_createSmtp();
85        $this->assertEquals(
86            $this->smtp->queryExtension('SIZE'),
87            $this->smtp->size
88        );
89    }
90
91    public function testNoop()
92    {
93        $this->_createSmtp();
94        $this->smtp->noop();
95    }
96
97    public function testProcessQueue()
98    {
99        $this->_createSmtp();
100        $this->smtp->processQueue();
101    }
102
103    protected function _createSmtp()
104    {
105        $this->smtp = new Horde_Smtp($this->config);
106    }
107
108}
109