namespace CoreFramework\Configuration;
// Inport framework stuff
-use CoreFramework\Console\Tools\ConsoleTools;
use CoreFramework\Loader\ClassLoader;
use CoreFramework\Generic\NullPointerException;
use CoreFramework\Generic\UnsupportedOperationException;
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-
class FrameworkConfigurationTest extends TestCase {
/**
*/
private static $configInstance = NULL;
- /**
- * Own IP address
- */
- private static $ipAddress = FALSE;
-
/**
* Setup test case
*/
*/
ClassLoader::enableStrictNamingConventionCheck(FALSE);
- // Quiet DNS resolver as this is not wanted here
- self::$configInstance->setConfigEntry('quiet_dns_resolver', TRUE);
-
- // Lookup own IP address
- self::$ipAddress = ConsoleTools::acquireSelfIpAddress();
-
// Trace message
//* NOISY-DEBUG: */ printf('[%s:%d]: EXIT!' . PHP_EOL, __METHOD__, __LINE__);
}
self::$configInstance->unsetConfigEntry('__test_key');
}
- /**
- * Tests setting a NULL default timezone
- */
- public function testSettingNullDefaultTimezone () {
- // Will throw this exception
- $this->expectException(NullPointerException::class);
-
- // Test it
- self::$configInstance->setDefaultTimezone(NULL);
- }
-
- /**
- * Tests setting a boolean default timezone
- */
- public function testSettingBooleanDefaultTimezone () {
- // Will throw this exception
- $this->expectException(InvalidArgumentException::class);
-
- // Test it
- self::$configInstance->setDefaultTimezone(FALSE);
- }
-
- /**
- * Tests setting a decimal default timezone
- */
- public function testSettingDecimalDefaultTimezone () {
- // Will throw this exception
- $this->expectException(InvalidArgumentException::class);
-
- // Test it
- self::$configInstance->setDefaultTimezone(12345);
- }
-
- /**
- * Tests setting a float default timezone
- */
- public function testSettingFloatDefaultTimezone () {
- // Will throw this exception
- $this->expectException(InvalidArgumentException::class);
-
- // Test it
- self::$configInstance->setDefaultTimezone(123.45);
- }
-
- /**
- * Tests setting an array default timezone
- */
- public function testSettingArrayDefaultTimezone () {
- // Will throw this exception
- $this->expectException(InvalidArgumentException::class);
-
- // Test it
- self::$configInstance->setDefaultTimezone(array());
- }
-
- /**
- * Tests setting an object default timezone
- */
- public function testSettingObjectDefaultTimezone () {
- // Will throw this exception
- $this->expectException(InvalidArgumentException::class);
-
- // Test it
- self::$configInstance->setDefaultTimezone($this);
- }
-
- /**
- * Tests setting a resource default timezone
- */
- public function testSettingResourceDefaultTimezone () {
- // Will throw this exception
- $this->expectException(InvalidArgumentException::class);
-
- // Init some resource
- $resource = fopen(__FILE__, 'r');
-
- // Test it
- self::$configInstance->setDefaultTimezone($resource);
- }
-
- /**
- * Tests setting an empty default timezone
- */
- public function testSettingEmptyDefaultTimezone () {
- // Will throw this exception
- $this->expectException(InvalidArgumentException::class);
-
- // Test it
- self::$configInstance->setDefaultTimezone('');
- }
-
- /**
- * Tests setting invalid timezone
- */
- public function testSettingInvalidDefaultTimezone () {
- // Expect Notice
- $this->expectException(Notice::class);
-
- // Try to set it
- self::$configInstance->setDefaultTimezone('!invalid!');
- }
-
- /**
- * Tests setting valid timezone
- */
- public function testSettingValidDefaultTimezone () {
- // Will be true
- $this->assertTrue(self::$configInstance->setDefaultTimezone('Europe/Berlin'));
- }
-
- /**
- * Tests if detectServerAddress is returning what it should for tests.
- * This will always be 127.0.0.1.
- */
- public function testConfigDetectServerAddress () {
- // Call it
- $serverAddress = self::$configInstance->detectServerAddress();
-
- // Should be the same
- $this->assertEquals(self::$ipAddress, $serverAddress);
- }
-
- /**
- * Re-tests if detectServerAddress is returning what it should for tests.
- * This will always be 127.0.0.1. This call should not invoke
- * ConsoleTools's method as the configuration entry is already cached.
- */
- public function testConfigDetectServerAddressCached () {
- // Call it
- $serverAddress = self::$configInstance->detectServerAddress();
-
- // Should be the same
- $this->assertEquals(self::$ipAddress, $serverAddress);
- }
-
- /**
- * Tests setting a NULL server address
- */
- public function testConfigSettingNullServerAddress () {
- // Expect this exception
- $this->expectException(NullPointerException::class);
-
- // Test it
- self::$configInstance->setServerAddress(NULL);
- }
-
- /**
- * Tests setting a boolean server address
- */
- public function testConfigSettingBooleanServerAddress () {
- // Expect this exception
- $this->expectException(InvalidArgumentException::class);
-
- // Test it
- self::$configInstance->setServerAddress(FALSE);
- }
-
- /**
- * Tests setting a decimal server address
- */
- public function testConfigSettingDecimalServerAddress () {
- // Expect this exception
- $this->expectException(InvalidArgumentException::class);
-
- // Test it
- self::$configInstance->setServerAddress(12345);
- }
-
- /**
- * Tests setting a float server address
- */
- public function testConfigSettingFloatServerAddress () {
- // Expect this exception
- $this->expectException(InvalidArgumentException::class);
-
- // Test it
- self::$configInstance->setServerAddress(123.45);
- }
-
- /**
- * Tests setting an array server address
- */
- public function testConfigSettingArrayServerAddress () {
- // Expect this exception
- $this->expectException(InvalidArgumentException::class);
-
- // Test it
- self::$configInstance->setServerAddress(array());
- }
-
- /**
- * Tests setting an object server address
- */
- public function testConfigSettingObjectServerAddress () {
- // Expect this exception
- $this->expectException(InvalidArgumentException::class);
-
- // Test it
- self::$configInstance->setServerAddress($this);
- }
-
- /**
- * Tests setting a resource server address
- */
- public function testConfigSettingResourceServerAddress () {
- // Expect this exception
- $this->expectException(InvalidArgumentException::class);
-
- // Init some resource
- $resource = fopen(__FILE__, 'r');
-
- // Test it
- self::$configInstance->setServerAddress($resource);
- }
-
- /**
- * Tests setting an empty server address
- */
- public function testConfigSettingEmptyServerAddress () {
- // Expect this exception
- $this->expectException(InvalidArgumentException::class);
-
- // Test it
- self::$configInstance->setServerAddress('');
- }
-
- /**
- * Tests setting a valid server address and getting it back
- */
- public function testConfigGettingValidServerAddress () {
- // Test it
- self::$configInstance->setServerAddress('127.0.0.1');
-
- // Get it back
- $serverAddress = self::$configInstance->getServerAddress();
-
- // Should be equal
- $this->assertEquals('127.0.0.1', $serverAddress);
-
- // Set old back
- self::$configInstance->setServerAddress(self::$ipAddress);
- }
-
/**
* Tests if the method getField() is still unsupported in this class. Please
* note, that this and isFieldSet() may get removed in the future. So also