@@ -16,15 +16,15 @@ discard block |
||
| 16 | 16 | * along with php-pens. If not, see <http://www.gnu.org/licenses/>. |
| 17 | 17 | */ |
| 18 | 18 | |
| 19 | - /** |
|
| 20 | - * PENSServer |
|
| 21 | - * |
|
| 22 | - * Provides the PENSServer class |
|
| 23 | - * |
|
| 24 | - * @package PENS |
|
| 25 | - * @author Guillaume Viguier-Just <[email protected]> |
|
| 26 | - * @licence http://www.gnu.org/licenses/gpl.txt |
|
| 27 | - */ |
|
| 19 | + /** |
|
| 20 | + * PENSServer |
|
| 21 | + * |
|
| 22 | + * Provides the PENSServer class |
|
| 23 | + * |
|
| 24 | + * @package PENS |
|
| 25 | + * @author Guillaume Viguier-Just <[email protected]> |
|
| 26 | + * @licence http://www.gnu.org/licenses/gpl.txt |
|
| 27 | + */ |
|
| 28 | 28 | |
| 29 | 29 | require_once __DIR__ . '/pens_controller.php'; |
| 30 | 30 | require_once __DIR__ . '/pens_package_handler.php'; |
@@ -42,272 +42,272 @@ discard block |
||
| 42 | 42 | */ |
| 43 | 43 | class PENSServer extends PENSController { |
| 44 | 44 | |
| 45 | - /** |
|
| 46 | - * Instance of the PENSServer |
|
| 47 | - * @var PENSServer |
|
| 48 | - */ |
|
| 49 | - private static $_instance; |
|
| 45 | + /** |
|
| 46 | + * Instance of the PENSServer |
|
| 47 | + * @var PENSServer |
|
| 48 | + */ |
|
| 49 | + private static $_instance; |
|
| 50 | 50 | |
| 51 | - /** |
|
| 52 | - * Package handler |
|
| 53 | - * @var PENSPackageHandler |
|
| 54 | - */ |
|
| 55 | - protected $_package_handler = null; |
|
| 51 | + /** |
|
| 52 | + * Package handler |
|
| 53 | + * @var PENSPackageHandler |
|
| 54 | + */ |
|
| 55 | + protected $_package_handler = null; |
|
| 56 | 56 | |
| 57 | - /** |
|
| 58 | - * Private constructor |
|
| 59 | - */ |
|
| 60 | - private function __construct() { |
|
| 61 | - } |
|
| 57 | + /** |
|
| 58 | + * Private constructor |
|
| 59 | + */ |
|
| 60 | + private function __construct() { |
|
| 61 | + } |
|
| 62 | 62 | |
| 63 | - /** |
|
| 64 | - * Singleton method |
|
| 65 | - */ |
|
| 66 | - public static function singleton() { |
|
| 67 | - if(!isset(self::$_instance)) { |
|
| 68 | - $c = __CLASS__; |
|
| 69 | - self::$_instance = new $c; |
|
| 70 | - } |
|
| 71 | - return self::$_instance; |
|
| 72 | - } |
|
| 63 | + /** |
|
| 64 | + * Singleton method |
|
| 65 | + */ |
|
| 66 | + public static function singleton() { |
|
| 67 | + if(!isset(self::$_instance)) { |
|
| 68 | + $c = __CLASS__; |
|
| 69 | + self::$_instance = new $c; |
|
| 70 | + } |
|
| 71 | + return self::$_instance; |
|
| 72 | + } |
|
| 73 | 73 | |
| 74 | - /** |
|
| 75 | - * Prevent users to clone the instance |
|
| 76 | - */ |
|
| 77 | - public function __clone() { |
|
| 78 | - trigger_error('Clone is not allowed', E_USER_ERROR); |
|
| 79 | - } |
|
| 74 | + /** |
|
| 75 | + * Prevent users to clone the instance |
|
| 76 | + */ |
|
| 77 | + public function __clone() { |
|
| 78 | + trigger_error('Clone is not allowed', E_USER_ERROR); |
|
| 79 | + } |
|
| 80 | 80 | |
| 81 | - public function getPackageHandler() { |
|
| 82 | - return $this->_package_handler; |
|
| 83 | - } |
|
| 81 | + public function getPackageHandler() { |
|
| 82 | + return $this->_package_handler; |
|
| 83 | + } |
|
| 84 | 84 | |
| 85 | - /** |
|
| 86 | - * Sets the package handler. Does nothing if the argument is not an instance of PENSPackageHandler |
|
| 87 | - * |
|
| 88 | - * @param PENSPackageHandler Package handler |
|
| 89 | - */ |
|
| 90 | - public function setPackageHandler($package_handler) { |
|
| 91 | - if($package_handler instanceof PENSPackageHandler) { |
|
| 92 | - $this->_package_handler = $package_handler; |
|
| 93 | - } |
|
| 94 | - } |
|
| 85 | + /** |
|
| 86 | + * Sets the package handler. Does nothing if the argument is not an instance of PENSPackageHandler |
|
| 87 | + * |
|
| 88 | + * @param PENSPackageHandler Package handler |
|
| 89 | + */ |
|
| 90 | + public function setPackageHandler($package_handler) { |
|
| 91 | + if($package_handler instanceof PENSPackageHandler) { |
|
| 92 | + $this->_package_handler = $package_handler; |
|
| 93 | + } |
|
| 94 | + } |
|
| 95 | 95 | |
| 96 | - /** |
|
| 97 | - * Receives a collect request and treats it |
|
| 98 | - */ |
|
| 99 | - public function receiveCollect() { |
|
| 100 | - $request = null; |
|
| 101 | - try { |
|
| 102 | - // First, try to parse the request |
|
| 103 | - $request = $this->parseRequest(); |
|
| 104 | - if($request->getCommand() == "collect") { |
|
| 105 | - if(isset($_REQUEST['process'])) { |
|
| 106 | - // Collect the package and process it |
|
| 107 | - $receipt = null; |
|
| 108 | - $path_to_package = null; |
|
| 109 | - try { |
|
| 110 | - // Collect the package |
|
| 111 | - $path_to_package = $this->collectPackage($request); |
|
| 112 | - $receipt = new PENSResponse(0, "package successfully collected"); |
|
| 113 | - } catch(PENSException $e) { |
|
| 114 | - $receipt = new PENSResponse($e); |
|
| 115 | - } |
|
| 116 | - // Send receipt |
|
| 117 | - $response = $this->sendReceipt($request, $receipt); |
|
| 118 | - if(!is_null($response) && !is_null($path_to_package)) { |
|
| 119 | - if($response->getError() === 0) { |
|
| 120 | - // Process package |
|
| 121 | - $this->processPackage($request, $path_to_package); |
|
| 122 | - } |
|
| 123 | - unlink($path_to_package); |
|
| 124 | - } |
|
| 125 | - } else { |
|
| 126 | - // Then, send a success response to the client |
|
| 127 | - $this->sendResponse(new PENSResponse(0, "collect command received and understood")); |
|
| 128 | - // Send a request to process the package: fake multithreading |
|
| 129 | - $params = $_REQUEST; |
|
| 130 | - $params['process'] = 1; |
|
| 131 | - $scheme = "http"; |
|
| 132 | - if(!empty($_SERVER['HTTPS'])) { |
|
| 133 | - $scheme = "https"; |
|
| 134 | - } |
|
| 135 | - $ch = curl_init(); |
|
| 136 | - curl_setopt($ch, CURLOPT_URL, $scheme."://".$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']); |
|
| 137 | - curl_setopt($ch, CURLOPT_POSTFIELDS, $params); |
|
| 138 | - curl_setopt($ch, CURLOPT_TIMEOUT, 1); |
|
| 139 | - curl_exec($ch); |
|
| 140 | - curl_close($ch); |
|
| 141 | - } |
|
| 142 | - } |
|
| 96 | + /** |
|
| 97 | + * Receives a collect request and treats it |
|
| 98 | + */ |
|
| 99 | + public function receiveCollect() { |
|
| 100 | + $request = null; |
|
| 101 | + try { |
|
| 102 | + // First, try to parse the request |
|
| 103 | + $request = $this->parseRequest(); |
|
| 104 | + if($request->getCommand() == "collect") { |
|
| 105 | + if(isset($_REQUEST['process'])) { |
|
| 106 | + // Collect the package and process it |
|
| 107 | + $receipt = null; |
|
| 108 | + $path_to_package = null; |
|
| 109 | + try { |
|
| 110 | + // Collect the package |
|
| 111 | + $path_to_package = $this->collectPackage($request); |
|
| 112 | + $receipt = new PENSResponse(0, "package successfully collected"); |
|
| 113 | + } catch(PENSException $e) { |
|
| 114 | + $receipt = new PENSResponse($e); |
|
| 115 | + } |
|
| 116 | + // Send receipt |
|
| 117 | + $response = $this->sendReceipt($request, $receipt); |
|
| 118 | + if(!is_null($response) && !is_null($path_to_package)) { |
|
| 119 | + if($response->getError() === 0) { |
|
| 120 | + // Process package |
|
| 121 | + $this->processPackage($request, $path_to_package); |
|
| 122 | + } |
|
| 123 | + unlink($path_to_package); |
|
| 124 | + } |
|
| 125 | + } else { |
|
| 126 | + // Then, send a success response to the client |
|
| 127 | + $this->sendResponse(new PENSResponse(0, "collect command received and understood")); |
|
| 128 | + // Send a request to process the package: fake multithreading |
|
| 129 | + $params = $_REQUEST; |
|
| 130 | + $params['process'] = 1; |
|
| 131 | + $scheme = "http"; |
|
| 132 | + if(!empty($_SERVER['HTTPS'])) { |
|
| 133 | + $scheme = "https"; |
|
| 134 | + } |
|
| 135 | + $ch = curl_init(); |
|
| 136 | + curl_setopt($ch, CURLOPT_URL, $scheme."://".$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']); |
|
| 137 | + curl_setopt($ch, CURLOPT_POSTFIELDS, $params); |
|
| 138 | + curl_setopt($ch, CURLOPT_TIMEOUT, 1); |
|
| 139 | + curl_exec($ch); |
|
| 140 | + curl_close($ch); |
|
| 141 | + } |
|
| 142 | + } |
|
| 143 | 143 | |
| 144 | - } catch(PENSException $e) { |
|
| 145 | - // If we could not parse the request, send the error back to the client |
|
| 146 | - $this->sendResponse(new PENSResponse($e)); |
|
| 147 | - } |
|
| 148 | - } |
|
| 144 | + } catch(PENSException $e) { |
|
| 145 | + // If we could not parse the request, send the error back to the client |
|
| 146 | + $this->sendResponse(new PENSResponse($e)); |
|
| 147 | + } |
|
| 148 | + } |
|
| 149 | 149 | |
| 150 | - /** |
|
| 151 | - * Collects the package onto the local server |
|
| 152 | - * |
|
| 153 | - * @param PENSRequest request |
|
| 154 | - * @return string Path to the package on the hard drive |
|
| 155 | - * @throws PENSException if an exception occured |
|
| 156 | - */ |
|
| 157 | - protected function collectPackage($request) { |
|
| 158 | - $supported_package_types = $this->_package_handler->getSupportedPackageTypes(); |
|
| 159 | - if(!in_array($request->getPackageType(), $supported_package_types)) { |
|
| 160 | - throw new PENSException(1430); |
|
| 161 | - } |
|
| 162 | - $supported_package_formats = $this->_package_handler->getSupportedPackageFormats(); |
|
| 163 | - if(!in_array($request->getPackageFormat(), $supported_package_formats)) { |
|
| 164 | - throw new PENSException(1431); |
|
| 165 | - } |
|
| 166 | - if(!$this->isExpiryDateValid($request->getPackageUrlExpiry())) { |
|
| 167 | - throw new PENSException(1322); |
|
| 168 | - } |
|
| 150 | + /** |
|
| 151 | + * Collects the package onto the local server |
|
| 152 | + * |
|
| 153 | + * @param PENSRequest request |
|
| 154 | + * @return string Path to the package on the hard drive |
|
| 155 | + * @throws PENSException if an exception occured |
|
| 156 | + */ |
|
| 157 | + protected function collectPackage($request) { |
|
| 158 | + $supported_package_types = $this->_package_handler->getSupportedPackageTypes(); |
|
| 159 | + if(!in_array($request->getPackageType(), $supported_package_types)) { |
|
| 160 | + throw new PENSException(1430); |
|
| 161 | + } |
|
| 162 | + $supported_package_formats = $this->_package_handler->getSupportedPackageFormats(); |
|
| 163 | + if(!in_array($request->getPackageFormat(), $supported_package_formats)) { |
|
| 164 | + throw new PENSException(1431); |
|
| 165 | + } |
|
| 166 | + if(!$this->isExpiryDateValid($request->getPackageUrlExpiry())) { |
|
| 167 | + throw new PENSException(1322); |
|
| 168 | + } |
|
| 169 | 169 | |
| 170 | - // Try to download the package in the temporary directory |
|
| 171 | - $tmp = null; |
|
| 172 | - if(function_exists("sys_get_temp_dir")) { |
|
| 173 | - $tmp = sys_get_temp_dir(); |
|
| 174 | - } else { |
|
| 175 | - $tmp = "/tmp"; |
|
| 176 | - } |
|
| 177 | - $path_to_file = $tmp."/".$request->getFilename(); |
|
| 178 | - $fp = fopen($path_to_file, 'w'); |
|
| 179 | - $ch = curl_init(); |
|
| 180 | - curl_setopt($ch, CURLOPT_URL, $request->getPackageUrl()); |
|
| 181 | - curl_setopt($ch, CURLOPT_HEADER, false); |
|
| 182 | - curl_setopt($ch, CURLOPT_FILE, $fp); |
|
| 183 | - if(!is_null($request->getPackageUrlUserId())) { |
|
| 184 | - curl_setopt($ch, CURLOPT_USERPWD, $request->getPackageUrlUserId().":".$request->getPackageUrlPassword()); |
|
| 185 | - } |
|
| 186 | - if(curl_exec($ch) === false) { |
|
| 187 | - $errno = curl_errno($ch); |
|
| 188 | - curl_close($ch); |
|
| 189 | - // Error occured. Throw an exception |
|
| 190 | - switch($errno) { |
|
| 191 | - case CURLE_UNSUPPORTED_PROTOCOL: |
|
| 192 | - throw new PENSException(1301); |
|
| 193 | - break; |
|
| 194 | - case CURLE_URL_MALFORMAT: |
|
| 195 | - case CURLE_COULDNT_RESOLVE_PROXY: |
|
| 196 | - case CURLE_COULDNT_RESOLVE_HOST: |
|
| 197 | - case CURLE_COULDNT_CONNECT: |
|
| 198 | - case CURLE_OPERATION_TIMEOUT: |
|
| 199 | - case CURLE_REMOTE_FILE_NOT_FOUND: |
|
| 200 | - throw new PENSException(1310); |
|
| 201 | - break; |
|
| 202 | - case CURLE_REMOTE_ACCESS_DENIED: |
|
| 203 | - throw new PENSException(1312); |
|
| 204 | - break; |
|
| 205 | - default: |
|
| 206 | - throw new PENSException(1301); |
|
| 207 | - break; |
|
| 208 | - } |
|
| 209 | - return null; |
|
| 170 | + // Try to download the package in the temporary directory |
|
| 171 | + $tmp = null; |
|
| 172 | + if(function_exists("sys_get_temp_dir")) { |
|
| 173 | + $tmp = sys_get_temp_dir(); |
|
| 174 | + } else { |
|
| 175 | + $tmp = "/tmp"; |
|
| 176 | + } |
|
| 177 | + $path_to_file = $tmp."/".$request->getFilename(); |
|
| 178 | + $fp = fopen($path_to_file, 'w'); |
|
| 179 | + $ch = curl_init(); |
|
| 180 | + curl_setopt($ch, CURLOPT_URL, $request->getPackageUrl()); |
|
| 181 | + curl_setopt($ch, CURLOPT_HEADER, false); |
|
| 182 | + curl_setopt($ch, CURLOPT_FILE, $fp); |
|
| 183 | + if(!is_null($request->getPackageUrlUserId())) { |
|
| 184 | + curl_setopt($ch, CURLOPT_USERPWD, $request->getPackageUrlUserId().":".$request->getPackageUrlPassword()); |
|
| 185 | + } |
|
| 186 | + if(curl_exec($ch) === false) { |
|
| 187 | + $errno = curl_errno($ch); |
|
| 188 | + curl_close($ch); |
|
| 189 | + // Error occured. Throw an exception |
|
| 190 | + switch($errno) { |
|
| 191 | + case CURLE_UNSUPPORTED_PROTOCOL: |
|
| 192 | + throw new PENSException(1301); |
|
| 193 | + break; |
|
| 194 | + case CURLE_URL_MALFORMAT: |
|
| 195 | + case CURLE_COULDNT_RESOLVE_PROXY: |
|
| 196 | + case CURLE_COULDNT_RESOLVE_HOST: |
|
| 197 | + case CURLE_COULDNT_CONNECT: |
|
| 198 | + case CURLE_OPERATION_TIMEOUT: |
|
| 199 | + case CURLE_REMOTE_FILE_NOT_FOUND: |
|
| 200 | + throw new PENSException(1310); |
|
| 201 | + break; |
|
| 202 | + case CURLE_REMOTE_ACCESS_DENIED: |
|
| 203 | + throw new PENSException(1312); |
|
| 204 | + break; |
|
| 205 | + default: |
|
| 206 | + throw new PENSException(1301); |
|
| 207 | + break; |
|
| 208 | + } |
|
| 209 | + return null; |
|
| 210 | 210 | |
| 211 | - } else { |
|
| 212 | - curl_close($ch); |
|
| 213 | - return $path_to_file; |
|
| 214 | - } |
|
| 215 | - } |
|
| 211 | + } else { |
|
| 212 | + curl_close($ch); |
|
| 213 | + return $path_to_file; |
|
| 214 | + } |
|
| 215 | + } |
|
| 216 | 216 | |
| 217 | - /** |
|
| 218 | - * Verifies that the package url is not expired |
|
| 219 | - * |
|
| 220 | - * @param DateTime DateTime object to verify against current time |
|
| 221 | - */ |
|
| 222 | - protected function isExpiryDateValid($expiry) { |
|
| 223 | - date_default_timezone_set('UTC'); |
|
| 224 | - $current_time = time(); |
|
| 225 | - $expiry_time = strtotime($expiry->format(DateTime::ISO8601)); |
|
| 226 | - if($current_time > $expiry_time) { |
|
| 227 | - return false; |
|
| 228 | - } else { |
|
| 229 | - return true; |
|
| 230 | - } |
|
| 231 | - } |
|
| 217 | + /** |
|
| 218 | + * Verifies that the package url is not expired |
|
| 219 | + * |
|
| 220 | + * @param DateTime DateTime object to verify against current time |
|
| 221 | + */ |
|
| 222 | + protected function isExpiryDateValid($expiry) { |
|
| 223 | + date_default_timezone_set('UTC'); |
|
| 224 | + $current_time = time(); |
|
| 225 | + $expiry_time = strtotime($expiry->format(DateTime::ISO8601)); |
|
| 226 | + if($current_time > $expiry_time) { |
|
| 227 | + return false; |
|
| 228 | + } else { |
|
| 229 | + return true; |
|
| 230 | + } |
|
| 231 | + } |
|
| 232 | 232 | |
| 233 | - /** |
|
| 234 | - * Sends an alert or a receipt. Called by sendReceipt and sendAlert |
|
| 235 | - * |
|
| 236 | - * @param PENSRequest Original collect request |
|
| 237 | - * @param PENSResponse Reponse to send in the receipt or the alert |
|
| 238 | - * @param string Mode (alert | receipt) |
|
| 239 | - * @return PENSResponse Response |
|
| 240 | - */ |
|
| 241 | - protected function sendAlertOrReceipt($request, $response, $mode) { |
|
| 242 | - if($mode == "alert") { |
|
| 243 | - $url = $request->getAlerts(); |
|
| 244 | - } else { |
|
| 245 | - $url = $request->getReceipt(); |
|
| 246 | - } |
|
| 247 | - if(!empty($url)) { |
|
| 248 | - $url_components = parse_url($url); |
|
| 249 | - $scheme = $url_components["scheme"]; |
|
| 250 | - if($scheme == "mailto") { |
|
| 251 | - $to = $url_components["path"]; |
|
| 252 | - if($mode == "alert") { |
|
| 253 | - $subject = "PENS Alert for ".$request->getPackageId(); |
|
| 254 | - } else { |
|
| 255 | - $subject = "PENS Receipt for ".$request->getPackageId(); |
|
| 256 | - } |
|
| 257 | - $message = $response->__toString(); |
|
| 258 | - mail($to, $subject, $message); |
|
| 259 | - return new PENSResponse(0, ""); |
|
| 260 | - } else if($scheme == "http" || $scheme == "https") { |
|
| 261 | - if($mode == "alert") { |
|
| 262 | - $params = array_merge($request->getSendAlertArray(), $response->getArray()); |
|
| 263 | - } else { |
|
| 264 | - $params = array_merge($request->getSendReceiptArray(), $response->getArray()); |
|
| 265 | - } |
|
| 266 | - $ch = curl_init($url); |
|
| 267 | - curl_setopt($ch, CURLOPT_POST, true); |
|
| 268 | - curl_setopt($ch, CURLOPT_POSTFIELDS, $params); |
|
| 269 | - curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); |
|
| 270 | - $data = curl_exec($ch); |
|
| 271 | - curl_close($ch); |
|
| 272 | - if($data === false) { |
|
| 273 | - return null; |
|
| 274 | - } else { |
|
| 275 | - return new PENSResponse($data); |
|
| 276 | - } |
|
| 277 | - } |
|
| 278 | - } |
|
| 279 | - } |
|
| 233 | + /** |
|
| 234 | + * Sends an alert or a receipt. Called by sendReceipt and sendAlert |
|
| 235 | + * |
|
| 236 | + * @param PENSRequest Original collect request |
|
| 237 | + * @param PENSResponse Reponse to send in the receipt or the alert |
|
| 238 | + * @param string Mode (alert | receipt) |
|
| 239 | + * @return PENSResponse Response |
|
| 240 | + */ |
|
| 241 | + protected function sendAlertOrReceipt($request, $response, $mode) { |
|
| 242 | + if($mode == "alert") { |
|
| 243 | + $url = $request->getAlerts(); |
|
| 244 | + } else { |
|
| 245 | + $url = $request->getReceipt(); |
|
| 246 | + } |
|
| 247 | + if(!empty($url)) { |
|
| 248 | + $url_components = parse_url($url); |
|
| 249 | + $scheme = $url_components["scheme"]; |
|
| 250 | + if($scheme == "mailto") { |
|
| 251 | + $to = $url_components["path"]; |
|
| 252 | + if($mode == "alert") { |
|
| 253 | + $subject = "PENS Alert for ".$request->getPackageId(); |
|
| 254 | + } else { |
|
| 255 | + $subject = "PENS Receipt for ".$request->getPackageId(); |
|
| 256 | + } |
|
| 257 | + $message = $response->__toString(); |
|
| 258 | + mail($to, $subject, $message); |
|
| 259 | + return new PENSResponse(0, ""); |
|
| 260 | + } else if($scheme == "http" || $scheme == "https") { |
|
| 261 | + if($mode == "alert") { |
|
| 262 | + $params = array_merge($request->getSendAlertArray(), $response->getArray()); |
|
| 263 | + } else { |
|
| 264 | + $params = array_merge($request->getSendReceiptArray(), $response->getArray()); |
|
| 265 | + } |
|
| 266 | + $ch = curl_init($url); |
|
| 267 | + curl_setopt($ch, CURLOPT_POST, true); |
|
| 268 | + curl_setopt($ch, CURLOPT_POSTFIELDS, $params); |
|
| 269 | + curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); |
|
| 270 | + $data = curl_exec($ch); |
|
| 271 | + curl_close($ch); |
|
| 272 | + if($data === false) { |
|
| 273 | + return null; |
|
| 274 | + } else { |
|
| 275 | + return new PENSResponse($data); |
|
| 276 | + } |
|
| 277 | + } |
|
| 278 | + } |
|
| 279 | + } |
|
| 280 | 280 | |
| 281 | - /** |
|
| 282 | - * Sends a receipt. Returns a PENSResponse in case of success, null if a problem occured |
|
| 283 | - * |
|
| 284 | - * @param PENSRequest Original collect request |
|
| 285 | - * @param PENSResponse Response to send in the receipt |
|
| 286 | - * @return PENSResponse Response |
|
| 287 | - */ |
|
| 288 | - protected function sendReceipt($request, $receipt) { |
|
| 289 | - return $this->sendAlertOrReceipt($request, $receipt, "receipt"); |
|
| 290 | - } |
|
| 281 | + /** |
|
| 282 | + * Sends a receipt. Returns a PENSResponse in case of success, null if a problem occured |
|
| 283 | + * |
|
| 284 | + * @param PENSRequest Original collect request |
|
| 285 | + * @param PENSResponse Response to send in the receipt |
|
| 286 | + * @return PENSResponse Response |
|
| 287 | + */ |
|
| 288 | + protected function sendReceipt($request, $receipt) { |
|
| 289 | + return $this->sendAlertOrReceipt($request, $receipt, "receipt"); |
|
| 290 | + } |
|
| 291 | 291 | |
| 292 | - /** |
|
| 293 | - * Processes the package using the handler provided |
|
| 294 | - * |
|
| 295 | - * @param PENSRequest Original collect request |
|
| 296 | - * @param string Path to the package on the hard drive |
|
| 297 | - */ |
|
| 298 | - protected function processPackage($request, $path_to_package) { |
|
| 299 | - return $this->_package_handler->processPackage($request, $path_to_package); |
|
| 300 | - } |
|
| 292 | + /** |
|
| 293 | + * Processes the package using the handler provided |
|
| 294 | + * |
|
| 295 | + * @param PENSRequest Original collect request |
|
| 296 | + * @param string Path to the package on the hard drive |
|
| 297 | + */ |
|
| 298 | + protected function processPackage($request, $path_to_package) { |
|
| 299 | + return $this->_package_handler->processPackage($request, $path_to_package); |
|
| 300 | + } |
|
| 301 | 301 | |
| 302 | - /** |
|
| 303 | - * Sends an alert to the client. Returns a PENSResponse in case of success, null if a problem occured |
|
| 304 | - * |
|
| 305 | - * @param PENSRequest Original collect request |
|
| 306 | - * @param PENSResponse Response to send in the alert |
|
| 307 | - * @return PENSResponse Response |
|
| 308 | - */ |
|
| 309 | - public function sendAlert($request, $alert) { |
|
| 310 | - return $this->sendAlertOrReceipt($request, $alert, "alert"); |
|
| 311 | - } |
|
| 302 | + /** |
|
| 303 | + * Sends an alert to the client. Returns a PENSResponse in case of success, null if a problem occured |
|
| 304 | + * |
|
| 305 | + * @param PENSRequest Original collect request |
|
| 306 | + * @param PENSResponse Response to send in the alert |
|
| 307 | + * @return PENSResponse Response |
|
| 308 | + */ |
|
| 309 | + public function sendAlert($request, $alert) { |
|
| 310 | + return $this->sendAlertOrReceipt($request, $alert, "alert"); |
|
| 311 | + } |
|
| 312 | 312 | |
| 313 | 313 | } |
@@ -43,26 +43,26 @@ |
||
| 43 | 43 | */ |
| 44 | 44 | class PENSRequestFactory { |
| 45 | 45 | |
| 46 | - /** |
|
| 47 | - * Factory method |
|
| 48 | - * |
|
| 49 | - * Creates the right PENSRequest object, based on the command inside the arguments |
|
| 50 | - * |
|
| 51 | - * @param array Associative array of arguments |
|
| 52 | - * @return mixed PENSRequestAlert or PENSRequestCollect or PENSRequestReceipt |
|
| 53 | - * |
|
| 54 | - * @throws PENSException with code 2002 if command is invalid |
|
| 55 | - */ |
|
| 56 | - public static function createPENSRequest($arguments) { |
|
| 57 | - $command = $arguments["command"]; |
|
| 58 | - if($command == "alert") { |
|
| 59 | - return new PENSRequestAlert($arguments); |
|
| 60 | - } else if($command == "collect") { |
|
| 61 | - return new PENSRequestCollect($arguments); |
|
| 62 | - } else if($command == "receipt") { |
|
| 63 | - return new PENSRequestReceipt($arguments); |
|
| 64 | - } else { |
|
| 65 | - throw new PENSException(2002); |
|
| 66 | - } |
|
| 67 | - } |
|
| 46 | + /** |
|
| 47 | + * Factory method |
|
| 48 | + * |
|
| 49 | + * Creates the right PENSRequest object, based on the command inside the arguments |
|
| 50 | + * |
|
| 51 | + * @param array Associative array of arguments |
|
| 52 | + * @return mixed PENSRequestAlert or PENSRequestCollect or PENSRequestReceipt |
|
| 53 | + * |
|
| 54 | + * @throws PENSException with code 2002 if command is invalid |
|
| 55 | + */ |
|
| 56 | + public static function createPENSRequest($arguments) { |
|
| 57 | + $command = $arguments["command"]; |
|
| 58 | + if($command == "alert") { |
|
| 59 | + return new PENSRequestAlert($arguments); |
|
| 60 | + } else if($command == "collect") { |
|
| 61 | + return new PENSRequestCollect($arguments); |
|
| 62 | + } else if($command == "receipt") { |
|
| 63 | + return new PENSRequestReceipt($arguments); |
|
| 64 | + } else { |
|
| 65 | + throw new PENSException(2002); |
|
| 66 | + } |
|
| 67 | + } |
|
| 68 | 68 | } |
@@ -39,137 +39,137 @@ |
||
| 39 | 39 | * @author Guillaume Viguier-Just <[email protected]> |
| 40 | 40 | * @licence http://www.gnu.org/licenses/gpl.txt |
| 41 | 41 | */ |
| 42 | - class PENSResponse extends PENSMessage { |
|
| 43 | - /** |
|
| 44 | - * Error code |
|
| 45 | - * @var int |
|
| 46 | - */ |
|
| 47 | - protected $_error = null; |
|
| 42 | + class PENSResponse extends PENSMessage { |
|
| 43 | + /** |
|
| 44 | + * Error code |
|
| 45 | + * @var int |
|
| 46 | + */ |
|
| 47 | + protected $_error = null; |
|
| 48 | 48 | |
| 49 | - /** |
|
| 50 | - * Descriptive text of the error |
|
| 51 | - * @var string |
|
| 52 | - */ |
|
| 53 | - protected $_error_text = null; |
|
| 49 | + /** |
|
| 50 | + * Descriptive text of the error |
|
| 51 | + * @var string |
|
| 52 | + */ |
|
| 53 | + protected $_error_text = null; |
|
| 54 | 54 | |
| 55 | - /** |
|
| 56 | - * Data linked to the error |
|
| 57 | - * @var string |
|
| 58 | - */ |
|
| 59 | - protected $_pens_data = null; |
|
| 55 | + /** |
|
| 56 | + * Data linked to the error |
|
| 57 | + * @var string |
|
| 58 | + */ |
|
| 59 | + protected $_pens_data = null; |
|
| 60 | 60 | |
| 61 | - /** |
|
| 62 | - * Version |
|
| 63 | - * @var string |
|
| 64 | - */ |
|
| 65 | - protected $_pens_version = null; |
|
| 61 | + /** |
|
| 62 | + * Version |
|
| 63 | + * @var string |
|
| 64 | + */ |
|
| 65 | + protected $_pens_version = null; |
|
| 66 | 66 | |
| 67 | - /** |
|
| 68 | - * Constructor |
|
| 69 | - * |
|
| 70 | - * @param mixed Can be a PENSException or an error code or a string representing an HTTP response |
|
| 71 | - * @param string error text |
|
| 72 | - * @param string PENS data |
|
| 73 | - */ |
|
| 74 | - public function __construct($error, $error_text = null, $pens_data = null) { |
|
| 75 | - $this->_pens_version = PENSConfig::$version; |
|
| 76 | - if($error instanceof PENSException) { |
|
| 77 | - $this->_error = $error->getCode(); |
|
| 78 | - $this->_error_text = $error->getMessage(); |
|
| 79 | - } else if(is_string($error)){ |
|
| 80 | - // Parse the string |
|
| 81 | - $this->parseResponse($error); |
|
| 82 | - } else if(is_array($error)) { |
|
| 83 | - // Try to build from array |
|
| 84 | - $this->_error = $error["error"]; |
|
| 85 | - $this->_error_text = $error["error-text"]; |
|
| 86 | - $this->_pens_data = $error["pens-data"]; |
|
| 87 | - } else { |
|
| 88 | - $this->_error = $error; |
|
| 89 | - $this->_error_text = $error_text; |
|
| 90 | - $this->_pens_data = $pens_data; |
|
| 91 | - } |
|
| 67 | + /** |
|
| 68 | + * Constructor |
|
| 69 | + * |
|
| 70 | + * @param mixed Can be a PENSException or an error code or a string representing an HTTP response |
|
| 71 | + * @param string error text |
|
| 72 | + * @param string PENS data |
|
| 73 | + */ |
|
| 74 | + public function __construct($error, $error_text = null, $pens_data = null) { |
|
| 75 | + $this->_pens_version = PENSConfig::$version; |
|
| 76 | + if($error instanceof PENSException) { |
|
| 77 | + $this->_error = $error->getCode(); |
|
| 78 | + $this->_error_text = $error->getMessage(); |
|
| 79 | + } else if(is_string($error)){ |
|
| 80 | + // Parse the string |
|
| 81 | + $this->parseResponse($error); |
|
| 82 | + } else if(is_array($error)) { |
|
| 83 | + // Try to build from array |
|
| 84 | + $this->_error = $error["error"]; |
|
| 85 | + $this->_error_text = $error["error-text"]; |
|
| 86 | + $this->_pens_data = $error["pens-data"]; |
|
| 87 | + } else { |
|
| 88 | + $this->_error = $error; |
|
| 89 | + $this->_error_text = $error_text; |
|
| 90 | + $this->_pens_data = $pens_data; |
|
| 91 | + } |
|
| 92 | 92 | |
| 93 | - } |
|
| 93 | + } |
|
| 94 | 94 | |
| 95 | - /** |
|
| 96 | - * Parses an HTTP response and assigns the attributes of the object |
|
| 97 | - * |
|
| 98 | - * @param string HTTP response |
|
| 99 | - */ |
|
| 100 | - protected function parseResponse($response) { |
|
| 101 | - $lines = explode(PENSConfig::$eol, $response); |
|
| 102 | - $i = 1; |
|
| 103 | - foreach($lines as $line) { |
|
| 104 | - if($i < 5) { |
|
| 105 | - $pair = explode("=", $line); |
|
| 106 | - if($pair[0] == "error") { |
|
| 107 | - $this->_error = intval($pair[1]); |
|
| 108 | - } else if($pair[0] == "error-text") { |
|
| 109 | - $this->_error_text = $pair[1]; |
|
| 110 | - } else if($pair[0] == "version") { |
|
| 111 | - $this->_pens_version = $pair[1]; |
|
| 112 | - } else if($pair[0] == "pens-data") { |
|
| 113 | - if(!empty($pair[1])) { |
|
| 114 | - $this->_pens_data = $pair[1].PENSConfig::$eol; |
|
| 115 | - } |
|
| 116 | - } |
|
| 117 | - } else { |
|
| 118 | - if(!empty($line)) { |
|
| 119 | - $this->_pens_data .= $line.PENSConfig::$eol; |
|
| 120 | - } |
|
| 121 | - } |
|
| 122 | - $i++; |
|
| 123 | - } |
|
| 124 | - } |
|
| 95 | + /** |
|
| 96 | + * Parses an HTTP response and assigns the attributes of the object |
|
| 97 | + * |
|
| 98 | + * @param string HTTP response |
|
| 99 | + */ |
|
| 100 | + protected function parseResponse($response) { |
|
| 101 | + $lines = explode(PENSConfig::$eol, $response); |
|
| 102 | + $i = 1; |
|
| 103 | + foreach($lines as $line) { |
|
| 104 | + if($i < 5) { |
|
| 105 | + $pair = explode("=", $line); |
|
| 106 | + if($pair[0] == "error") { |
|
| 107 | + $this->_error = intval($pair[1]); |
|
| 108 | + } else if($pair[0] == "error-text") { |
|
| 109 | + $this->_error_text = $pair[1]; |
|
| 110 | + } else if($pair[0] == "version") { |
|
| 111 | + $this->_pens_version = $pair[1]; |
|
| 112 | + } else if($pair[0] == "pens-data") { |
|
| 113 | + if(!empty($pair[1])) { |
|
| 114 | + $this->_pens_data = $pair[1].PENSConfig::$eol; |
|
| 115 | + } |
|
| 116 | + } |
|
| 117 | + } else { |
|
| 118 | + if(!empty($line)) { |
|
| 119 | + $this->_pens_data .= $line.PENSConfig::$eol; |
|
| 120 | + } |
|
| 121 | + } |
|
| 122 | + $i++; |
|
| 123 | + } |
|
| 124 | + } |
|
| 125 | 125 | |
| 126 | - public function getError() { |
|
| 127 | - return $this->_error; |
|
| 128 | - } |
|
| 126 | + public function getError() { |
|
| 127 | + return $this->_error; |
|
| 128 | + } |
|
| 129 | 129 | |
| 130 | - public function getErrorText() { |
|
| 131 | - return $this->_error_text; |
|
| 132 | - } |
|
| 130 | + public function getErrorText() { |
|
| 131 | + return $this->_error_text; |
|
| 132 | + } |
|
| 133 | 133 | |
| 134 | - public function getPensData() { |
|
| 135 | - return $this->_pens_data; |
|
| 136 | - } |
|
| 134 | + public function getPensData() { |
|
| 135 | + return $this->_pens_data; |
|
| 136 | + } |
|
| 137 | 137 | |
| 138 | - public function getVersion() { |
|
| 139 | - return $this->_pens_version; |
|
| 140 | - } |
|
| 138 | + public function getVersion() { |
|
| 139 | + return $this->_pens_version; |
|
| 140 | + } |
|
| 141 | 141 | |
| 142 | - /** |
|
| 143 | - * Sends the response content through HTTP headers |
|
| 144 | - */ |
|
| 145 | - public function send() { |
|
| 146 | - header("Content-Type: text/plain"); |
|
| 147 | - print $this; |
|
| 148 | - } |
|
| 142 | + /** |
|
| 143 | + * Sends the response content through HTTP headers |
|
| 144 | + */ |
|
| 145 | + public function send() { |
|
| 146 | + header("Content-Type: text/plain"); |
|
| 147 | + print $this; |
|
| 148 | + } |
|
| 149 | 149 | |
| 150 | - /** |
|
| 151 | - * Returns an associative array of the response |
|
| 152 | - * |
|
| 153 | - * @return array Associative array |
|
| 154 | - */ |
|
| 155 | - public function getArray() { |
|
| 156 | - return array("error" => $this->_error, |
|
| 157 | - "error-text" => $this->_error_text, |
|
| 158 | - "version" => PENSConfig::$version, |
|
| 159 | - "pens-data" => $this->_pens_data); |
|
| 160 | - } |
|
| 150 | + /** |
|
| 151 | + * Returns an associative array of the response |
|
| 152 | + * |
|
| 153 | + * @return array Associative array |
|
| 154 | + */ |
|
| 155 | + public function getArray() { |
|
| 156 | + return array("error" => $this->_error, |
|
| 157 | + "error-text" => $this->_error_text, |
|
| 158 | + "version" => PENSConfig::$version, |
|
| 159 | + "pens-data" => $this->_pens_data); |
|
| 160 | + } |
|
| 161 | 161 | |
| 162 | - /** |
|
| 163 | - * Transforms the object into a string |
|
| 164 | - */ |
|
| 165 | - public function __toString() { |
|
| 166 | - $eol = PENSConfig::$eol; |
|
| 167 | - $return = "error=".$this->_error.$eol; |
|
| 168 | - $return .= "error-text=".$this->_error_text.$eol; |
|
| 169 | - $return .= "version=".PENSConfig::$version.$eol; |
|
| 170 | - $return .= "pens-data=".$this->_pens_data.$eol; |
|
| 171 | - return $return; |
|
| 172 | - } |
|
| 162 | + /** |
|
| 163 | + * Transforms the object into a string |
|
| 164 | + */ |
|
| 165 | + public function __toString() { |
|
| 166 | + $eol = PENSConfig::$eol; |
|
| 167 | + $return = "error=".$this->_error.$eol; |
|
| 168 | + $return .= "error-text=".$this->_error_text.$eol; |
|
| 169 | + $return .= "version=".PENSConfig::$version.$eol; |
|
| 170 | + $return .= "pens-data=".$this->_pens_data.$eol; |
|
| 171 | + return $return; |
|
| 172 | + } |
|
| 173 | 173 | |
| 174 | - } |
|
| 174 | + } |
|
| 175 | 175 | |
@@ -26,9 +26,9 @@ |
||
| 26 | 26 | require_once __DIR__ . '/pens.php'; |
| 27 | 27 | |
| 28 | 28 | class MyRequestHandler extends PENSRequestHandler { |
| 29 | - public function processRequest($request, $response) { |
|
| 30 | - // Do the processing of the alert or the receipt here |
|
| 31 | - } |
|
| 29 | + public function processRequest($request, $response) { |
|
| 30 | + // Do the processing of the alert or the receipt here |
|
| 31 | + } |
|
| 32 | 32 | } |
| 33 | 33 | |
| 34 | 34 | $handler = new MyRequestHandler(); |
@@ -26,9 +26,9 @@ |
||
| 26 | 26 | require_once __DIR__ . '/pens.php'; |
| 27 | 27 | |
| 28 | 28 | class MyPackageHandler extends PENSPackageHandler { |
| 29 | - public function processPackage($request, $path_to_package) { |
|
| 30 | - // Do the package processing here |
|
| 31 | - } |
|
| 29 | + public function processPackage($request, $path_to_package) { |
|
| 30 | + // Do the package processing here |
|
| 31 | + } |
|
| 32 | 32 | } |
| 33 | 33 | |
| 34 | 34 | $handler = new MyPackageHandler(); |
@@ -44,25 +44,25 @@ |
||
| 44 | 44 | */ |
| 45 | 45 | class TestPENSResponse extends UnitTestCase { |
| 46 | 46 | |
| 47 | - public function testCreationFromPENSException() { |
|
| 48 | - $object = new PENSResponse(new PENSException(1101)); |
|
| 49 | - $this->assertEqual($object->getError(), 1101); |
|
| 50 | - $this->assertNotNull($object->getErrorText()); |
|
| 51 | - } |
|
| 47 | + public function testCreationFromPENSException() { |
|
| 48 | + $object = new PENSResponse(new PENSException(1101)); |
|
| 49 | + $this->assertEqual($object->getError(), 1101); |
|
| 50 | + $this->assertNotNull($object->getErrorText()); |
|
| 51 | + } |
|
| 52 | 52 | |
| 53 | - public function testCreationFromArguments() { |
|
| 54 | - $object = new PENSResponse(0, "collect command received and understood"); |
|
| 55 | - $this->assertIdentical($object->getError(), 0); |
|
| 56 | - $this->assertEqual($object->getErrorText(), "collect command received and understood"); |
|
| 57 | - } |
|
| 53 | + public function testCreationFromArguments() { |
|
| 54 | + $object = new PENSResponse(0, "collect command received and understood"); |
|
| 55 | + $this->assertIdentical($object->getError(), 0); |
|
| 56 | + $this->assertEqual($object->getErrorText(), "collect command received and understood"); |
|
| 57 | + } |
|
| 58 | 58 | |
| 59 | - public function testCreationFromHTTPResponse() { |
|
| 60 | - $eol = PENSConfig::$eol; |
|
| 61 | - $response = "error=1101".$eol."error-text=unable to parse PENS command".$eol."version=1.0.0".$eol."pens-data=".$eol; |
|
| 62 | - $object = new PENSResponse($response); |
|
| 63 | - $this->assertIdentical($object->getError(), 1101); |
|
| 64 | - $this->assertIdentical($object->getErrorText(), "unable to parse PENS command"); |
|
| 65 | - $this->assertIdentical($object->getVersion(), "1.0.0"); |
|
| 66 | - $this->assertNull($object->getPensData()); |
|
| 67 | - } |
|
| 59 | + public function testCreationFromHTTPResponse() { |
|
| 60 | + $eol = PENSConfig::$eol; |
|
| 61 | + $response = "error=1101".$eol."error-text=unable to parse PENS command".$eol."version=1.0.0".$eol."pens-data=".$eol; |
|
| 62 | + $object = new PENSResponse($response); |
|
| 63 | + $this->assertIdentical($object->getError(), 1101); |
|
| 64 | + $this->assertIdentical($object->getErrorText(), "unable to parse PENS command"); |
|
| 65 | + $this->assertIdentical($object->getVersion(), "1.0.0"); |
|
| 66 | + $this->assertNull($object->getPensData()); |
|
| 67 | + } |
|
| 68 | 68 | } |
@@ -33,8 +33,8 @@ discard block |
||
| 33 | 33 | require_once(dirname(__FILE__)."/../pens.php"); |
| 34 | 34 | |
| 35 | 35 | class MyPackageHandler extends PENSPackageHandler { |
| 36 | - public function processPackage($request, $path_to_package) { |
|
| 37 | - } |
|
| 36 | + public function processPackage($request, $path_to_package) { |
|
| 37 | + } |
|
| 38 | 38 | } |
| 39 | 39 | |
| 40 | 40 | /** |
@@ -49,39 +49,39 @@ discard block |
||
| 49 | 49 | */ |
| 50 | 50 | class TestPENSPackageHandler extends UnitTestCase { |
| 51 | 51 | |
| 52 | - public function testSupportedPackageTypesInvalid() { |
|
| 53 | - $object = new MyPackageHandler(); |
|
| 54 | - $object->setSupportedPackageTypes("testing"); |
|
| 55 | - $this->assertEqual($object->getSupportedPackageTypes(), null); |
|
| 56 | - } |
|
| 52 | + public function testSupportedPackageTypesInvalid() { |
|
| 53 | + $object = new MyPackageHandler(); |
|
| 54 | + $object->setSupportedPackageTypes("testing"); |
|
| 55 | + $this->assertEqual($object->getSupportedPackageTypes(), null); |
|
| 56 | + } |
|
| 57 | 57 | |
| 58 | - public function testSupportedPackageTypesInvalid2() { |
|
| 59 | - $object = new MyPackageHandler(); |
|
| 60 | - $object->setSupportedPackageTypes(array("aicc-pkg", "testing")); |
|
| 61 | - $this->assertEqual($object->getSupportedPackageTypes(), array("aicc-pkg")); |
|
| 62 | - } |
|
| 58 | + public function testSupportedPackageTypesInvalid2() { |
|
| 59 | + $object = new MyPackageHandler(); |
|
| 60 | + $object->setSupportedPackageTypes(array("aicc-pkg", "testing")); |
|
| 61 | + $this->assertEqual($object->getSupportedPackageTypes(), array("aicc-pkg")); |
|
| 62 | + } |
|
| 63 | 63 | |
| 64 | - public function testSupportedPackageTypesValid() { |
|
| 65 | - $object = new MyPackageHandler(); |
|
| 66 | - $object->setSupportedPackageTypes(array("aicc-pkg", "lms-qti")); |
|
| 67 | - $this->assertEqual($object->getSupportedPackageTypes(), array("aicc-pkg", "lms-qti")); |
|
| 68 | - } |
|
| 64 | + public function testSupportedPackageTypesValid() { |
|
| 65 | + $object = new MyPackageHandler(); |
|
| 66 | + $object->setSupportedPackageTypes(array("aicc-pkg", "lms-qti")); |
|
| 67 | + $this->assertEqual($object->getSupportedPackageTypes(), array("aicc-pkg", "lms-qti")); |
|
| 68 | + } |
|
| 69 | 69 | |
| 70 | - public function testSupportedPackageFormatsInvalid() { |
|
| 71 | - $object = new MyPackageHandler(); |
|
| 72 | - $object->setSupportedPackageFormats("testing"); |
|
| 73 | - $this->assertEqual($object->getSupportedPackageFormats(), null); |
|
| 74 | - } |
|
| 70 | + public function testSupportedPackageFormatsInvalid() { |
|
| 71 | + $object = new MyPackageHandler(); |
|
| 72 | + $object->setSupportedPackageFormats("testing"); |
|
| 73 | + $this->assertEqual($object->getSupportedPackageFormats(), null); |
|
| 74 | + } |
|
| 75 | 75 | |
| 76 | - public function testSupportedPackageFormatsInvalid2() { |
|
| 77 | - $object = new MyPackageHandler(); |
|
| 78 | - $object->setSupportedPackageFormats(array("zip", "testing")); |
|
| 79 | - $this->assertEqual($object->getSupportedPackageFormats(), array("zip")); |
|
| 80 | - } |
|
| 76 | + public function testSupportedPackageFormatsInvalid2() { |
|
| 77 | + $object = new MyPackageHandler(); |
|
| 78 | + $object->setSupportedPackageFormats(array("zip", "testing")); |
|
| 79 | + $this->assertEqual($object->getSupportedPackageFormats(), array("zip")); |
|
| 80 | + } |
|
| 81 | 81 | |
| 82 | - public function testSupportedPackageFormatsValid() { |
|
| 83 | - $object = new MyPackageHandler(); |
|
| 84 | - $object->setSupportedPackageFormats(array("zip", "jar")); |
|
| 85 | - $this->assertEqual($object->getSupportedPackageFormats(), array("zip", "jar")); |
|
| 86 | - } |
|
| 82 | + public function testSupportedPackageFormatsValid() { |
|
| 83 | + $object = new MyPackageHandler(); |
|
| 84 | + $object->setSupportedPackageFormats(array("zip", "jar")); |
|
| 85 | + $this->assertEqual($object->getSupportedPackageFormats(), array("zip", "jar")); |
|
| 86 | + } |
|
| 87 | 87 | } |
@@ -46,77 +46,77 @@ |
||
| 46 | 46 | */ |
| 47 | 47 | class TestPENSServer extends WebTestCase { |
| 48 | 48 | |
| 49 | - private $_valid_params = array( |
|
| 50 | - "command" => "collect", |
|
| 51 | - "pens-version" => "1.0.0", |
|
| 52 | - "package-type" => "aicc-pkg", |
|
| 53 | - "package-type-version" => "1.0", |
|
| 54 | - "package-format" => "zip", |
|
| 55 | - "package-id" => "http://myurl.com/12345", |
|
| 56 | - "package-url" => "http://www.aicc.org/pens/sample/captivatequiz.zip", |
|
| 57 | - "package-url-expiry" => "2099-04-09T14:17:43Z", |
|
| 58 | - "client" => "test-pens-server", |
|
| 59 | - "receipt" => PENS_TEST_RECEIPT_MAILTO); |
|
| 49 | + private $_valid_params = array( |
|
| 50 | + "command" => "collect", |
|
| 51 | + "pens-version" => "1.0.0", |
|
| 52 | + "package-type" => "aicc-pkg", |
|
| 53 | + "package-type-version" => "1.0", |
|
| 54 | + "package-format" => "zip", |
|
| 55 | + "package-id" => "http://myurl.com/12345", |
|
| 56 | + "package-url" => "http://www.aicc.org/pens/sample/captivatequiz.zip", |
|
| 57 | + "package-url-expiry" => "2099-04-09T14:17:43Z", |
|
| 58 | + "client" => "test-pens-server", |
|
| 59 | + "receipt" => PENS_TEST_RECEIPT_MAILTO); |
|
| 60 | 60 | |
| 61 | - public function testEmptyQuery() { |
|
| 62 | - $this->get(PENS_TEST_SERVER_URL); |
|
| 63 | - $this->assertText("error=2002"); |
|
| 64 | - } |
|
| 61 | + public function testEmptyQuery() { |
|
| 62 | + $this->get(PENS_TEST_SERVER_URL); |
|
| 63 | + $this->assertText("error=2002"); |
|
| 64 | + } |
|
| 65 | 65 | |
| 66 | - public function testValidQuery() { |
|
| 67 | - $this->get(PENS_TEST_SERVER_URL, $this->_valid_params); |
|
| 68 | - $this->assertText("error=0"); |
|
| 69 | - } |
|
| 66 | + public function testValidQuery() { |
|
| 67 | + $this->get(PENS_TEST_SERVER_URL, $this->_valid_params); |
|
| 68 | + $this->assertText("error=0"); |
|
| 69 | + } |
|
| 70 | 70 | |
| 71 | - private function invalidParameterTest($name, $value, $error) { |
|
| 72 | - $params = $this->_valid_params; |
|
| 73 | - $params[$name] = $value; |
|
| 74 | - $this->get(PENS_TEST_SERVER_URL, $params); |
|
| 75 | - $this->assertText("error=".$error); |
|
| 76 | - } |
|
| 71 | + private function invalidParameterTest($name, $value, $error) { |
|
| 72 | + $params = $this->_valid_params; |
|
| 73 | + $params[$name] = $value; |
|
| 74 | + $this->get(PENS_TEST_SERVER_URL, $params); |
|
| 75 | + $this->assertText("error=".$error); |
|
| 76 | + } |
|
| 77 | 77 | |
| 78 | - private function validParameterTest($name, $value) { |
|
| 79 | - $params = $this->_valid_params; |
|
| 80 | - $params[$name] = $value; |
|
| 81 | - $this->get(PENS_TEST_SERVER_URL, $params); |
|
| 82 | - $this->assertText("error=0"); |
|
| 83 | - } |
|
| 78 | + private function validParameterTest($name, $value) { |
|
| 79 | + $params = $this->_valid_params; |
|
| 80 | + $params[$name] = $value; |
|
| 81 | + $this->get(PENS_TEST_SERVER_URL, $params); |
|
| 82 | + $this->assertText("error=0"); |
|
| 83 | + } |
|
| 84 | 84 | |
| 85 | - public function testInvalidCommand() { |
|
| 86 | - $this->invalidParameterTest("command", "invalid", 2002); |
|
| 87 | - } |
|
| 85 | + public function testInvalidCommand() { |
|
| 86 | + $this->invalidParameterTest("command", "invalid", 2002); |
|
| 87 | + } |
|
| 88 | 88 | |
| 89 | - public function testInvalidVersion() { |
|
| 90 | - $this->invalidParameterTest("pens-version", "0.8.0", 2001); |
|
| 91 | - } |
|
| 89 | + public function testInvalidVersion() { |
|
| 90 | + $this->invalidParameterTest("pens-version", "0.8.0", 2001); |
|
| 91 | + } |
|
| 92 | 92 | |
| 93 | - public function testInvalidPackageType() { |
|
| 94 | - $this->invalidParameterTest("package-type", "invalid", 2003); |
|
| 95 | - } |
|
| 93 | + public function testInvalidPackageType() { |
|
| 94 | + $this->invalidParameterTest("package-type", "invalid", 2003); |
|
| 95 | + } |
|
| 96 | 96 | |
| 97 | - public function testEmptyPackageTypeVersion() { |
|
| 98 | - $this->invalidParameterTest("package-type-version", null, 2004); |
|
| 99 | - } |
|
| 97 | + public function testEmptyPackageTypeVersion() { |
|
| 98 | + $this->invalidParameterTest("package-type-version", null, 2004); |
|
| 99 | + } |
|
| 100 | 100 | |
| 101 | - public function testInvalidPackageFormat() { |
|
| 102 | - $this->invalidParameterTest("package-format", "invalid", 2005); |
|
| 103 | - } |
|
| 101 | + public function testInvalidPackageFormat() { |
|
| 102 | + $this->invalidParameterTest("package-format", "invalid", 2005); |
|
| 103 | + } |
|
| 104 | 104 | |
| 105 | - public function testInvalidPackageId() { |
|
| 106 | - $this->invalidParameterTest("package-id", "invalid", 2007); |
|
| 107 | - } |
|
| 105 | + public function testInvalidPackageId() { |
|
| 106 | + $this->invalidParameterTest("package-id", "invalid", 2007); |
|
| 107 | + } |
|
| 108 | 108 | |
| 109 | - public function testInvalidPackageUrl() { |
|
| 110 | - $this->invalidParameterTest("package-url", "invalid", 2008); |
|
| 111 | - } |
|
| 109 | + public function testInvalidPackageUrl() { |
|
| 110 | + $this->invalidParameterTest("package-url", "invalid", 2008); |
|
| 111 | + } |
|
| 112 | 112 | |
| 113 | - public function testInvalidPackageUrlExpiry() { |
|
| 114 | - $this->invalidParameterTest("package-url-expiry", "invalid", 2009); |
|
| 115 | - } |
|
| 113 | + public function testInvalidPackageUrlExpiry() { |
|
| 114 | + $this->invalidParameterTest("package-url-expiry", "invalid", 2009); |
|
| 115 | + } |
|
| 116 | 116 | |
| 117 | - public function testValidPackageUrlExpiry() { |
|
| 118 | - $this->validParameterTest("package-url-expiry", "2099-01-01"); |
|
| 119 | - } |
|
| 117 | + public function testValidPackageUrlExpiry() { |
|
| 118 | + $this->validParameterTest("package-url-expiry", "2099-01-01"); |
|
| 119 | + } |
|
| 120 | 120 | |
| 121 | 121 | } |
| 122 | 122 | |
@@ -44,170 +44,170 @@ |
||
| 44 | 44 | */ |
| 45 | 45 | class TestPENSRequest extends UnitTestCase { |
| 46 | 46 | |
| 47 | - /** |
|
| 48 | - * Valid arguments to be used for tests |
|
| 49 | - * |
|
| 50 | - * @var array |
|
| 51 | - */ |
|
| 52 | - private $args = null; |
|
| 53 | - |
|
| 54 | - public function setUp() { |
|
| 55 | - $this->args = array( |
|
| 56 | - "pens-version" => "1.0.0", |
|
| 57 | - "command" => "collect", |
|
| 58 | - "package-type" => "aicc-pkg", |
|
| 59 | - "package-type-version" => "1.0", |
|
| 60 | - "package-format" => "zip", |
|
| 61 | - "package-id" => "http://myurl.com/12345", |
|
| 62 | - "package-url" => "http://myurl.com/mypackage.zip", |
|
| 63 | - "package-url-expiry" => "2006-04-01T06:51:29Z", |
|
| 64 | - "client" => "Authorware7", |
|
| 65 | - "receipt" => "mailto:[email protected]", |
|
| 66 | - "package-url-user-id" => "guillaumev", |
|
| 67 | - "package-url-account" => "toto", |
|
| 68 | - "package-url-password" => "12345", |
|
| 69 | - "system-user-id" => "guillaumev", |
|
| 70 | - "system-password" => "12345", |
|
| 71 | - "alerts" => "http://myurl.com/alerts", |
|
| 72 | - "vendor-data" => "here are my data"); |
|
| 73 | - } |
|
| 74 | - |
|
| 75 | - public function createObject($myargs) { |
|
| 76 | - return PENSRequestFactory::createPENSRequest($myargs); |
|
| 77 | - } |
|
| 78 | - |
|
| 79 | - public function exceptionTestForValue($key, $value, $code) { |
|
| 80 | - try { |
|
| 81 | - $myargs = $this->args; |
|
| 82 | - if($value === null) { |
|
| 83 | - unset($myargs[$key]); |
|
| 84 | - } else { |
|
| 85 | - $myargs[$key] = $value; |
|
| 86 | - } |
|
| 87 | - $object = $this->createObject($myargs); |
|
| 88 | - $this->fail(); |
|
| 89 | - } catch(PENSException $e) { |
|
| 90 | - $this->assertEqual($e->getCode(), $code); |
|
| 91 | - } |
|
| 92 | - } |
|
| 93 | - |
|
| 94 | - public function testPensVersionInvalid() { |
|
| 95 | - $this->exceptionTestForValue("pens-version", "0.8.0", 2001); |
|
| 96 | - } |
|
| 97 | - |
|
| 98 | - public function testPensVersionNull() { |
|
| 99 | - $this->exceptionTestForValue("pens-version", null, 2001); |
|
| 100 | - } |
|
| 101 | - |
|
| 102 | - |
|
| 103 | - public function testCommandInvalid() { |
|
| 104 | - $this->exceptionTestForValue("command", "testing", 2002); |
|
| 105 | - } |
|
| 106 | - |
|
| 107 | - public function testCommandNull() { |
|
| 108 | - $this->exceptionTestForValue("command", null, 2002); |
|
| 109 | - } |
|
| 110 | - |
|
| 111 | - public function testPackageTypeInvalid() { |
|
| 112 | - $this->exceptionTestForValue("package-type", "testing", 2003); |
|
| 113 | - } |
|
| 114 | - |
|
| 115 | - public function testPackageTypeNull() { |
|
| 116 | - $this->exceptionTestForValue("package-type", null, 2003); |
|
| 117 | - } |
|
| 118 | - |
|
| 119 | - public function testPackageTypeVersionNull() { |
|
| 120 | - $this->exceptionTestForValue("package-type-version", null, 2004); |
|
| 121 | - } |
|
| 122 | - |
|
| 123 | - public function testPackageFormatInvalid() { |
|
| 124 | - $this->exceptionTestForValue("package-format", "testing", 2005); |
|
| 125 | - } |
|
| 126 | - |
|
| 127 | - public function testPackageFormatNull() { |
|
| 128 | - $this->exceptionTestForValue("package-format", null, 2005); |
|
| 129 | - } |
|
| 130 | - |
|
| 131 | - public function testPackageIdInvalid() { |
|
| 132 | - $this->exceptionTestForValue("package-id", "testing", 2007); |
|
| 133 | - } |
|
| 134 | - |
|
| 135 | - public function testPackageIdNull() { |
|
| 136 | - $this->exceptionTestForValue("package-id", null, 2007); |
|
| 137 | - } |
|
| 138 | - |
|
| 139 | - public function testPackageUrlInvalid() { |
|
| 140 | - $this->exceptionTestForValue("package-url", "testing", 2008); |
|
| 141 | - } |
|
| 142 | - |
|
| 143 | - public function testPackageUrlInvalid2() { |
|
| 144 | - $this->exceptionTestForValue("package-url", "http://myurl.com/mypackage", 2008); |
|
| 145 | - } |
|
| 146 | - |
|
| 147 | - public function testPackageUrlNull() { |
|
| 148 | - $this->exceptionTestForValue("package-url", null, 2008); |
|
| 149 | - } |
|
| 150 | - |
|
| 151 | - public function testPackageUrlExpiryNull() { |
|
| 152 | - $this->exceptionTestForValue("package-url-expiry", null, 2009); |
|
| 153 | - } |
|
| 154 | - |
|
| 155 | - public function testPackageUrlExpiryInvalid() { |
|
| 156 | - $this->exceptionTestForValue("package-url-expiry", "testing", 2009); |
|
| 157 | - } |
|
| 158 | - |
|
| 159 | - public function testClientNull() { |
|
| 160 | - $this->exceptionTestForValue("client", null, 2010); |
|
| 161 | - } |
|
| 162 | - |
|
| 163 | - public function testReceiptNull() { |
|
| 164 | - $this->exceptionTestForValue("receipt", null, 2011); |
|
| 165 | - } |
|
| 166 | - |
|
| 167 | - public function testReceiptInvalid() { |
|
| 168 | - $this->exceptionTestForValue("receipt", "testing", 2011); |
|
| 169 | - } |
|
| 170 | - |
|
| 171 | - public function testAlertsInvalid() { |
|
| 172 | - $this->exceptionTestForValue("alerts", "testing", 1201); |
|
| 173 | - } |
|
| 174 | - |
|
| 175 | - public function testReceiptValid() { |
|
| 176 | - try { |
|
| 177 | - $myargs = $this->args; |
|
| 178 | - $myargs["receipt"] = "mailto:[email protected],[email protected]"; |
|
| 179 | - $object = $this->createObject($myargs); |
|
| 180 | - $this->pass(); |
|
| 181 | - } catch(PENSException $e) { |
|
| 182 | - $this->fail(); |
|
| 183 | - } |
|
| 184 | - } |
|
| 185 | - |
|
| 186 | - public function testValid() { |
|
| 187 | - try { |
|
| 188 | - $object = $this->createObject($this->args); |
|
| 189 | - $this->assertIsA($object, "PENSRequestCollect"); |
|
| 190 | - $this->assertEqual($object->getPensVersion(), "1.0.0"); |
|
| 191 | - $this->assertEqual($object->getPackageType(), "aicc-pkg"); |
|
| 192 | - $this->assertEqual($object->getPackageTypeVersion(), "1.0"); |
|
| 193 | - $this->assertEqual($object->getPackageFormat(), "zip"); |
|
| 194 | - $this->assertEqual($object->getPackageId(), "http://myurl.com/12345"); |
|
| 195 | - $this->assertEqual($object->getPackageUrl(), "http://myurl.com/mypackage.zip"); |
|
| 196 | - $this->assertIsA($object->getPackageUrlExpiry(), "DateTime"); |
|
| 197 | - $this->assertEqual($object->getClient(), "Authorware7"); |
|
| 198 | - $this->assertEqual($object->getReceipt(), "mailto:[email protected]"); |
|
| 199 | - $this->assertEqual($object->getPackageUrlUserId(), "guillaumev"); |
|
| 200 | - $this->assertEqual($object->getPackageUrlAccount(), "toto"); |
|
| 201 | - $this->assertEqual($object->getPackageUrlPassword(), "12345"); |
|
| 202 | - $this->assertEqual($object->getSystemUserId(), "guillaumev"); |
|
| 203 | - $this->assertEqual($object->getSystemPassword(), "12345"); |
|
| 204 | - $this->assertEqual($object->getAlerts(), "http://myurl.com/alerts"); |
|
| 205 | - $this->assertEqual($object->getVendorData(), "here are my data"); |
|
| 47 | + /** |
|
| 48 | + * Valid arguments to be used for tests |
|
| 49 | + * |
|
| 50 | + * @var array |
|
| 51 | + */ |
|
| 52 | + private $args = null; |
|
| 53 | + |
|
| 54 | + public function setUp() { |
|
| 55 | + $this->args = array( |
|
| 56 | + "pens-version" => "1.0.0", |
|
| 57 | + "command" => "collect", |
|
| 58 | + "package-type" => "aicc-pkg", |
|
| 59 | + "package-type-version" => "1.0", |
|
| 60 | + "package-format" => "zip", |
|
| 61 | + "package-id" => "http://myurl.com/12345", |
|
| 62 | + "package-url" => "http://myurl.com/mypackage.zip", |
|
| 63 | + "package-url-expiry" => "2006-04-01T06:51:29Z", |
|
| 64 | + "client" => "Authorware7", |
|
| 65 | + "receipt" => "mailto:[email protected]", |
|
| 66 | + "package-url-user-id" => "guillaumev", |
|
| 67 | + "package-url-account" => "toto", |
|
| 68 | + "package-url-password" => "12345", |
|
| 69 | + "system-user-id" => "guillaumev", |
|
| 70 | + "system-password" => "12345", |
|
| 71 | + "alerts" => "http://myurl.com/alerts", |
|
| 72 | + "vendor-data" => "here are my data"); |
|
| 73 | + } |
|
| 74 | + |
|
| 75 | + public function createObject($myargs) { |
|
| 76 | + return PENSRequestFactory::createPENSRequest($myargs); |
|
| 77 | + } |
|
| 78 | + |
|
| 79 | + public function exceptionTestForValue($key, $value, $code) { |
|
| 80 | + try { |
|
| 81 | + $myargs = $this->args; |
|
| 82 | + if($value === null) { |
|
| 83 | + unset($myargs[$key]); |
|
| 84 | + } else { |
|
| 85 | + $myargs[$key] = $value; |
|
| 86 | + } |
|
| 87 | + $object = $this->createObject($myargs); |
|
| 88 | + $this->fail(); |
|
| 89 | + } catch(PENSException $e) { |
|
| 90 | + $this->assertEqual($e->getCode(), $code); |
|
| 91 | + } |
|
| 92 | + } |
|
| 93 | + |
|
| 94 | + public function testPensVersionInvalid() { |
|
| 95 | + $this->exceptionTestForValue("pens-version", "0.8.0", 2001); |
|
| 96 | + } |
|
| 97 | + |
|
| 98 | + public function testPensVersionNull() { |
|
| 99 | + $this->exceptionTestForValue("pens-version", null, 2001); |
|
| 100 | + } |
|
| 101 | + |
|
| 102 | + |
|
| 103 | + public function testCommandInvalid() { |
|
| 104 | + $this->exceptionTestForValue("command", "testing", 2002); |
|
| 105 | + } |
|
| 106 | + |
|
| 107 | + public function testCommandNull() { |
|
| 108 | + $this->exceptionTestForValue("command", null, 2002); |
|
| 109 | + } |
|
| 110 | + |
|
| 111 | + public function testPackageTypeInvalid() { |
|
| 112 | + $this->exceptionTestForValue("package-type", "testing", 2003); |
|
| 113 | + } |
|
| 114 | + |
|
| 115 | + public function testPackageTypeNull() { |
|
| 116 | + $this->exceptionTestForValue("package-type", null, 2003); |
|
| 117 | + } |
|
| 118 | + |
|
| 119 | + public function testPackageTypeVersionNull() { |
|
| 120 | + $this->exceptionTestForValue("package-type-version", null, 2004); |
|
| 121 | + } |
|
| 122 | + |
|
| 123 | + public function testPackageFormatInvalid() { |
|
| 124 | + $this->exceptionTestForValue("package-format", "testing", 2005); |
|
| 125 | + } |
|
| 126 | + |
|
| 127 | + public function testPackageFormatNull() { |
|
| 128 | + $this->exceptionTestForValue("package-format", null, 2005); |
|
| 129 | + } |
|
| 130 | + |
|
| 131 | + public function testPackageIdInvalid() { |
|
| 132 | + $this->exceptionTestForValue("package-id", "testing", 2007); |
|
| 133 | + } |
|
| 134 | + |
|
| 135 | + public function testPackageIdNull() { |
|
| 136 | + $this->exceptionTestForValue("package-id", null, 2007); |
|
| 137 | + } |
|
| 138 | + |
|
| 139 | + public function testPackageUrlInvalid() { |
|
| 140 | + $this->exceptionTestForValue("package-url", "testing", 2008); |
|
| 141 | + } |
|
| 142 | + |
|
| 143 | + public function testPackageUrlInvalid2() { |
|
| 144 | + $this->exceptionTestForValue("package-url", "http://myurl.com/mypackage", 2008); |
|
| 145 | + } |
|
| 146 | + |
|
| 147 | + public function testPackageUrlNull() { |
|
| 148 | + $this->exceptionTestForValue("package-url", null, 2008); |
|
| 149 | + } |
|
| 150 | + |
|
| 151 | + public function testPackageUrlExpiryNull() { |
|
| 152 | + $this->exceptionTestForValue("package-url-expiry", null, 2009); |
|
| 153 | + } |
|
| 154 | + |
|
| 155 | + public function testPackageUrlExpiryInvalid() { |
|
| 156 | + $this->exceptionTestForValue("package-url-expiry", "testing", 2009); |
|
| 157 | + } |
|
| 158 | + |
|
| 159 | + public function testClientNull() { |
|
| 160 | + $this->exceptionTestForValue("client", null, 2010); |
|
| 161 | + } |
|
| 162 | + |
|
| 163 | + public function testReceiptNull() { |
|
| 164 | + $this->exceptionTestForValue("receipt", null, 2011); |
|
| 165 | + } |
|
| 166 | + |
|
| 167 | + public function testReceiptInvalid() { |
|
| 168 | + $this->exceptionTestForValue("receipt", "testing", 2011); |
|
| 169 | + } |
|
| 170 | + |
|
| 171 | + public function testAlertsInvalid() { |
|
| 172 | + $this->exceptionTestForValue("alerts", "testing", 1201); |
|
| 173 | + } |
|
| 174 | + |
|
| 175 | + public function testReceiptValid() { |
|
| 176 | + try { |
|
| 177 | + $myargs = $this->args; |
|
| 178 | + $myargs["receipt"] = "mailto:[email protected],[email protected]"; |
|
| 179 | + $object = $this->createObject($myargs); |
|
| 180 | + $this->pass(); |
|
| 181 | + } catch(PENSException $e) { |
|
| 182 | + $this->fail(); |
|
| 183 | + } |
|
| 184 | + } |
|
| 185 | + |
|
| 186 | + public function testValid() { |
|
| 187 | + try { |
|
| 188 | + $object = $this->createObject($this->args); |
|
| 189 | + $this->assertIsA($object, "PENSRequestCollect"); |
|
| 190 | + $this->assertEqual($object->getPensVersion(), "1.0.0"); |
|
| 191 | + $this->assertEqual($object->getPackageType(), "aicc-pkg"); |
|
| 192 | + $this->assertEqual($object->getPackageTypeVersion(), "1.0"); |
|
| 193 | + $this->assertEqual($object->getPackageFormat(), "zip"); |
|
| 194 | + $this->assertEqual($object->getPackageId(), "http://myurl.com/12345"); |
|
| 195 | + $this->assertEqual($object->getPackageUrl(), "http://myurl.com/mypackage.zip"); |
|
| 196 | + $this->assertIsA($object->getPackageUrlExpiry(), "DateTime"); |
|
| 197 | + $this->assertEqual($object->getClient(), "Authorware7"); |
|
| 198 | + $this->assertEqual($object->getReceipt(), "mailto:[email protected]"); |
|
| 199 | + $this->assertEqual($object->getPackageUrlUserId(), "guillaumev"); |
|
| 200 | + $this->assertEqual($object->getPackageUrlAccount(), "toto"); |
|
| 201 | + $this->assertEqual($object->getPackageUrlPassword(), "12345"); |
|
| 202 | + $this->assertEqual($object->getSystemUserId(), "guillaumev"); |
|
| 203 | + $this->assertEqual($object->getSystemPassword(), "12345"); |
|
| 204 | + $this->assertEqual($object->getAlerts(), "http://myurl.com/alerts"); |
|
| 205 | + $this->assertEqual($object->getVendorData(), "here are my data"); |
|
| 206 | 206 | |
| 207 | - } catch(PENSException $e) { |
|
| 208 | - $this->fail(); |
|
| 209 | - } |
|
| 210 | - } |
|
| 207 | + } catch(PENSException $e) { |
|
| 208 | + $this->fail(); |
|
| 209 | + } |
|
| 210 | + } |
|
| 211 | 211 | |
| 212 | 212 | |
| 213 | 213 | } |