Skip to content
This repository has been archived by the owner on Nov 29, 2021. It is now read-only.

Added trim to remove trailing slash in the server URL #118

Merged
merged 1 commit into from
Jan 7, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/Helper/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ public function __construct(array $config)

// Register Merged Config
$this->config = array_merge($this->getDefaultConfig(), $config);
$this->config['serverUrl'] = rtrim ($this->config['serverUrl'], "/");
}

/**
Expand Down
25 changes: 25 additions & 0 deletions tests/Helper/ConfigTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,4 +95,29 @@ public function testGetConfig() {
$this->assertEquals( $agent->getConfig()->get( 'appName' ), $init['appName'] );
}

/**
* @depends testControlDefaultConfig
*
* @covers \PhilKra\Helper\Config::__construct
* @covers \PhilKra\Agent::getConfig
* @covers \PhilKra\Helper\Config::getDefaultConfig
* @covers \PhilKra\Helper\Config::asArray
*/
public function testTrimElasticServerUrl() {
$init = [
'serverUrl' => 'http://foo.bar/',
'appName' => sprintf( 'app_name_%d', rand( 10, 99 ) ),
'active' => false,
];

$agent = new Agent( $init );
$config = $agent->getConfig()->asArray();
foreach( $init as $key => $value ) {
if ('serverUrl' === $key) {
$this->assertEquals('http://foo.bar', $config[$key]);
} else {
$this->assertEquals( $config[$key], $init[$key], 'key: ' . $key );
}
}
}
}