|
1
|
|
|
<?php
|
|
2
|
|
|
/**
|
|
3
|
|
|
* OpenFireRestAPI is based entirely on official documentation of the REST API
|
|
4
|
|
|
* Plugin and you can extend it by following the directives of the documentation
|
|
5
|
|
|
*
|
|
6
|
|
|
* For the full copyright and license information, please read the LICENSE
|
|
7
|
|
|
* file that was distributed with this source code. For the full list of
|
|
8
|
|
|
* contributors, visit https://github.com/gnello/PHPOpenFireRestAPI/contributors
|
|
9
|
|
|
*
|
|
10
|
|
|
* @author Luca Agnello <[email protected]>
|
|
11
|
|
|
* @link https://www.igniterealtime.org/projects/openfire/plugins/restapi/readme.html
|
|
12
|
|
|
*/
|
|
13
|
|
|
|
|
14
|
|
|
namespace Gnello\OpenFireRestAPI\Settings;
|
|
15
|
|
|
|
|
16
|
|
|
/**
|
|
17
|
|
|
* Class SettingsTest
|
|
18
|
|
|
* @package Gnello\OpenFireRestAPI\Settings
|
|
19
|
|
|
*/
|
|
20
|
|
|
class SettingsTest extends \PHPUnit_Framework_TestCase
|
|
21
|
|
|
{
|
|
22
|
|
|
/** @var Settings */
|
|
23
|
|
|
protected $fixture;
|
|
24
|
|
|
|
|
25
|
|
|
protected function setUp()
|
|
26
|
|
|
{
|
|
27
|
|
|
$this->fixture = Settings::getInstance();
|
|
28
|
|
|
}
|
|
29
|
|
|
|
|
30
|
|
|
protected function tearDown()
|
|
31
|
|
|
{
|
|
32
|
|
|
$this->fixture->destroy();
|
|
33
|
|
|
}
|
|
34
|
|
|
|
|
35
|
|
|
public function testGetInstance()
|
|
36
|
|
|
{
|
|
37
|
|
|
$this->assertInstanceOf("Gnello\\OpenFireRestAPI\\Settings\\Settings", $this->fixture);
|
|
38
|
|
|
}
|
|
39
|
|
|
|
|
40
|
|
|
public function testGetInstanceIsCorrectlyInitializated()
|
|
41
|
|
|
{
|
|
42
|
|
|
$this->assertEquals(Settings::PLUGIN_PATH, $this->fixture->getPlugin());
|
|
43
|
|
|
$this->assertFalse($this->fixture->isSSL());
|
|
44
|
|
|
$this->assertFalse($this->fixture->isDebug());
|
|
45
|
|
|
}
|
|
46
|
|
|
|
|
47
|
|
|
public function testSetHost()
|
|
48
|
|
|
{
|
|
49
|
|
|
$this->fixture->setHost('http://www.example.it');
|
|
50
|
|
|
$this->assertEquals('www.example.it', $this->fixture->getHost());
|
|
51
|
|
|
|
|
52
|
|
|
$this->fixture->setHost('test');
|
|
53
|
|
|
$this->assertEquals('test', $this->fixture->getHost());
|
|
54
|
|
|
}
|
|
55
|
|
|
|
|
56
|
|
View Code Duplication |
public function testHostIsNull()
|
|
|
|
|
|
|
57
|
|
|
{
|
|
58
|
|
|
$this->fixture->setHost(true);
|
|
59
|
|
|
$this->assertNull($this->fixture->getHost());
|
|
60
|
|
|
|
|
61
|
|
|
$this->fixture->setHost(1);
|
|
62
|
|
|
$this->assertNull($this->fixture->getHost());
|
|
63
|
|
|
|
|
64
|
|
|
$this->fixture->setHost(array(1, 2));
|
|
65
|
|
|
$this->assertNull($this->fixture->getHost());
|
|
66
|
|
|
}
|
|
67
|
|
|
|
|
68
|
|
|
public function testSetServerNameFromHost()
|
|
69
|
|
|
{
|
|
70
|
|
|
$this->fixture->setServerNameFromHost('http://www.example.it');
|
|
71
|
|
|
$this->assertEquals('example.it', $this->fixture->getServerName());
|
|
72
|
|
|
|
|
73
|
|
|
$this->fixture->setServerNameFromHost('test');
|
|
74
|
|
|
$this->assertEquals('test', $this->fixture->getServerName());
|
|
75
|
|
|
}
|
|
76
|
|
|
|
|
77
|
|
View Code Duplication |
public function testServerNameFromHostIsNull()
|
|
|
|
|
|
|
78
|
|
|
{
|
|
79
|
|
|
$this->fixture->setServerNameFromHost(true);
|
|
80
|
|
|
$this->assertNull($this->fixture->getServerName());
|
|
81
|
|
|
|
|
82
|
|
|
$this->fixture->setServerNameFromHost(1);
|
|
83
|
|
|
$this->assertNull($this->fixture->getServerName());
|
|
84
|
|
|
|
|
85
|
|
|
$this->fixture->setServerNameFromHost(array(1, 2));
|
|
86
|
|
|
$this->assertNull($this->fixture->getServerName());
|
|
87
|
|
|
}
|
|
88
|
|
|
}
|
|
89
|
|
|
|
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.