Skip to content

Commit

Permalink
Handled warning messages on unit-test.
Browse files Browse the repository at this point in the history
  • Loading branch information
msyk committed Nov 2, 2024
1 parent 5d5733a commit 1f9f680
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 29 deletions.
57 changes: 30 additions & 27 deletions spec/INTER-Mediator-UnitTest/Core/IMUtil_Test.php
Original file line number Diff line number Diff line change
Expand Up @@ -125,37 +125,35 @@ public function test_protectCSRF()

public function test_checkHost()
{
if (((float)phpversion()) >= 5.3) {
$reflectionMethod = new ReflectionMethod('\INTERMediator\IMUtil', 'checkHost');
$reflectionMethod->setAccessible(true);
$reflectionMethod = new ReflectionMethod('\INTERMediator\IMUtil', 'checkHost');
$reflectionMethod->setAccessible(true);

$result = $reflectionMethod->invokeArgs($this->util, array('www.inter-mediator.com', 'www.inter-mediator.com'));
$this->assertTrue($result);
$result = $reflectionMethod->invokeArgs($this->util, array('www.inter-mediator.com', 'www.inter-mediator.com'));
$this->assertTrue($result);

$result = $reflectionMethod->invokeArgs($this->util, array('www.inter-mediator.com', 'inter-mediator.com'));
$this->assertTrue($result);
$result = $reflectionMethod->invokeArgs($this->util, array('www.inter-mediator.com', 'inter-mediator.com'));
$this->assertTrue($result);

$result = $reflectionMethod->invokeArgs($this->util, array('WWW.inter-mediator.com', 'inter-mediator.com'));
$this->assertTrue($result);
$result = $reflectionMethod->invokeArgs($this->util, array('WWW.inter-mediator.com', 'inter-mediator.com'));
$this->assertTrue($result);

$result = $reflectionMethod->invokeArgs($this->util, array('inter-mediator.com', 'inter-mediator.com'));
$this->assertTrue($result);
$result = $reflectionMethod->invokeArgs($this->util, array('inter-mediator.com', 'inter-mediator.com'));
$this->assertTrue($result);

$_SERVER = array();
$_SERVER['SERVER_ADDR'] = '192.168.56.101';
$result = $reflectionMethod->invokeArgs($this->util, array('192.168.56.101', $_SERVER['SERVER_ADDR']));
$this->assertTrue($result);
$_SERVER = array();
$_SERVER['SERVER_ADDR'] = '192.168.56.101';
$result = $reflectionMethod->invokeArgs($this->util, array('192.168.56.101', $_SERVER['SERVER_ADDR']));
$this->assertTrue($result);

$result = $reflectionMethod->invokeArgs($this->util, array('www.inter-mediator.com', ''));
$this->assertFalse($result);
$result = $reflectionMethod->invokeArgs($this->util, array('www.inter-mediator.com', ''));
$this->assertFalse($result);

$result = $reflectionMethod->invokeArgs($this->util, array('www.inter-mediator.com', 'ww.inter-mediator.com'));
$this->assertFalse($result);
$result = $reflectionMethod->invokeArgs($this->util, array('www.inter-mediator.com', 'ww.inter-mediator.com'));
$this->assertFalse($result);

$_SERVER = array();
$result = $reflectionMethod->invokeArgs($this->util, array('192.168.56.101', '56.101'));
$this->assertFalse($result);
}
$_SERVER = array();
$result = $reflectionMethod->invokeArgs($this->util, array('192.168.56.101', '56.101'));
$this->assertFalse($result);
}

#[RunInSeparateProcess]
Expand Down Expand Up @@ -317,7 +315,8 @@ public function test_UserNameHome()
$this->assertNotNull($home, "IMUtil::getServerUserHome has to return any strings.");
}

public function test_Profile() {
public function test_Profile()
{
$tempDir = sys_get_temp_dir();
Params::setVar("profileRoot", $tempDir);
$profileRoot = Params::getParameterValue("profileRoot", null);
Expand All @@ -334,10 +333,14 @@ public function test_Profile() {
"mysecret = 1234",
"your-secret = 9876",
"big_city = \t 1919",
"noone-knows = 4567", "", "",
"noone-knows = 4567", "", "",
];
mkdir("$tempDir/.im");
mkdir("$tempDir/.aws");
if (!file_exists("$tempDir/.im")) {
mkdir("$tempDir/.im");
}
if (!file_exists("$tempDir/.aws")) {
mkdir("$tempDir/.aws");
}
file_put_contents("$tempDir/.im/credentials", implode("\n", $fileContent));
file_put_contents("$tempDir/.aws/credentials", implode("\n", $fileContent));

Expand Down
8 changes: 6 additions & 2 deletions spec/INTER-Mediator-UnitTest/phpunit.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
<phpunit>
<phunit
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="./vendor/phpunit/phpunit/phpunit.xsd"
displayDetailsOnTestsThatTriggerWarnings="true"
colors="true">
<testsuites>
<testsuite name="core">
<directory>Core</directory>
Expand Down Expand Up @@ -31,4 +35,4 @@
<directory>Editors</directory>
</testsuite>
</testsuites>
</phpunit>
</phunit>
4 changes: 4 additions & 0 deletions src/php/DB/Settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -493,6 +493,10 @@ public function getAssociated(): ?array
*/
public function setSmtpConfiguration(?array $config): void
{
if(is_null($config)) {
$this->smtpConfiguration = null;
return;
}
$this->smtpConfiguration = [
"server" => $config["server"],
"port" => $config["port"],
Expand Down

0 comments on commit 1f9f680

Please sign in to comment.