2 // Same namespace as target class
3 namespace Org\Mxchange\CoreFramework\Bootstrap;
5 // Inport framework stuff
6 use Org\Mxchange\CoreFramework\Console\Tools\ConsoleTools;
7 use Org\Mxchange\CoreFramework\Generic\NullPointerException;
8 use Org\Mxchange\CoreFramework\Generic\UnsupportedOperationException;
10 // Import PHPUnit stuff
11 use PHPUnit\Framework\Error\Notice;
12 use PHPUnit\Framework\TestCase;
15 use \InvalidArgumentException;
18 * Copyright (C) 2017 - 2022 Core Developer Team
20 * This program is free software: you can redistribute it and/or modify
21 * it under the terms of the GNU General Public License as published by
22 * the Free Software Foundation, either version 3 of the License, or
23 * (at your option) any later version.
25 * This program is distributed in the hope that it will be useful,
26 * but WITHOUT ANY WARRANTY; without even the implied warranty of
27 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
28 * GNU General Public License for more details.
30 * You should have received a copy of the GNU General Public License
31 * along with this program. If not, see <http://www.gnu.org/licenses/>.
33 class FrameworkBootstrapTest extends TestCase {
38 private static $ipAddress = FALSE;
43 public function setUp() {
45 //* NOISY-DEBUG: */ printf('[%s:%d]: CALLED!' . PHP_EOL, __METHOD__, __LINE__);
51 //* NOISY-DEBUG: */ printf('[%s:%d]: EXIT!' . PHP_EOL, __METHOD__, __LINE__);
58 public static function setUpBeforeClass() {
60 //* NOISY-DEBUG: */ printf('[%s:%d]: CALLED!' . PHP_EOL, __METHOD__, __LINE__);
63 parent::setUpBeforeClass();
65 // Lookup own IP address
66 self::$ipAddress = ConsoleTools::acquireSelfIpAddress();
69 //* NOISY-DEBUG: */ printf('[%s:%d]: EXIT!' . PHP_EOL, __METHOD__, __LINE__);
73 * Tests setting an empty default timezone
75 public function testSettingEmptyDefaultTimezone () {
76 // Will throw this exception
77 $this->expectException(InvalidArgumentException::class);
80 FrameworkBootstrap::setDefaultTimezone('');
84 * Tests setting invalid timezone
86 public function testSettingInvalidDefaultTimezone () {
88 $this->expectException(Notice::class);
91 FrameworkBootstrap::setDefaultTimezone('!invalid!');
95 * Tests setting valid timezone
97 public function testSettingValidDefaultTimezone () {
99 $this->assertTrue(FrameworkBootstrap::setDefaultTimezone('Europe/Berlin'));
103 * Tests if detectServerAddress() is returning what it should for tests.
104 * This will always be 127.0.0.1.
106 public function testConfigDetectServerAddress () {
108 $serverAddress = FrameworkBootstrap::detectServerAddress();
110 // Should be the same
111 $this->assertEquals(self::$ipAddress, $serverAddress);
115 * Re-tests if detectServerAddress() is returning what it should for tests.
116 * This will always be 127.0.0.1. This method should not invoke
117 * ConsoleTools's method as the configuration entry is already cached.
119 public function testConfigDetectServerAddressCached () {
121 $serverAddress = FrameworkBootstrap::detectServerAddress();
123 // Should be the same
124 $this->assertEquals(self::$ipAddress, $serverAddress);