[mapguide-commits] r7178 - in trunk/MgDev/UnitTest: . WebTier/Php

svn_mapguide at osgeo.org svn_mapguide at osgeo.org
Thu Nov 1 08:12:33 PDT 2012


Author: jng
Date: 2012-11-01 08:12:33 -0700 (Thu, 01 Nov 2012)
New Revision: 7178

Added:
   trunk/MgDev/UnitTest/run_php_tests.bat
   trunk/MgDev/UnitTest/set_test_params.bat
Modified:
   trunk/MgDev/UnitTest/WebTier/Php/RunTests.php
Log:
#2166: Make the Web Tier test suite simpler to set up and run.
 - Add a set of batch files that will harness the existing PHP binaries under Oem to invoke the PHP-based test runner. The 32-bit Oem PHP binaries require ssleay32.dll and libeay32.dll to be present (see batch file for more information)
 - Modify RunTests.php to accept a switch (-apionly). If defined, the http related tests will be skipped. The default batch file settings will run the test runner with this switch defined because the http tests still require a mapagent that has to be manually set up on a web server.

Modified: trunk/MgDev/UnitTest/WebTier/Php/RunTests.php
===================================================================
--- trunk/MgDev/UnitTest/WebTier/Php/RunTests.php	2012-10-31 13:26:16 UTC (rev 7177)
+++ trunk/MgDev/UnitTest/WebTier/Php/RunTests.php	2012-11-01 15:12:33 UTC (rev 7178)
@@ -30,6 +30,7 @@
     $testsFailed = 0;
     $testsRun = 0;
     $isEnterprise = false;
+    $runApiTestsOnly = false;
     $file = fopen("UnitTests.log", "w");
 
     date_default_timezone_set("GMT-0");
@@ -47,6 +48,17 @@
     {
         $isEnterprise = true;
     }
+    
+    if (($_SERVER['argc']>1))
+    {
+        for ($i = 0; $i < count($_SERVER['argv']); $i++)
+        {
+            if ($_SERVER['argv'][$i] == "-apionly")
+            {
+                $runApiTestsOnly = true;
+            }
+        }
+    }
 
     if (!$file)
     {
@@ -54,19 +66,24 @@
     }
 
     $testsFailed += ExecuteTest("Api", "../../TestData/ResourceService/ResourceServiceTest.dump", $testsRun, $file, $isEnterprise);
-    $testsFailed += ExecuteTest("Http", "../../TestData/ResourceService/ResourceServiceTest.dump", $testsRun, $file, $isEnterprise);
+    if (!$runApiTestsOnly)
+        $testsFailed += ExecuteTest("Http", "../../TestData/ResourceService/ResourceServiceTest.dump", $testsRun, $file, $isEnterprise);
 
     $testsFailed += ExecuteTest("Api", "../../TestData/DrawingService/DrawingServiceTest.dump", $testsRun, $file, $isEnterprise);
-    $testsFailed += ExecuteTest("Http", "../../TestData/DrawingService/DrawingServiceTest.dump", $testsRun, $file, $isEnterprise);
+    if (!$runApiTestsOnly)
+        $testsFailed += ExecuteTest("Http", "../../TestData/DrawingService/DrawingServiceTest.dump", $testsRun, $file, $isEnterprise);
 
     $testsFailed += ExecuteTest("Api", "../../TestData/FeatureService/FeatureServiceTest.dump", $testsRun, $file, $isEnterprise);
-    $testsFailed += ExecuteTest("Http", "../../TestData/FeatureService/FeatureServiceTest.dump", $testsRun, $file, $isEnterprise);
+    if (!$runApiTestsOnly)
+        $testsFailed += ExecuteTest("Http", "../../TestData/FeatureService/FeatureServiceTest.dump", $testsRun, $file, $isEnterprise);
 
     $testsFailed += ExecuteTest("Api", "../../TestData/SiteService/SiteServiceTest.dump", $testsRun, $file, $isEnterprise);
-    $testsFailed += ExecuteTest("Http", "../../TestData/SiteService/SiteServiceTest.dump", $testsRun, $file, $isEnterprise);
+    if (!$runApiTestsOnly)
+        $testsFailed += ExecuteTest("Http", "../../TestData/SiteService/SiteServiceTest.dump", $testsRun, $file, $isEnterprise);
 
     $testsFailed += ExecuteTest("Api", "../../TestData/MappingService/MappingServiceTest.dump", $testsRun, $file, $isEnterprise);
-    $testsFailed += ExecuteTest("Http", "../../TestData/MappingService/MappingServiceTest.dump", $testsRun, $file, $isEnterprise);
+    if (!$runApiTestsOnly)
+        $testsFailed += ExecuteTest("Http", "../../TestData/MappingService/MappingServiceTest.dump", $testsRun, $file, $isEnterprise);
 
     $testsFailed += ExecuteTest("Api", "../../TestData/ServerAdmin/ServerAdminTest.dump", $testsRun, $file, $isEnterprise);
 
@@ -74,10 +91,11 @@
 
     $testsFailed += ExecuteTest("Api", "../../TestData/WebLayout/WebLayoutTest.dump", $testsRun, $file, $isEnterprise);
 
-    $testsFailed += ExecuteTest("Http", "../../TestData/Wfs/WfsTest.dump", $testsRun, $file, $isEnterprise);
-
-    $testsFailed += ExecuteTest("Http", "../../TestData/Wms/WmsTest.dump", $testsRun, $file, $isEnterprise);
-
+    if (!$runApiTestsOnly)
+    {
+        $testsFailed += ExecuteTest("Http", "../../TestData/Wfs/WfsTest.dump", $testsRun, $file, $isEnterprise);
+        $testsFailed += ExecuteTest("Http", "../../TestData/Wms/WmsTest.dump", $testsRun, $file, $isEnterprise);
+    }
     $testsFailed += ExecuteTest("Api", "../../TestData/Unicode/UnicodeTest.dump", $testsRun, $file, $isEnterprise);
 
     $str = sprintf("\n\nTests failed/run: %d/%d\n", $testsFailed, $testsRun);

Added: trunk/MgDev/UnitTest/run_php_tests.bat
===================================================================
--- trunk/MgDev/UnitTest/run_php_tests.bat	                        (rev 0)
+++ trunk/MgDev/UnitTest/run_php_tests.bat	2012-11-01 15:12:33 UTC (rev 7178)
@@ -0,0 +1,105 @@
+ at echo off
+REM Web Tier Test Suite runner script
+REM
+REM Author: Jackie Ng (jumpinjackie at gmail.com)
+REM
+REM About this script:
+REM
+REM This batch script will automatically start the mgserver.exe with a customizable wait period.
+REM Once the wait period has elapsed the Web Tier test suite will be run via the PHP CLI interpreter.
+REM
+REM This script harnesses everything that's available from the MapGuide source tree (under MgDev) to avoid
+REM minimal external setup. 
+REM
+REM The only setup required is to copy a 32-bit ssleay32.dll and libeay32.dll to Oem\php\Release_TS.
+REM If you have the Installer checked out, you can extract a copy of these files from the
+REM binary 32-bit PHP zip under Installer\Support\Web\x86
+REM
+REM By default, http unit tests are skipped because of this. See remarks.
+REM
+REM Instructions:
+REM 
+REM  1. Build the Oem, Server and WebTier in release mode
+REM  2. Run set_test_params.bat. You can change the values in this file beforehand.
+REM  3. Run run_php_tests.bat
+REM
+REM Remarks:
+REM
+REM  1. mapagent http tests are not run by default as this requires one to be already set up under 
+REM     (http://localhost:<port>/mapguide/mapagent/mapagent.fcgi). If you have already set one up
+REM     you can set API_ONLY=0 in set_test_params.bat
+REM
+REM TODO:
+REM  We really need to automate setting up the mapagent in a web server in a zero-configuration manner. Only then can we 
+REM  remove the API_ONLY variable
+REM
+SET WEB_BIN=%CD%\..\Web\bin\release
+SET SERVER_BIN=%CD%\..\Server\bin\release
+SET OEM_PATH=%CD%\..\Oem
+SET OEM_PHP=%OEM_PATH%\php\Release_TS
+REM MENTOR_DICTIONARY_PATH fallback for MgCoordinateSystem still exists, so use it so we don't have to mess around with webconfig.ini
+SET MENTOR_DICTIONARY_PATH=%OEM_PATH%\CsMap\Dictionaries
+IF "%PLATFORM%" == "64" (
+    SET OEM_PHP=%OEM_PATH%\php\x64\Release_TS
+    SET WEB_BIN=%CD%\..\Web\bin\release64
+    SET SERVER_BIN=%CD%\..\Server\bin\release
+)
+SET OEM_SQLITE=%OEM_PATH%\SQLite\bin\Win%PLATFORM%\release
+SET MAPAGENT=%CD%\..\Web\src\mapagent
+SET OLD_PATH=%PATH%
+SET PATH=%PATH%;%OEM_PHP%;%MAPAGENT%
+
+echo ******************************************************************************
+echo Platform: %PLATFORM%
+echo Auto-start mgserver.exe: %START_MGSERVER%
+echo Time to wait for mgserver.exe: %MGSERVER_WAIT%
+echo Running Web API only: %API_ONLY%
+echo PHP dir: %OEM_PHP%
+echo ******************************************************************************
+
+REM Sanity checks
+IF NOT EXIST "%WEB_BIN%" (
+    echo Could not find required directory %WEB_BIN%
+    goto quit
+)
+IF NOT EXIST "%OEM_SQLITE%" (
+    echo Could not find required directory %OEM_SQLITE%
+    goto quit
+)
+
+REM Copy required php extensions. Copy everything from %WEB_BIN% as PHP MapGuide API requires these
+echo [check]: PHP MapGuide dlls
+IF NOT EXIST "%OEM_PHP%\php_MapGuideApi.dll" copy /Y "%WEB_BIN%\*.dll" "%OEM_PHP%" > NUL
+echo [check]: Checking PHP SQLite dlls
+IF NOT EXIST "%OEM_PHP%\php_SQLitePhpApi.dll" copy /Y "%OEM_SQLITE%\php_SQLitePhpApi.dll" "%OEM_PHP%" > NUL
+
+REM Copy resource files to satisfy new relative path of webconfig.ini
+echo [check]: MapGuide messages (en)
+xcopy /S /Y /I "%MAPAGENT%\Resources" WebTier\php\Resources > NUL
+
+IF "%START_MGSERVER%" == "1" (
+    echo Starting mgserver.exe
+    pushd "%SERVER_BIN%"
+    start mgserver run
+    REM An elegant hack to pause this script allowing mgserver to start up
+    echo Waiting %MGSERVER_WAIT%s for mgserver.exe to start up
+    ping -n %MGSERVER_WAIT% 127.0.0.1 > NUL
+    popd
+)
+
+REM We're ready now. Dive in
+echo Starting unit tests
+pushd WebTier\php
+IF "%API_ONLY%" == "1" (
+    php.exe -n -d display_errors=Off -d extension_dir=%OEM_PHP% -d extension=php_mbstring.dll -d extension=php_curl.dll -d extension=php_MapGuideApi.dll -d extension=php_SQLitePhpApi.dll RunTests.php -- -apionly
+) ELSE (
+    php.exe -n -d display_errors=Off -d extension_dir=%OEM_PHP% -d extension=php_mbstring.dll -d extension=php_curl.dll -d extension=php_MapGuideApi.dll -d extension=php_SQLitePhpApi.dll RunTests.php
+)
+popd
+
+IF "%START_MGSERVER%" == "1" (
+    echo You can now terminate mgserver.exe
+)
+
+:quit
+SET PATH=%OLD_PATH%
\ No newline at end of file

Added: trunk/MgDev/UnitTest/set_test_params.bat
===================================================================
--- trunk/MgDev/UnitTest/set_test_params.bat	                        (rev 0)
+++ trunk/MgDev/UnitTest/set_test_params.bat	2012-11-01 15:12:33 UTC (rev 7178)
@@ -0,0 +1,9 @@
+ at echo off
+REM Bitness of MapGuide we're testing with: 32|64
+SET PLATFORM=32
+REM Auto-start mgserver.exe, set to 0 if testing against a service-installed mgserver.exe: 1|0
+SET START_MGSERVER=1
+REM Time to wait for mgserver.exe to startup in seconds
+SET MGSERVER_WAIT=15
+REM Test only Web Extensions API, set to 0 to also test against the mapagent (must be already setup on a web server): 1|0
+SET API_ONLY=1
\ No newline at end of file



More information about the mapguide-commits mailing list