3 // Same namespace as target class
4 namespace Org\Mxchange\CoreFramework\Bootstrap;
6 // Inport framework stuff
7 use Org\Mxchange\CoreFramework\Console\Tools\ConsoleTools;
8 use Org\Mxchange\CoreFramework\Loader\ClassLoader;
9 use Org\Mxchange\CoreFramework\Generic\NullPointerException;
10 use Org\Mxchange\CoreFramework\Generic\UnsupportedOperationException;
12 // Import PHPUnit stuff
13 use PHPUnit\Framework\Error\Notice;
14 use PHPUnit\Framework\TestCase;
17 use \InvalidArgumentException;
20 * Copyright (C) 2017 - 2020 Core Developer Team
22 * This program is free software: you can redistribute it and/or modify
23 * it under the terms of the GNU General Public License as published by
24 * the Free Software Foundation, either version 3 of the License, or
25 * (at your option) any later version.
27 * This program is distributed in the hope that it will be useful,
28 * but WITHOUT ANY WARRANTY; without even the implied warranty of
29 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
30 * GNU General Public License for more details.
32 * You should have received a copy of the GNU General Public License
33 * along with this program. If not, see <http://www.gnu.org/licenses/>.
35 class FrameworkBootstrapTest extends TestCase {
40 private static $ipAddress = FALSE;
45 public function setUp() {
47 //* NOISY-DEBUG: */ printf('[%s:%d]: CALLED!' . PHP_EOL, __METHOD__, __LINE__);
53 //* NOISY-DEBUG: */ printf('[%s:%d]: EXIT!' . PHP_EOL, __METHOD__, __LINE__);
60 public static function setUpBeforeClass() {
62 //* NOISY-DEBUG: */ printf('[%s:%d]: CALLED!' . PHP_EOL, __METHOD__, __LINE__);
65 parent::setUpBeforeClass();
68 * Disable strict naming-convention check in own class loader, because
69 * PHP_Invoker doesn't have namespaces.
71 ClassLoader::enableStrictNamingConventionCheck(FALSE);
73 // Lookup own IP address
74 self::$ipAddress = ConsoleTools::acquireSelfIpAddress();
77 //* NOISY-DEBUG: */ printf('[%s:%d]: EXIT!' . PHP_EOL, __METHOD__, __LINE__);
81 * Tests setting an empty default timezone
83 public function testSettingEmptyDefaultTimezone () {
84 // Will throw this exception
85 $this->expectException(InvalidArgumentException::class);
88 FrameworkBootstrap::setDefaultTimezone('');
92 * Tests setting invalid timezone
94 public function testSettingInvalidDefaultTimezone () {
96 $this->expectException(Notice::class);
99 FrameworkBootstrap::setDefaultTimezone('!invalid!');
103 * Tests setting valid timezone
105 public function testSettingValidDefaultTimezone () {
107 $this->assertTrue(FrameworkBootstrap::setDefaultTimezone('Europe/Berlin'));
111 * Tests if detectServerAddress() is returning what it should for tests.
112 * This will always be 127.0.0.1.
114 public function testConfigDetectServerAddress () {
116 $serverAddress = FrameworkBootstrap::detectServerAddress();
118 // Should be the same
119 $this->assertEquals(self::$ipAddress, $serverAddress);
123 * Re-tests if detectServerAddress() is returning what it should for tests.
124 * This will always be 127.0.0.1. This method should not invoke
125 * ConsoleTools's method as the configuration entry is already cached.
127 public function testConfigDetectServerAddressCached () {
129 $serverAddress = FrameworkBootstrap::detectServerAddress();
131 // Should be the same
132 $this->assertEquals(self::$ipAddress, $serverAddress);