From: Roland Häder Date: Sun, 16 Jul 2017 00:32:39 +0000 (+0200) Subject: Cleanup: X-Git-Url: https://git.mxchange.org/?p=core.git;a=commitdiff_plain;h=e358330c74fb96756839c97c1194f4bdb3c305a3 Cleanup: - removed deprecated unit tests, very old-lost stuff - removed deprecated setMagicQuotesRuntime() which only wraps an already deprecated PHP function - unit tests with PHPUnit are coming! :-) Signed-off-by: Roland Häder --- diff --git a/.gitignore b/.gitignore index 35e1d964..0577ff27 100644 --- a/.gitignore +++ b/.gitignore @@ -1,18 +1,19 @@ -contrib/chash/chash.pos -contrib/lfdb2/*.bin* -contrib/lfdb2/*.out* -contrib/mindmaps/*.png -contrib/mindmaps/*.svg -inc/config/config-local.php +/contrib/chash/chash.pos +/contrib/lfdb2/*.bin* +/contrib/lfdb2/*.out* +/contrib/mindmaps/*.png +/contrib/mindmaps/*.svg +/inc/config/config-local.php /nbproject/private/* -templates/_compiled/*.* -templates/images/_cache/*.* +/templates/_compiled/*.* +/templates/images/_cache/*.* *.*~ /.cache /.project /.settings -application/*/config-local.php -db/*/*.serialized -docs/html/* -docs/latex/* -docs/warn.log +/application/*/config-local.php +/db/*/*.serialized +/docs/html/* +/docs/latex/* +/docs/warn.log +/reports/*.* diff --git a/framework/config/class_FrameworkConfiguration.php b/framework/config/class_FrameworkConfiguration.php index 17c456e7..9da74c43 100644 --- a/framework/config/class_FrameworkConfiguration.php +++ b/framework/config/class_FrameworkConfiguration.php @@ -124,27 +124,6 @@ class FrameworkConfiguration implements Registerable { } // END - if } - /** - * Setter for runtime magic quotes - * - * @param $enableQuotes Whether enable magic runtime quotes (should be disabled for security reasons) - * @return void - * @todo This method encapsulates a deprecated PHP function and should be deprecated, too. - */ - public final function setMagicQuotesRuntime ($enableQuotes) { - // Is the PHP version < 5.4? - if (version_compare(phpversion(), '5.4', '>=')) { - // Then silently skip this part as set_magic_quotes_runtime() is deprecated - return; - } // END - if - - // Cast it to boolean - $enableQuotes = (boolean) $enableQuotes; - - // Set it - set_magic_quotes_runtime($enableQuotes); - } - /** * Checks whether the given configuration key is set * diff --git a/nbproject/project.properties b/nbproject/project.properties index 3f57abd9..7982449d 100644 --- a/nbproject/project.properties +++ b/nbproject/project.properties @@ -5,17 +5,31 @@ auxiliary.org-netbeans-modules-css-prep.sass_2e_compiler_2e_options= auxiliary.org-netbeans-modules-css-prep.sass_2e_enabled=false auxiliary.org-netbeans-modules-css-prep.sass_2e_mappings=/scss:/css auxiliary.org-netbeans-modules-javascript2-requirejs.enabled=false +auxiliary.org-netbeans-modules-php-phpunit.bootstrap_2e_create_2e_tests=false +auxiliary.org-netbeans-modules-php-phpunit.bootstrap_2e_enabled=false +auxiliary.org-netbeans-modules-php-phpunit.bootstrap_2e_path= +auxiliary.org-netbeans-modules-php-phpunit.configuration_2e_enabled=false +auxiliary.org-netbeans-modules-php-phpunit.configuration_2e_path= +auxiliary.org-netbeans-modules-php-phpunit.customSuite_2e_enabled=false +auxiliary.org-netbeans-modules-php-phpunit.customSuite_2e_path= +auxiliary.org-netbeans-modules-php-phpunit.phpUnit_2e_enabled=false +auxiliary.org-netbeans-modules-php-phpunit.phpUnit_2e_path= +auxiliary.org-netbeans-modules-php-phpunit.test_2e_groups_2e_ask=false +auxiliary.org-netbeans-modules-php-phpunit.test_2e_run_2e_all=false auxiliary.org-netbeans-modules-web-clientproject-api.js_2e_libs_2e_folder=js/libs browser.reload.on.save=true code.analysis.excludes= +file.reference.core-tests=tests ignore.path= include.path=\ ${php.global.include.path} php.version=PHP_56 project.license=gpl30 +selenium.src.dir=${file.reference.core-tests} source.encoding=UTF-8 src.dir=. tags.asp=false tags.short=false -testing.providers= +test.src.dir=${file.reference.core-tests} +testing.providers=PhpUnit web.root=. diff --git a/tests/ConfigTest.php b/tests/ConfigTest.php deleted file mode 100644 index 2896d393..00000000 --- a/tests/ConfigTest.php +++ /dev/null @@ -1,151 +0,0 @@ -getConfigEntry('framework_base_path') . 'includes.php'; - -// Load all game classes -require $cfg->getConfigEntry('framework_base_path') . 'classes.php'; - -// Set default application -FrameworkConfiguration::getInstance()->setConfigEntry('default_application', 'shipsimu'); - -// Set testing mode (no starter.php will be loaded!) -define('TEST_MODE', true); - -// Load the PHPUnit framework -require 'PHPUnit/Framework.php'; - -print (basename(__FILE__).": Init completed.\n\n"); - -/** - * A test case for the configuration sub system - * - * @author Roland Haeder - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * @see http://www.phpunit.de - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class ConfigTest extends PHPUnit_Framework_TestCase { - /** - * Tests the exception ConfigEntryNotFoundException if it is being thrown. - * Else the test shall fail - * - * @return void - */ - public function testConfigEntryNotFoundException () { - // Now try the test - $testPassed = false; - try { - // Now find a configuration variable that does not exist - $dummy = FrameworkConfiguration::getInstance()->getConfigEntry('does_not_exist'); - } catch (ConfigEntryNotFoundException $expected) { - // This exception was expected, so it is fine - $testPassed = true; - } catch (FrameworkException $unexptected) { - // This exception was not expected! - $this->fail(sprintf("Unexpected exception %s detected.", $unexpected->__toString())); - } - - if (!$testPassed) { - // This test went wrong - $this->fail("Test of thrown exception ConfigEntryNotFoundException failed!"); - } - } - - /** - * Tests if the exception ConfigEntryIsEmptyException is being thrown by - * "emulating" an empty configuration variable. - * - * @return void - */ - public function testConfigEntryIsEmptyExceptionRead () { - // Now try the test - $testPassed = false; - try { - // Try to read an empty configuration variable - $dummy = FrameworkConfiguration::getInstance()->getConfigEntry(''); - } catch (ConfigEntryIsEmptyException $expected) { - // This exception was expected, so it is fine - $testPassed = true; - } catch (FrameworkException $unexptected) { - // This exception was not expected! - $this->fail(sprintf("Unexpected exception %s detected.", $unexpected->__toString())); - } - - if (!$testPassed) { - // This test went wrong - $this->fail("Test of thrown exception ConfigEntryIsEmptyException failed!"); - } - } - - /** - * Tests if the exception ConfigEntryIsEmptyException is being thrown by - * "emulating" an empty configuration variable. - * - * @return void - */ - public function testConfigEntryIsEmptyExceptionWrite () { - // Now try the test - $testPassed = false; - try { - // Try to read an empty configuration variable - FrameworkConfiguration::getInstance()->setConfigEntry('', 'will_never_be_set'); - } catch (ConfigEntryIsEmptyException $expected) { - // This exception was expected, so it is fine - $testPassed = true; - } catch (FrameworkException $unexptected) { - // This exception was not expected! - $this->fail(sprintf("Unexpected exception %s detected.", $unexpected->__toString())); - } - - if (!$testPassed) { - // This test went wrong - $this->fail("Test of thrown exception ConfigEntryIsEmptyException failed!"); - } - } - - /** - * Tests if a set value can be returned from the configuration sub-system - * - * @return void - */ - public function testWritegetConfigEntryEntry () { - // Try it here - $value = "This is a test value"; - try { - // Try to read an empty configuration variable - FrameworkConfiguration::getInstance()->setConfigEntry('test_key', "{$value}"); - - // Read the config entry we have just written - $readValue = FrameworkConfiguration::getInstance()->getConfigEntry('test_key'); - - // Now test the values - $this->assertEquals($value, $readValue); - } catch (FrameworkException $unexptected) { - // This exception was not expected! - $this->fail(sprintf("Unexpected exception %s detected.", $unexpected->__toString())); - } - } -} diff --git a/tests/RegistryTest.php b/tests/RegistryTest.php deleted file mode 100644 index 4807b416..00000000 --- a/tests/RegistryTest.php +++ /dev/null @@ -1,92 +0,0 @@ -getConfigEntry('framework_base_path') . 'includes.php'; - -// Load all game classes -require $cfg->getConfigEntry('framework_base_path') . 'classes.php'; - -// Set default application -FrameworkConfiguration::getInstance()->setConfigEntry('default_application', 'shipsimu'); - -// Set testing mode (no starter.php will be loaded!) -define('TEST_MODE', true); - -// Load the PHPUnit framework -require 'PHPUnit/Framework.php'; - -print (basename(__FILE__).": Init completed.\n\n"); - -/** - * A test case for the registry - * - * @author Roland Haeder - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * @see http://www.phpunit.de - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class RegistryTest extends PHPUnit_Framework_TestCase { - /** - * Tests if we can store an instance to the registry - * - * @return void - */ - public function testInstanceRegistryAdd () { - // Get a registry instance - $registryInstance = Registry::getRegistry(); - - // Create a User instance - $userInstance = Member::createMemberByEmail("webmaster@shipsimu.org"); - - // Now store the instance in the registry - $registryInstance->addInstance('user', $userInstance); - - // Test if the registry key is there - if (!$registryInstance->instanceExists('user')) { - $this->fail("Registry test failed: Cannot locate our user instance in registry!"); - } - } - - /** - * Tests if we can store an instance to the registry - * - * @return void - */ - public function testInstanceRegistryCompare () { - // Get a registry instance - $registryInstance = Registry::getRegistry(); - - // And get it back - $userInstance = $registryInstance->getInstance('user'); - - // Compare both unique keys - $testPassed = ($userInstance instanceof ManageableAccount); - - // Test passed? - if (!$testPassed) { - $this->fail("Registry test failed: Method getInstance() returned a non-object."); - } - } -} diff --git a/tests/RequestTest.php b/tests/RequestTest.php deleted file mode 100644 index 784239f1..00000000 --- a/tests/RequestTest.php +++ /dev/null @@ -1,100 +0,0 @@ -getConfigEntry('framework_base_path') . 'includes.php'; - -// Load all game classes -require $cfg->getConfigEntry('framework_base_path') . 'classes.php'; - -// Set default application -FrameworkConfiguration::getInstance()->setConfigEntry('default_application', 'shipsimu'); - -// Set testing mode (no starter.php will be loaded!) -define('TEST_MODE', true); - -// Load the PHPUnit framework -require 'PHPUnit/Framework.php'; - -print (basename(__FILE__).": Init completed.\n\n"); - -/** - * A test case for faked HTTP requests. This is faked because we *set* - * $_REQUEST here. This should be made better in PHP6... :( - * - * @author Roland Haeder - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * @see http://www.phpunit.de - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class RequestTest extends PHPUnit_Framework_TestCase { - /** - * A non-exist request element is being asked for. null is the expected - * result from the class - * - * @return void - */ - public function testMissingRequestElement () { - // Get a request instance - $requestInstance = HtmlRequest::createHtmlRequest(); - - // Get the element - $nonExist = $requestInstance->getRequestElement('never_there'); - - // Is this null? - if (!is_null($nonExist)) { - // Is not null! - $this->fail(sprintf("[%s:] Unexpected type %s received from request handler.", - $requestInstance->__toString(), - gettype($nonExists) - )); - } - } - - /** - * Now fake a request array and try the test on it again - * - * @return void - */ - public function testFakeRequestElement () { - // Fake the request here - $_REQUEST = array('test_key' => 'test_value'); - - // Again get an instance - $requestInstance = HtmlRequest::createHtmlRequest(); - - // Get the element - $testValue = $requestInstance->getRequestElement('test_key'); - - // Is it the same? - if ($testValue !== 'test_value') { - // Something went wrong - $this->fail(sprintf('[%s] Unexpected value %s (%s) from test key received.', - $requestInstance->__toString(), - $testValue, - gettype($testValue) - )); - } - } -} diff --git a/tests/Test.php b/tests/Test.php deleted file mode 100644 index f9f1952f..00000000 --- a/tests/Test.php +++ /dev/null @@ -1,52 +0,0 @@ -getConfigEntry('framework_base_path') . 'includes.php'; - -// Load all game classes -require $cfg->getConfigEntry('framework_base_path') . 'classes.php'; - -// Set default application -FrameworkConfiguration::getInstance()->setConfigEntry('default_application', 'shipsimu'); - -// Set testing mode (no starter.php will be loaded!) -define('TEST_MODE', true); - -// Load the PHPUnit framework -require 'PHPUnit/Framework.php'; - -print (basename(__FILE__).": Init completed.\n\n"); -die("You need to remove this line (".__LINE__.") and implement this test!\n"); - -/** - * A test case for - * - * @author Roland Haeder - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * @see http://www.phpunit.de - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class Test extends PHPUnit_Framework_TestCase { -} diff --git a/tests/all-tests.sh b/tests/all-tests.sh deleted file mode 100755 index 13c704a6..00000000 --- a/tests/all-tests.sh +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/sh - -find -type f -name "*Test.php" -not -name "Test.php" -exec sh ./unittest.sh {} \; diff --git a/tests/old/contract-test.php b/tests/old/contract-test.php deleted file mode 100644 index 962719d6..00000000 --- a/tests/old/contract-test.php +++ /dev/null @@ -1,349 +0,0 @@ -getConfigEntry('framework_base_path') . 'includes.php'; - -// Load all game classes -require $cfg->getConfigEntry('framework_base_path') . 'classes.php'; - -// Load file I/O handler -require $cfg->getConfigEntry('framework_base_path') . 'file_io.php'; - -// Load database layer -require $cfg->getConfigEntry('framework_base_path') . 'database.php'; - -// Set default application -FrameworkConfiguration::getInstance()->setConfigEntry('default_application', 'shipsimu'); -$application = 'shipsimu'; - -// Load more includes -require $cfg->getConfigEntry('root_base_path') . 'application/shipsimu/loader.php'; - -// Wir tun hier so, als waere schon das Reederei-Objekt generiert und wir wollen -// jetzt die Personalliste wiederherstellen -$personell = SimulatorPersonell::createSimulatorPersonellByID('SimulatorPersonell@829292aeca3f6bf78c16e25fc4f75c98'); - -// Personal-Objekt debuggen -if (defined('DEBUG_PERSONELL_OBJ')) { - DebugMiddleware::getInstance()->output(sprintf("The personal object looks like this:
-
%s
\n", - print_r($personell, true) - )); -} - -// Hafen bauen -$harbor = Harbor::createHarbor("Hamburger Hafen"); - -// Name ausgeben -DebugMiddleware::getInstance()->output(sprintf("Der %s ist gegründet worden.
\n", - $harbor->getHarborName() -)); - -// Hafen-Objekt debuggen -if (defined('DEBUG_HARBOR_OBJ')) { - DebugMiddleware::getInstance()->output(sprintf("Der %s sieht wie folgt aus:
-
%s
\n", - $harbor->getHarborName(), - print_r($harbor, true) - )); -} - -// Haendler gruenden -$merchant = Merchant::createMerchant("Namenlos", $harbor); - -// Array mit Einbauten erstellen -$einbauten = array( - 'parts' => array( // *** Die zu einbauenden Schiffsteile *** - 'Motor' => array( // --- Maschinenraum mit Motor --- - "Ocean-Power 2000", // Bezeichnung - 20000, // Pferdestaerken - 6, // Anzahl Nocken - 2.5, 2, 3.5 // Abmasse (Breite/Hoehe/Laenge) - ), - 'Bridge' => array( // --- Kommandobruecke --- - 26, 2.5, 15 // Abmasse (Breite/Hoehe/Laenge) - ), - 'CarDeck' => array( // --- Autodecks --- - 'amount' => 8, // Anzahl Autodecks (einige liegen hintereinander im selben Deck!) - 'dim' => array( // Abmessung (Breite/Hoehe/Laenge) - 6, 3, 16 - ) - ), - 'TruckDeck' => array( // --- Decks fuer LKW/Busse haben vielleicht ein anderes Belueftgungssystem, etc. --- - 'amount' => 1, // Anzahl der Decks - 'dim' => array( // Abmessung (Breite/Hoehe/Laenge) - 8, 5, 195 // Geht durchs gesamte Schiff! - ) - ), - 'TrainDeck' => array( // --- Decks fuer Zuege haben Schienen... --- - 'amount' => 1, // Anzahl der Decks - 'dim' => array( // Abmessung (Breite/Hoehe/Laenge) - 8, 4, 195 // Geht durchs gesamte Schiff! - ) - ), - 'LuxuryCabin' => array( // --- Luxuskabinen --- - 'amount' => 20, // Anzahl Luxuskabinen im Schiff - 'rooms' => 4, // Raeume: 2 Schlafzimmer, 1 Auffenthaltszimmer, 1 Bad mit Dusche/Toilette/Waschbecken - 'bed' => 3, // Anzahl Betten (1 Doppelbett 2 Einzelbetten, Doppel-/Einzelbetten in getrennte Raeume) - 'dim' => array( // Abmessung der Luxuskabine (Breite/Hoehe/Laenge) - 4, 3, 5 - ), - ), - 'PremierCabin' => array( // --- Mittlere Kabinen --- - 'amount' => 40, // Anzahl - 'rooms' => 2, // Raeume: Schlafzimmer, Bad mit Toilette/Waschbecken - 'bed' => 2, // Anzahl Betten (1 Doppelbett, 1 Einzelbett; gemeinsamer Raum) - 'dim' => array( // Abmessungen der Kabine (Breite/Hoehe/Laenge) - 4, 2.5, 4 - ) - ), - 'LowCabin' => array( // --- Untere Kabinen (befinden sich in den Unterbauten) --- - 'amount' => 90, // Anzahl - 'rooms' => 1, // Raeume: Schlafzimmer, Waschbecken - 'bed' => 2, // Anzahl Betten (2 Etagenbetten) - 'dim' => array( // Abmessungen der Kabine (Breite/Hoehe/Laenge) - 3, 2.5, 4 - ) - ), - 'EconomyCabin' => array( // --- Unterste Kabinen (befinden sich tief unten im Schiffsbauch) --- - 'amount' => 140, // Anzahl - 'rooms' => 1, // Raeume: Schlafzimmer, Waschbecken - 'bed' => 1, // Anzahl Betten (1 Etagenbett) - 'dim' => array( // Abmessungen der Kabine (Breite/Hoehe/Laenge) - 2, 2.5, 2 - ) - ) - ), - 'builds' => array( // *** Welche Oberklasse verwendet werden sollen *** - 'Motor' => "MaschineRoom", - 'Bridge' => "BaseUpperStructure", - 'LuxuryCabin' => "BaseCabin", - 'PremierCabin' => "BaseCabin", - 'LowCabin' => "BaseCabin", - 'EconomyCabin' => "BaseCabin", - 'CarDeck' => "BaseDeck", - 'TrainDeck' => "BaseDeck", - 'TruckDeck' => "BaseDeck" - ) -); - -// Preisliste auffuellen -foreach ($einbauten['parts'] as $key=>$part) { - // Create item array string - $item = ''; - foreach ($part as $idx=>$itemPart) { - if (is_string($itemPart)) { - // String found - $item .= sprintf("\"%s\", ", $itemPart); - } elseif (is_int($itemPart)) { - // Integer found - $item .= sprintf("%d, ", $itemPart); - } elseif (is_float($itemPart)) { - // Float found - $item .= sprintf("%f, ", $itemPart); - } elseif (is_array($itemPart)) { - // Sub-array found - $item .= "array("; - - // Go all items through - foreach ($itemPart as $idx2=>$subPart) { - if (is_int($subPart)) { - // Integer again found - $item .= sprintf("%d, ", $subPart); - } elseif (is_float($subPart)) { - // Float found - $item .= sprintf("%f, ", $subPart); - } else { - // Unsupport part found - die(sprintf("[Main:] Unsupported sub-array element on pos %d in array %s found: %s", $idx2, $idx, $subPart)); - } - } - - // Remove trailing comma - $item = substr($item, 0, -2); - - // Add closing bracket - $item .= "), "; - } else { - // Unsupport part found - die(sprintf("[Main:] Unsupported array element on pos %d: %s", $idx, $itemPart)); - } - } - - // Remove trailing comma - $item = substr($item, 0, -2); - - // Random price - $price = mt_rand(5, 12) * 10000; - - // Generate command for adding objects to a price list - $eval = sprintf("\$merchant->addItemToPriceList(%s::create%s(%s), %d);", - $key, - $key, - $item, - $price - ); - - // Debug message - if ((defined('DEBUG_EVAL')) || (defined('DEBUG_ALL'))) DebugMiddleware::getInstance()->output(sprintf("[Main:] Konstruierte PHP-Anweisung:
%s

\n", - htmlentities($eval) - )); - - // Run the constructed command - eval($eval); -} - -// Haendler-Objekt debuggen -if (defined('DEBUG_MERCHANT_OBJ')) { - DebugMiddleware::getInstance()->output(sprintf("Der Händler %s sieht wie folgt aus:
-
%s
\n", - $merchant->getMerchantName(), - print_r($merchant, true) - )); -} - -// Reederei gruenden -$shipping = ShippingCompany::createShippingCompany("Hanseatic Travel Company", $harbor); - -// Firmenschef setzen -$shipping->setCompanyFounder(CompanyEmployee::createCompanyEmployee("Roland", "Häder", "M", 1977, 9, 26, true, 2000)); - -// Dann mal ausgeben... -DebugMiddleware::getInstance()->output(sprintf("Die Reederei %s ist von %s %s gegründet worden.
\n", - $shipping->getCompanyName(), - $shipping->getFounderInstance()->getSurname(), - $shipping->getFounderInstance()->getFamily() -)); - -// Die Reederei stellt Personal ein und bedient sich an der $personell-Instanz -$shipping->recruitRandomEmployees(10, $personell); - -// Anzahl Personal ausgeben -DebugMiddleware::getInstance()->output(sprintf("Die Reederei %s hat nun %d weitere Mitarbeiter.
\n", - $shipping->getCompanyName(), - $shipping->getTotalEmployee() -)); - -// Dann die ersten 3 Werften in den Hafen einbauen und Personal zuweisen -$shipping->createShipyardInHarbor("Werft 1", $harbor); -$shipping->createShipyardInHarbor("Werft 2", $harbor); -$shipping->createShipyardInHarbor("Werft 3", $harbor); - -// In alle Werften sollen Passagierschiffe gebaut werden koennen -$shipping->addShipTypeToAllShipyards("PassengerShip"); - -// Personal auf die Werften verteilen -$shipping->distributeAllPersonellOnShipyards(); - -// Normale Meldung ausgeben -DebugMiddleware::getInstance()->output(sprintf("Die Reederei %s beschäftigt nun ihre %d Mitarbeiter in %d Werft(en):
\n", - $shipping->getCompanyName(), - $shipping->getTotalEmployee(), - $shipping->getTotalShipyards() -)); - -// Dann nimmt die Reederei ihren ersten Bauauftrag entgegen. -// Sie muss auch sich selber Bauauftraege erteilen! -$shipping->addNewWorksContract(WorksContract::createWorksContract("PassengerShip", "M/S Poseidon", $shipping)); - -// Auftrag-Instanz holen -$contract = $shipping->getLastContractInstance(); - -// Die Reederei hat einen Haendler gewaehlt -$shipping->setMerchantInstance($merchant); - -// Den Bauauftrag mit der Reederei abgleichen, ob sie den Schiffstyp bauen koennen -$typeValid = $shipping->validateWorksContractShipType($contract); - -// Kann gebaut werden? -if ($typeValid) { - DebugMiddleware::getInstance()->output(sprintf("Die Reederei %s kann Schiffe vom Typ %s bauen.
\n", - $shipping->getCompanyName(), - $contract->getShipInstance()->getObjectDescription() - )); -} else { - DebugMiddleware::getInstance()->output(sprintf("Die Reederei %s kann keine Schiffe vom Typ %s bauen!
\n", - $shipping->getCompanyName(), - $contract->getShipInstance()->getObjectDescription() - )); - exit; -} - -// Dann den Bauauftrag verfeinern -foreach ($einbauten['parts'] as $key=>$part) { - $contract->addContractDetails($key, $einbauten['builds'][$key], $part); -} - -// Reederei-Objekt ausgeben -if (defined('DEBUG_COMPANY_OBJ')) { - DebugMiddleware::getInstance()->output(sprintf("Die Reederei %s sieht wie folgt aus:
-
%s
\n", - $shipping->getCompanyName(), - print_r($shipping, true) - )); -} - -// Clean up a little -unset($einbauten); -unset($part); -unset($eval); -unset($item); -unset($key); -unset($typeValid); - -// Gesamtwert ausgeben -$totalValue = $contract->getTotalPrice(); - -// Wert ausgeben -DebugMiddleware::getInstance()->output(sprintf("Der Bau der %s wird der Reederei %s voraussichtlich %s kosten.
\n", - $contract->getShipInstance()->getShipName(), - $shipping->getCompanyName(), - $contract->formatCurrency($totalValue) -)); - -// Clean up a little -unset($totalValue); - -// Den Bauvertrag unterschreiben (damit wird er in den Bau-Queue aufgenommen) -$shipping->signContract($contract, $shipping); - -// Meldung ausgeben -if ($contract->isSigned()) { - DebugMiddleware::getInstance()->output(sprintf("Die Reederei %s hat den Bau der %s zugestimmt.
\n", - $shipping->getCompanyName(), - $contract->getShipInstance()->getShipName() - )); -} else { - DebugMiddleware::getInstance()->output(sprintf("Die Reederei %s hat den Bau der %s abgelehnt.
\n", - $shipping->getCompanyName(), - $contract->getShipInstance()->getShipName() - )); - exit; -} - -// Auftrag-Objekt ausgeben -if (defined('DEBUG_CONTRACT_OBJ')) { - DebugMiddleware::getInstance()->output(sprintf("Der Bauauftrag sieht wie folgt aus:
-
%s
\n", - print_r($contract, true) - )); -} - -// Erstmal bis hier hin... -//exit(); - -// Anzahl Betten ermitteln -$totalBeds = $contract->getShipInstance()->calcTotalBeds(); - -// Bettenanzahl ausgeben -DebugMiddleware::getInstance()->output(sprintf("Es stehen %d Betten zur Verfügung.", - $totalBeds -)); diff --git a/tests/old/loader-test.php b/tests/old/loader-test.php deleted file mode 100644 index aea6638c..00000000 --- a/tests/old/loader-test.php +++ /dev/null @@ -1,57 +0,0 @@ -getConfigEntry('framework_base_path') . 'includes.php'; - -// Load all game classes -require $cfg->getConfigEntry('framework_base_path') . 'classes.php'; - -// Load file I/O handler -require $cfg->getConfigEntry('framework_base_path') . 'file_io.php'; - -// Load database layer -require $cfg->getConfigEntry('framework_base_path') . 'database.php'; - -// Set default application -FrameworkConfiguration::getInstance()->setConfigEntry('default_application', 'shipsimu'); -$application = 'shipsimu'; - -// Load more includes -require $cfg->getConfigEntry('root_base_path') . 'application/shipsimu/loader.php'; - -// Wir tun hier so, als waere schon das Reederei-Objekt generiert und wir wollen -// jetzt die Personalliste wiederherstellen -$personell = SimulatorPersonell::createSimulatorPersonellByID('SimulatorPersonell@829292aeca3f6bf78c16e25fc4f75c98'); - -// Personal-Objekt debuggen -if (defined('DEBUG_PERSONELL_OBJ')) { - DebugMiddleware::getInstance()->output(sprintf("The personal object looks like this:
-
%s
\n", - print_r($personell, true) - )); -} - -// Erstmal bis hier hin -exit(); - -// Etwas zum Testen... -$personell = SimulatorPersonell::createSimulatorPersonell(20); - -// Personal-Objekt debuggen -if (defined('DEBUG_PERSONELL_OBJ')) { - DebugMiddleware::getInstance()->output(sprintf("The personal object looks like this:
-
%s
\n", - print_r($personell, true) - )); -} - -// Try to save the object (for testing purposes) -$personell->saveObjectToDatabase(); diff --git a/tests/old/personell-test.php b/tests/old/personell-test.php deleted file mode 100644 index ab78f525..00000000 --- a/tests/old/personell-test.php +++ /dev/null @@ -1,57 +0,0 @@ -getConfigEntry('framework_base_path') . 'includes.php'; - -// Load all game classes -require $cfg->getConfigEntry('framework_base_path') . 'classes.php'; - -// Load file I/O handler -require $cfg->getConfigEntry('framework_base_path') . 'file_io.php'; - -// Load database layer -require $cfg->getConfigEntry('framework_base_path') . 'database.php'; - -// Set default application -FrameworkConfiguration::getInstance()->setConfigEntry('default_application', 'shipsimu'); -$application = 'shipsimu'; - -// Load more includes -require $cfg->getConfigEntry('root_base_path') . 'application/shipsimu/loader.php'; - -// Wir tun hier so, als waere schon das Reederei-Objekt generiert und wir wollen -// jetzt die Personalliste wiederherstellen -$personell = SimulatorPersonell::createSimulatorPersonellByID('SimulatorPersonell@829292aeca3f6bf78c16e25fc4f75c98'); - -// Personal-Objekt debuggen -if (defined('DEBUG_PERSONELL_OBJ')) { - echo sprintf("The personal object looks like this:
-
%s
\n", - print_r($personell, true) - ); -} - -// Erstmal bis hier hin -exit(); - -// Etwas zum Testen... -$personell = SimulatorPersonell::createSimulatorPersonell(20); - -// Personal-Objekt debuggen -if (defined('DEBUG_PERSONELL_OBJ')) { - echo sprintf("The personal object looks like this:
-
%s
\n", - print_r($personell, true) - ); -} - -// Try to save the object (for testing purposes) -$personell->saveObjectToDatabase(); diff --git a/tests/unittest.sh b/tests/unittest.sh deleted file mode 100755 index 18e210c5..00000000 --- a/tests/unittest.sh +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/sh - -FILE=`echo $1 | cut -d "/" -f 2` - -phpunit --wait $FILE