From 354758edcb0317688e1f9c8c2fad367b9ca00787 Mon Sep 17 00:00:00 2001 From: Rudra Chakraborty Date: Thu, 29 Jun 2017 15:15:31 -0400 Subject: [PATCH 01/14] bugfixes updates to work with PHP7/Fedora 25 --- classes/CCR/Log.php | 4 ++-- configuration/linker.php | 8 ++++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/classes/CCR/Log.php b/classes/CCR/Log.php index c9c40dcc43..efb3856ae4 100644 --- a/classes/CCR/Log.php +++ b/classes/CCR/Log.php @@ -2,6 +2,7 @@ namespace CCR; +require_once 'System.php'; require_once 'Log.php'; use xd_utilities; @@ -90,7 +91,7 @@ public static function factory( $mask = E_WARNING | E_NOTICE | E_USER_WARNING | E_USER_NOTICE | E_STRICT | E_DEPRECATED | E_USER_DEPRECATED; - if ($e !== NULL && ($e['type'] & $mask) == 0) { + if ($e !== null && ($e['type'] & $mask) == 0) { $logger->crit(array( 'message' => $e['message'], 'file' => $e['file'], @@ -278,4 +279,3 @@ protected static function getConfiguration($option) return xd_utilities\getConfiguration('logger', $option); } } - diff --git a/configuration/linker.php b/configuration/linker.php index 68a98fe879..8b326e800c 100644 --- a/configuration/linker.php +++ b/configuration/linker.php @@ -15,6 +15,7 @@ // Register a custom autoloader for XDMoD components. $include_path = ini_get('include_path'); $include_path .= ":" . $baseDir . '/classes'; +$include_path .= ":" . $baseDir . '/classes/CCR'; $include_path .= ":" . $baseDir . '/classes/DB'; $include_path .= ":" . $baseDir . '/classes/DB/TACCStatsIngestors'; $include_path .= ":" . $baseDir . '/classes/DB/TGcDBIngestors'; @@ -33,6 +34,8 @@ ini_alter('include_path', $include_path); +use CCR\Log; + function xdmodAutoload($className) { $pathList = explode(":", ini_get('include_path')); @@ -89,6 +92,7 @@ class HttpCodeMessages 300 => 'Multiple Choices', 301 => 'Moved Permanently', 302 => 'Found', + //302 => 'Found' . $include_path .= ":" . $baseDir . '/classes/DB', 303 => 'See Other', 304 => 'Not Modified', 305 => 'Use Proxy', @@ -136,10 +140,10 @@ class HttpCodeMessages */ function handle_uncaught_exception($exception) { - $logfile = LOG_DIR . "/" . xd_utilities\getConfiguration('general', 'exceptions_logfile'); + $logfile = LOG_DIR . "/" . xd_utilities\getConfiguration('general', 'exceptions_logfile'); $logConf = array('mode' => 0644); - $logger = Log::factory('file', $logfile, 'exception', $logConf); + $logger = XDLog::factory($logfile, $logConf); $logger->log('Exception Code: '.$exception->getCode(), PEAR_LOG_ERR); $logger->log('Message: '.$exception->getMessage(), PEAR_LOG_ERR); From caf764bfd753aacdf40dbb0c16620123aaa16c4c Mon Sep 17 00:00:00 2001 From: Rudra Chakraborty Date: Thu, 13 Jul 2017 11:51:56 -0400 Subject: [PATCH 02/14] removed unused external_libraries pathing from build --- configuration/linker.php | 1 - open_xdmod/modules/xdmod/assets/setup.sh | 6 ------ open_xdmod/modules/xdmod/build.json | 1 - 3 files changed, 8 deletions(-) diff --git a/configuration/linker.php b/configuration/linker.php index 8b326e800c..210133826c 100644 --- a/configuration/linker.php +++ b/configuration/linker.php @@ -29,7 +29,6 @@ $include_path .= ":" . $baseDir . '/classes/User'; $include_path .= ":" . $baseDir . '/classes/ReportTemplates'; $include_path .= ":" . $baseDir . '/classes/AppKernel'; -$include_path .= ":" . $baseDir . '/external_libraries/Zend/library'; $include_path .= ":" . $baseDir . '/libraries/HighRoller_1.0.5'; ini_alter('include_path', $include_path); diff --git a/open_xdmod/modules/xdmod/assets/setup.sh b/open_xdmod/modules/xdmod/assets/setup.sh index 8f6cbc2b3c..29ac6fcb78 100755 --- a/open_xdmod/modules/xdmod/assets/setup.sh +++ b/open_xdmod/modules/xdmod/assets/setup.sh @@ -7,12 +7,6 @@ assets_dir="$( module_dir="$assets_dir/.." xdmod_dir="$module_dir/../../.." -echo Removing existing dependencies -rm -rf $xdmod_dir/external_libraries - -echo Creating directory for external libraries -mkdir $xdmod_dir/external_libraries - echo Installing composer managed dependencies cd $xdmod_dir composer install --no-dev diff --git a/open_xdmod/modules/xdmod/build.json b/open_xdmod/modules/xdmod/build.json index e13b3a7548..46643e6296 100644 --- a/open_xdmod/modules/xdmod/build.json +++ b/open_xdmod/modules/xdmod/build.json @@ -29,7 +29,6 @@ "classes", "db", "etl", - "external_libraries", "html", "libraries", "reporting", From d85e68e0cd955ee80efdce219b5165dc9f2430ec Mon Sep 17 00:00:00 2001 From: Rudra Chakraborty Date: Thu, 13 Jul 2017 11:55:17 -0400 Subject: [PATCH 03/14] reverted one change --- configuration/linker.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configuration/linker.php b/configuration/linker.php index 210133826c..844d85897b 100644 --- a/configuration/linker.php +++ b/configuration/linker.php @@ -142,7 +142,7 @@ function handle_uncaught_exception($exception) $logfile = LOG_DIR . "/" . xd_utilities\getConfiguration('general', 'exceptions_logfile'); $logConf = array('mode' => 0644); - $logger = XDLog::factory($logfile, $logConf); + $logger = Log::factory($logfile, $logConf); $logger->log('Exception Code: '.$exception->getCode(), PEAR_LOG_ERR); $logger->log('Message: '.$exception->getMessage(), PEAR_LOG_ERR); From d18080f426f9876383bce57cc24d35a638023ddf Mon Sep 17 00:00:00 2001 From: Rudra Chakraborty Date: Fri, 14 Jul 2017 10:57:27 -0400 Subject: [PATCH 04/14] updated gitignore --- .gitignore | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.gitignore b/.gitignore index d978ae8ce2..26a7529586 100644 --- a/.gitignore +++ b/.gitignore @@ -103,6 +103,11 @@ crashlytics-build.properties # # gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore +# Visual Studio code +.vscode/** +settings.json +launch.json + ## Build generated build/ DerivedData From 38b24a785a1bd0f5a6fa0e10a4f87d99be96bc60 Mon Sep 17 00:00:00 2001 From: Rudra Chakraborty Date: Mon, 17 Jul 2017 13:55:56 -0400 Subject: [PATCH 05/14] removed unused line in linker --- configuration/linker.php | 1 - 1 file changed, 1 deletion(-) diff --git a/configuration/linker.php b/configuration/linker.php index 844d85897b..bf9da6500b 100644 --- a/configuration/linker.php +++ b/configuration/linker.php @@ -91,7 +91,6 @@ class HttpCodeMessages 300 => 'Multiple Choices', 301 => 'Moved Permanently', 302 => 'Found', - //302 => 'Found' . $include_path .= ":" . $baseDir . '/classes/DB', 303 => 'See Other', 304 => 'Not Modified', 305 => 'Use Proxy', From b1d4bb940011667c0b4067b1928f505e062d567a Mon Sep 17 00:00:00 2001 From: Rudra Chakraborty Date: Mon, 17 Jul 2017 16:08:04 -0400 Subject: [PATCH 06/14] PHP Style Changes --- configuration/linker.php | 149 +++++++++++++++++++-------------------- 1 file changed, 74 insertions(+), 75 deletions(-) diff --git a/configuration/linker.php b/configuration/linker.php index bf9da6500b..33dcba3f08 100644 --- a/configuration/linker.php +++ b/configuration/linker.php @@ -37,25 +37,25 @@ function xdmodAutoload($className) { - $pathList = explode(":", ini_get('include_path')); + $pathList = explode(":", ini_get('include_path')); // if class does not have a namespace - if(strpos($className,'\\') === FALSE) { - $includeFile = $className.".php"; - foreach ($pathList as $path) { - if (is_readable("$path/$includeFile")) { - require_once("$path/$includeFile"); - break; - } - } - } else { - // convert namespace to full file path - $class = dirname(__FILE__) . '/../classes/' + if(strpos($className, '\\') === false) { + $includeFile = $className.".php"; + foreach ($pathList as $path) { + if (is_readable("$path/$includeFile")) { + require_once("$path/$includeFile"); + break; + } + } + } else { + // convert namespace to full file path + $class = dirname(__FILE__) . '/../classes/' . str_replace('\\', '/', $className) . '.php'; - if (is_readable("$class")) { - require_once($class); - } - } + if (is_readable("$class")) { + require_once($class); + } + } } spl_autoload_register('xdmodAutoload'); @@ -67,14 +67,14 @@ function xdmodAutoload($className) $libraries = scandir($baseDir . '/libraries'); foreach ($libraries as $library) { - $file = "$baseDir/libraries/$library"; - if (is_dir($file)) { - continue; - } - require_once($file); + $file = "$baseDir/libraries/$library"; + if (is_dir($file)) { + continue; + } + require_once($file); } -class HttpCodeMessages +class HttpCodeMessages { // HTTP 1.1 messages from: http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html @@ -138,73 +138,73 @@ class HttpCodeMessages */ function handle_uncaught_exception($exception) { - $logfile = LOG_DIR . "/" . xd_utilities\getConfiguration('general', 'exceptions_logfile'); + $logfile = LOG_DIR . "/" . xd_utilities\getConfiguration('general', 'exceptions_logfile'); - $logConf = array('mode' => 0644); - $logger = Log::factory($logfile, $logConf); + $logConf = array('mode' => 0644); + $logger = Log::factory($logfile, $logConf); - $logger->log('Exception Code: '.$exception->getCode(), PEAR_LOG_ERR); - $logger->log('Message: '.$exception->getMessage(), PEAR_LOG_ERR); - $logger->log('Origin: '.$exception->getFile().' (line '.$exception->getLine().')', PEAR_LOG_INFO); + $logger->log('Exception Code: '.$exception->getCode(), PEAR_LOG_ERR); + $logger->log('Message: '.$exception->getMessage(), PEAR_LOG_ERR); + $logger->log('Origin: '.$exception->getFile().' (line '.$exception->getLine().')', PEAR_LOG_INFO); - $stringTrace = (get_class($exception) == 'UniqueException') ? $exception->getVerboseTrace() : $exception->getTraceAsString(); + $stringTrace = (get_class($exception) == 'UniqueException') ? $exception->getVerboseTrace() : $exception->getTraceAsString(); - $logger->log("Trace:\n".$stringTrace."\n-------------------------------------------------------", PEAR_LOG_INFO); + $logger->log("Trace:\n".$stringTrace."\n-------------------------------------------------------", PEAR_LOG_INFO); // If working in a server context, build headers to output. - $httpCode = 500; - $headers = array(); - $isServerContext = isset($_SERVER['SERVER_PROTOCOL']); - if ($isServerContext) { - $uncheckedExceptionHttpCode = null; - if ($exception instanceof XDException) { - $uncheckedExceptionHttpCode = $exception->httpCode; - $headers = $exception->headers; - } else if ($exception instanceof \Symfony\Component\HttpKernel\Exception\HttpExceptionInterface) { - $uncheckedExceptionHttpCode = $exception->getStatusCode(); - $headers = $exception->getHeaders(); - } - - if ($uncheckedExceptionHttpCode !== null) { - if (array_key_exists($uncheckedExceptionHttpCode, HttpCodeMessages::$messages)) { - $httpCode = $uncheckedExceptionHttpCode; - } - } - } - - $exceptionData = xd_response\buildError($exception); - $content = json_encode($exceptionData); - if ($isServerContext) { - $headers['Content-Type'] = 'application/json'; - } - - return array( + $httpCode = 500; + $headers = array(); + $isServerContext = isset($_SERVER['SERVER_PROTOCOL']); + if ($isServerContext) { + $uncheckedExceptionHttpCode = null; + if ($exception instanceof XDException) { + $uncheckedExceptionHttpCode = $exception->httpCode; + $headers = $exception->headers; + } elseif ($exception instanceof \Symfony\Component\HttpKernel\Exception\HttpExceptionInterface) { + $uncheckedExceptionHttpCode = $exception->getStatusCode(); + $headers = $exception->getHeaders(); + } + + if ($uncheckedExceptionHttpCode !== null) { + if (array_key_exists($uncheckedExceptionHttpCode, HttpCodeMessages::$messages)) { + $httpCode = $uncheckedExceptionHttpCode; + } + } + } + + $exceptionData = xd_response\buildError($exception); + $content = json_encode($exceptionData); + if ($isServerContext) { + $headers['Content-Type'] = 'application/json'; + } + + return array( 'content' => $content, 'isServerContext' => $isServerContext, 'headers' => $headers, 'httpCode' => $httpCode, - ); + ); } // handle_uncaught_exception function global_uncaught_exception_handler($exception) { // Perform logging and output building for the exception. - $exceptionOutput = handle_uncaught_exception($exception); + $exceptionOutput = handle_uncaught_exception($exception); // If running in a server context... - if ($exceptionOutput['isServerContext']) { - // Set the exception's headers (if any). - foreach ($exceptionOutput['headers'] as $headerKey => $headerValue) { - header("$headerKey: $headerValue"); - } + if ($exceptionOutput['isServerContext']) { + // Set the exception's headers (if any). + foreach ($exceptionOutput['headers'] as $headerKey => $headerValue) { + header("$headerKey: $headerValue"); + } - // Set the status code header. - $httpCode = $exceptionOutput['httpCode']; - header("{$_SERVER['SERVER_PROTOCOL']} $httpCode ".HttpCodeMessages::$messages[$httpCode]); - } + // Set the status code header. + $httpCode = $exceptionOutput['httpCode']; + header("{$_SERVER['SERVER_PROTOCOL']} $httpCode ".HttpCodeMessages::$messages[$httpCode]); + } // Print the exception's content. - echo $exceptionOutput['content']; + echo $exceptionOutput['content']; } // global_uncaught_exception_handler set_exception_handler('global_uncaught_exception_handler'); @@ -214,14 +214,13 @@ function global_uncaught_exception_handler($exception) $config = Xdmod\Config::factory(); $org = $config['organization']; -define('ORGANIZATION_NAME', $org['name']); +define('ORGANIZATION_NAME', $org['name']); define('ORGANIZATION_NAME_ABBREV', $org['name']); $hierarchy = $config['hierarchy']; -define('HIERARCHY_TOP_LEVEL_LABEL', $hierarchy['top_level_label']); -define('HIERARCHY_TOP_LEVEL_INFO', $hierarchy['top_level_info']); +define('HIERARCHY_TOP_LEVEL_LABEL', $hierarchy['top_level_label']); +define('HIERARCHY_TOP_LEVEL_INFO', $hierarchy['top_level_info']); define('HIERARCHY_MIDDLE_LEVEL_LABEL', $hierarchy['middle_level_label']); -define('HIERARCHY_MIDDLE_LEVEL_INFO', $hierarchy['middle_level_info']); +define('HIERARCHY_MIDDLE_LEVEL_INFO', $hierarchy['middle_level_info']); define('HIERARCHY_BOTTOM_LEVEL_LABEL', $hierarchy['bottom_level_label']); -define('HIERARCHY_BOTTOM_LEVEL_INFO', $hierarchy['bottom_level_info']); - +define('HIERARCHY_BOTTOM_LEVEL_INFO', $hierarchy['bottom_level_info']); From caf7aaa2a831a807904ee5d9d0c7147c0d557b08 Mon Sep 17 00:00:00 2001 From: Rudra Chakraborty Date: Mon, 17 Jul 2017 16:41:11 -0400 Subject: [PATCH 07/14] shippable update to tell us why ci tests barf --- shippable.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/shippable.yml b/shippable.yml index 040546e8d7..c5492d7961 100644 --- a/shippable.yml +++ b/shippable.yml @@ -18,3 +18,5 @@ build: - composer install --no-progress - cp ~/assets/secrets open_xdmod/modules/xdmod/integration_tests/.secrets - ./open_xdmod/modules/xdmod/integration_tests/runtests.sh --log-junit `pwd`/shippable/testresults/results.xml + on_failure: + - cat /var/log/xdmod/* \ No newline at end of file From 8637fd16df5273a1fccdbedb4fe7ee1ff9ab73a7 Mon Sep 17 00:00:00 2001 From: Rudra Chakraborty Date: Tue, 18 Jul 2017 09:44:11 -0400 Subject: [PATCH 08/14] reverted to use PEAR Logger --- classes/CCR/Log.php | 1 - configuration/linker.php | 3 +-- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/classes/CCR/Log.php b/classes/CCR/Log.php index efb3856ae4..b2c0e60241 100644 --- a/classes/CCR/Log.php +++ b/classes/CCR/Log.php @@ -2,7 +2,6 @@ namespace CCR; -require_once 'System.php'; require_once 'Log.php'; use xd_utilities; diff --git a/configuration/linker.php b/configuration/linker.php index 33dcba3f08..4fe7eff426 100644 --- a/configuration/linker.php +++ b/configuration/linker.php @@ -15,7 +15,6 @@ // Register a custom autoloader for XDMoD components. $include_path = ini_get('include_path'); $include_path .= ":" . $baseDir . '/classes'; -$include_path .= ":" . $baseDir . '/classes/CCR'; $include_path .= ":" . $baseDir . '/classes/DB'; $include_path .= ":" . $baseDir . '/classes/DB/TACCStatsIngestors'; $include_path .= ":" . $baseDir . '/classes/DB/TGcDBIngestors'; @@ -141,7 +140,7 @@ function handle_uncaught_exception($exception) $logfile = LOG_DIR . "/" . xd_utilities\getConfiguration('general', 'exceptions_logfile'); $logConf = array('mode' => 0644); - $logger = Log::factory($logfile, $logConf); + $logger = Log::factory('file', $logfile, 'exception', $logConf); $logger->log('Exception Code: '.$exception->getCode(), PEAR_LOG_ERR); $logger->log('Message: '.$exception->getMessage(), PEAR_LOG_ERR); From d2aad5ecfffd8fbe7f07571f4a4c0ee9b7a4cafd Mon Sep 17 00:00:00 2001 From: Rudra Chakraborty Date: Tue, 18 Jul 2017 10:21:37 -0400 Subject: [PATCH 09/14] Made explicit reference to PEAR Logger --- configuration/linker.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/configuration/linker.php b/configuration/linker.php index 4fe7eff426..9fb9f23b02 100644 --- a/configuration/linker.php +++ b/configuration/linker.php @@ -32,8 +32,6 @@ ini_alter('include_path', $include_path); -use CCR\Log; - function xdmodAutoload($className) { $pathList = explode(":", ini_get('include_path')); @@ -140,7 +138,7 @@ function handle_uncaught_exception($exception) $logfile = LOG_DIR . "/" . xd_utilities\getConfiguration('general', 'exceptions_logfile'); $logConf = array('mode' => 0644); - $logger = Log::factory('file', $logfile, 'exception', $logConf); + $logger = \Log::factory('file', $logfile, 'exception', $logConf); $logger->log('Exception Code: '.$exception->getCode(), PEAR_LOG_ERR); $logger->log('Message: '.$exception->getMessage(), PEAR_LOG_ERR); From b35b6476f33a037aefba54b8ff4db296112ce081 Mon Sep 17 00:00:00 2001 From: Rudra Chakraborty Date: Tue, 18 Jul 2017 10:38:20 -0400 Subject: [PATCH 10/14] syntax changes --- shippable.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/shippable.yml b/shippable.yml index c5492d7961..76b2c8a520 100644 --- a/shippable.yml +++ b/shippable.yml @@ -19,4 +19,5 @@ build: - cp ~/assets/secrets open_xdmod/modules/xdmod/integration_tests/.secrets - ./open_xdmod/modules/xdmod/integration_tests/runtests.sh --log-junit `pwd`/shippable/testresults/results.xml on_failure: - - cat /var/log/xdmod/* \ No newline at end of file + - cat /var/log/xdmod/* + \ No newline at end of file From 7633fe154fcf6968ae78783e99859464a4ee077a Mon Sep 17 00:00:00 2001 From: Rudra Chakraborty Date: Tue, 18 Jul 2017 11:10:20 -0400 Subject: [PATCH 11/14] added 7.0/7.1 build checks to Travis --- .travis.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.travis.yml b/.travis.yml index 1fbdef5ced..1c18afc1bf 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,6 +6,8 @@ language: php php: - '5.3.3' - '5.4' + - '7.0' + - '7.1.6' env: global: - NODE_VERSION=6 From 1b9babd487514f64a8aa8be5f106ca67effd51b2 Mon Sep 17 00:00:00 2001 From: Rudra Chakraborty Date: Tue, 18 Jul 2017 13:17:57 -0400 Subject: [PATCH 12/14] removed redundant test --- .../xdmod/tests/lib/Common/IdentityTest.php | 67 ------------------- 1 file changed, 67 deletions(-) delete mode 100644 open_xdmod/modules/xdmod/tests/lib/Common/IdentityTest.php diff --git a/open_xdmod/modules/xdmod/tests/lib/Common/IdentityTest.php b/open_xdmod/modules/xdmod/tests/lib/Common/IdentityTest.php deleted file mode 100644 index 88d3f156f9..0000000000 --- a/open_xdmod/modules/xdmod/tests/lib/Common/IdentityTest.php +++ /dev/null @@ -1,67 +0,0 @@ -_identity = new \Common\Identity('identity_name'); - $this->_identity1 = new \Common\Identity(''); - set_error_handler(array($this, 'errorHandler')); - } - - public function errorHandler($errno, $errstr, $errfile, $errline) - { - throw new \InvalidArgumentException( - sprintf( - 'Missing argument. %s %s %s %s', - $errno, - $errstr, - $errfile, - $errline - ) - ); - } - - public function tearDown() { - restore_error_handler(); - $this->_identity = null; - $this->_identity1 = null; - } - - /** - * @expectedException InvalidArgumentException - */ - public function testNoDefaultParameterToConstructor() - { - $identity = new \Common\Identity(); // this construction should fail since the name parameter is not specified - } - - public function testGetName() - { - $this->assertEquals($this->_identity->getName(), 'identity_name', "This should pass" ); - $this->assertEquals($this->_identity1->getName(), '', "This should pass" ); - } - - public function testSetName() - { - $this->_identity1->setName('mock_name'); - $this->assertEquals($this->_identity1->getName(), 'mock_name', "This should pass" ); - } - - public function testToString() - { - $this->assertEquals($this->_identity->__toString(), 'identity_name', "This should pass" ); - } -} From 7d2524bb9ee4af3d1dcd0347d81dc6da9ed32827 Mon Sep 17 00:00:00 2001 From: Rudra Chakraborty Date: Tue, 18 Jul 2017 15:38:45 -0400 Subject: [PATCH 13/14] reverted delete, made redundant constructor test only run on PHP 7.1 --- .../xdmod/tests/lib/Common/IdentityTest.php | 68 +++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100644 open_xdmod/modules/xdmod/tests/lib/Common/IdentityTest.php diff --git a/open_xdmod/modules/xdmod/tests/lib/Common/IdentityTest.php b/open_xdmod/modules/xdmod/tests/lib/Common/IdentityTest.php new file mode 100644 index 0000000000..35909f1535 --- /dev/null +++ b/open_xdmod/modules/xdmod/tests/lib/Common/IdentityTest.php @@ -0,0 +1,68 @@ +_identity = new \Common\Identity('identity_name'); + $this->_identity1 = new \Common\Identity(''); + set_error_handler(array($this, 'errorHandler')); + } + + public function errorHandler($errno, $errstr, $errfile, $errline) + { + throw new \BadMethodCallException( + sprintf( + 'Missing argument. %s %s %s %s', + $errno, + $errstr, + $errfile, + $errline + ) + ); + } + + public function tearDown() { + restore_error_handler(); + $this->_identity = null; + $this->_identity1 = null; + } + + /** + * @expectedException ArgumentCountError + * @requires PHP 7.1 + */ + public function testNoDefaultParameterToConstructor() + { + $identity = new \Common\Identity(); // this construction should fail since the name parameter is not specified + } + + public function testGetName() + { + $this->assertEquals($this->_identity->getName(), 'identity_name', "This should pass" ); + $this->assertEquals($this->_identity1->getName(), '', "This should pass" ); + } + + public function testSetName() + { + $this->_identity1->setName('mock_name'); + $this->assertEquals($this->_identity1->getName(), 'mock_name', "This should pass" ); + } + + public function testToString() + { + $this->assertEquals($this->_identity->__toString(), 'identity_name', "This should pass" ); + } +} From a81518eb28962f6481159bf886526c37eef2b245 Mon Sep 17 00:00:00 2001 From: Rudra Chakraborty Date: Wed, 19 Jul 2017 09:23:26 -0400 Subject: [PATCH 14/14] meaningless commit to figure out why PHP 5.3.3 is broken on Travis --- open_xdmod/modules/xdmod/tests/lib/Common/IdentityTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/open_xdmod/modules/xdmod/tests/lib/Common/IdentityTest.php b/open_xdmod/modules/xdmod/tests/lib/Common/IdentityTest.php index 35909f1535..f1a89b7880 100644 --- a/open_xdmod/modules/xdmod/tests/lib/Common/IdentityTest.php +++ b/open_xdmod/modules/xdmod/tests/lib/Common/IdentityTest.php @@ -23,7 +23,7 @@ public function setUp() public function errorHandler($errno, $errstr, $errfile, $errline) { - throw new \BadMethodCallException( + throw new \InvalidArgumentException( sprintf( 'Missing argument. %s %s %s %s', $errno,