From 753cb262e000db625d9e0feef687db3c56d3ff52 Mon Sep 17 00:00:00 2001 From: "Mr. Timothy G Webb Sr" Date: Mon, 28 Sep 2020 01:46:14 -0400 Subject: [PATCH] Revert "Updating my branch with master" --- src/bb-di.php | 1 - src/bb-library/Box/Requirements.php | 1 + src/bb-library/Payment/Adapter/SimplePay.php | 249 ------------------ .../includes/opensrs/openSRS_base.php | 6 +- src/bb-load.php | 41 +++ src/bb-modules/Order/Service.php | 12 +- .../Servicelicense/Plugin/Simple.php | 23 +- src/bb-modules/Servicelicense/Service.php | 4 - .../Serviceyouhosting/Api/Guest.php | 4 +- src/bb-modules/Staff/Service.php | 2 +- src/bb-modules/Theme/Service.php | 2 + src/bb-themes/huraga/assets/css/logos.css | 8 - .../assets/img/gateway_logos/simplepay.png | Bin 3841 -> 0 bytes src/composer.json | 107 ++++---- tests/bb-modules/Extension/ServiceTest.php | 83 +++--- tests/bb-modules/System/ServiceTest.php | 6 +- 16 files changed, 151 insertions(+), 398 deletions(-) delete mode 100644 src/bb-library/Payment/Adapter/SimplePay.php delete mode 100644 src/bb-themes/huraga/assets/img/gateway_logos/simplepay.png diff --git a/src/bb-di.php b/src/bb-di.php index f6a74de07..3c6befe66 100644 --- a/src/bb-di.php +++ b/src/bb-di.php @@ -20,7 +20,6 @@ $di['logger'] = function () use ($di) { $logFile = $di['config']['path_logs']; $writer = new Box_LogStream($logFile); $log = new Box_Log(); - $log->setDi($di); $log->addWriter($writer); $log_to_db = isset($di['config']['log_to_db']) && $di['config']['log_to_db']; diff --git a/src/bb-library/Box/Requirements.php b/src/bb-library/Box/Requirements.php index e8c31c49a..149470a6a 100644 --- a/src/bb-library/Box/Requirements.php +++ b/src/bb-library/Box/Requirements.php @@ -77,6 +77,7 @@ class Box_Requirements implements \Box\InjectionAwareInterface 'allow_url_fopen' => ini_get('allow_url_fopen'), 'safe_mode' => ini_get('safe_mode'), 'memory_limit' => ini_get('memory_limit'), + 'magic_quotes' => (function_exists('get_magic_quotes_gpc') && get_magic_quotes_gpc()), ); $data['permissions'] = array( diff --git a/src/bb-library/Payment/Adapter/SimplePay.php b/src/bb-library/Payment/Adapter/SimplePay.php deleted file mode 100644 index dfec76c8a..000000000 --- a/src/bb-library/Payment/Adapter/SimplePay.php +++ /dev/null @@ -1,249 +0,0 @@ -di = $di; - } - - public function getDi() - { - return $this->di; - } - - public function __construct($config) - { - $this->config = $config; - - if(!isset($this->config['api_key'])) { - throw new Payment_Exception('Payment gateway "SimplePay" is not configured properly. Please update configuration parameter "api_key" at "Configuration -> Payments".'); - } - - if(!isset($this->config['pub_key'])) { - throw new Payment_Exception('Payment gateway "SimplePay" is not configured properly. Please update configuration parameter "pub_key" at "Configuration -> Payments".'); - } - } - - public static function getConfig() - { - return array( - 'supports_one_time_payments' => true, - 'description' => ' You authenticate to the SimplePay API by providing one of your API keys in the request. You can manage your API keys from your account.', - 'form' => array( - 'test_api_key' => array('text', array( - 'label' => 'Test Secret key:', - 'required' => false, - ), - ), - 'test_pub_key' => array('text', array( - 'label' => 'Test Publishable key:', - 'required' => false, - ), - ), - 'api_key' => array('text', array( - 'label' => 'Live Secret key:', - ), - ), - 'pub_key' => array('text', array( - 'label' => 'Live publishable key:', - ), - ), - ), - ); - } - - public function getHtml($api_admin, $invoice_id, $subscription) - { - $invoiceModel = $this->di['db']->load('Invoice', $invoice_id); - - return $this->_generateForm($invoiceModel); - } - - public function getAmountInCents(\Model_Invoice $invoice) - { - $invoiceService = $this->di['mod_service']('Invoice'); - return $invoiceService->getTotalWithTax($invoice) * 100; - } - - public function getInvoiceTitle(\Model_Invoice $invoice) - { - $invoiceItems = $this->di['db']->getAll('SELECT title from invoice_item WHERE invoice_id = :invoice_id', array(':invoice_id' => $invoice->id)); - - $params = array( - ':id'=>sprintf('%05s', $invoice->nr), - ':serie'=>$invoice->serie, - ':title'=>$invoiceItems[0]['title']); - $title = __('Payment for invoice :serie:id [:title]', $params); - if(count($invoiceItems) > 1) { - $title = __('Payment for invoice :serie:id', $params); - } - return $title; - } - - public function logError(Exception $e, Model_Transaction $tx) - { - $body = $e->getJsonBody(); - $err = $body['error']; - $tx->txn_status = $err ['type']; - $tx->error = $err['message']; - $tx->status = 'processed'; - $tx->updated_at = date('Y-m-d H:i:s'); - $this->di['db']->store($tx); - - - if ($this->di['config']['debug']){ - error_log(json_encode($e->getJsonBody())); - } - throw new Exception($tx->error); - } - - public function processTransaction($api_admin, $id, $data, $gateway_id) - { - - $invoice = $this->di['db']->getExistingModelById('Invoice', $data['get']['bb_invoice_id']); - $tx = $this->di['db']->getExistingModelById('Transaction', $id); - - $title = $this->getInvoiceTitle($invoice); - - $invoiceService = $this->di['mod_service']('Invoice'); - - $tx->invoice_id = $invoice->id; - $tx->type = 'SimplePay Checkout'; - - $tx->txn_status = "success"; - $tx->txn_id = $data['post']['simplePayToken']; - $tx->amount = $invoiceService->getTotalWithTax($invoice); - $tx->currency = $invoice->currency; - - $bd = array( - 'amount' => $tx->amount, - 'description' => 'SimplePay transaction '.$data['post']['simplePayToken'], - 'type' => 'transaction', - 'rel_id' => $tx->id, - ); - $client = $this->di['db']->getExistingModelById('Client', $invoice->client_id); - $clientService = $this->di['mod_service']('client'); - $clientService->addFunds($client, $bd['amount'], $bd['description'], $bd); - if($tx->invoice_id) { - $invoiceService->payInvoiceWithCredits($invoice); - } - $invoiceService->doBatchPayWithCredits(array('client_id'=>$client->id)); - - $tx->status = 'processed'; - $tx->updated_at = date('Y-m-d H:i:s'); - $this->di['db']->store($tx); - } - - /** - * @param string $url - */ - protected function _generateForm(Model_Invoice $invoice) - { - $pubKey = $this->config['pub_key']; - if ($this->config['test_mode']){ - $pubKey = $this->get_test_pub_key(); - } - - $dataAmount = $this->getAmountInCents($invoice); - - $settingService = $this->di['mod_service']('System'); - $company = $settingService->getCompany(); - - $title = $this->getInvoiceTitle($invoice); - - $form = '
- - - - -
'; - - $payGatewayService = $this->di['mod_service']('Invoice', 'PayGateway'); - $payGateway = $this->di['db']->findOne('PayGateway', 'gateway = "SimplePay"'); - $bindings = array( - ':key' => $pubKey, - ':amount' => $dataAmount, - ':currency' => $invoice->currency, - ':name' => $company['name'], - ':description' => $title, - ':image' => $company['logo_url'], - ':email' => $invoice->buyer_email, - ':phone' => $invoice->buyer_phone, - ':address' => $invoice->buyer_address, - ':postal' => $invoice->buyer_zip, - ':city' => $invoice->buyer_city, - ':country' => $invoice->buyer_country, - ':callbackUrl' => $payGatewayService->getCallbackUrl($payGateway, $invoice), - ':redirectUrl' => $this->di['tools']->url('invoice/'.$invoice->hash) - ); - - return strtr($form, $bindings); - } - - public function get_test_pub_key() - { - if(!isset($this->config['test_pub_key'])) { - throw new Payment_Exception('Payment gateway "SimplePay" is not configured properly. Please update configuration parameter "test_pub_key" at "Configuration -> Payments".'); - } - return $this->config['test_pub_key']; - } - - public function get_test_api_key() - { - if(!isset($this->config['test_api_key'])) { - throw new Payment_Exception('Payment gateway "SimplePay" is not configured properly. Please update configuration parameter "test_api_key" at "Configuration -> Payments".'); - } - return $this->config['test_api_key']; - } -} diff --git a/src/bb-library/Registrar/includes/opensrs/openSRS_base.php b/src/bb-library/Registrar/includes/opensrs/openSRS_base.php index 743733374..99f805efa 100644 --- a/src/bb-library/Registrar/includes/opensrs/openSRS_base.php +++ b/src/bb-library/Registrar/includes/opensrs/openSRS_base.php @@ -349,7 +349,7 @@ class openSRS_base { } if (preg_match('/^\s*Content-Length:\s+(\d+)\s*\r\n/i', $line, $matches ) ) { - $header['content-length'] = (int)$matches[1]; + $header{'content-length'} = (int)$matches[1]; } else { trigger_error ("oSRS Error - UNEXPECTED READ: No Content-Length.", E_USER_WARNING); return false; @@ -381,14 +381,14 @@ class openSRS_base { /* PHP doesn't have timeout for fread ... we just set the timeout for the socket */ socket_set_timeout($fh, $timeout); $header = $this->readHeader($fh, $timeout); - if (!$header || !isset($header['content-length']) || (empty($header['content-length']))) { + if (!$header || !isset($header{'content-length'}) || (empty($header{'content-length'}))) { if ($this->crypt_type == "SSL") trigger_error ("oSRS Error - UNEXPECTED ERROR: No Content-Length header provided! Please make sure IP is whitelisted in RWI.", E_USER_WARNING); else trigger_error ("oSRS Error - No Content-Length header returned. Please make sure IP is whitelisted in RWI. Check the osrs_key and osrs_username in the config file as well.", E_USER_WARNING); } - $len = (int)$header['content-length']; + $len = (int)$header{'content-length'}; $line = ''; while (strlen($line) < $len) { $line .= fread($fh, $len); diff --git a/src/bb-load.php b/src/bb-load.php index bfd1eab55..763e65cb0 100644 --- a/src/bb-load.php +++ b/src/bb-load.php @@ -136,3 +136,44 @@ if($config['debug']) { ini_set('log_errors', '1'); ini_set('html_errors', FALSE); ini_set('error_log', BB_PATH_LOG . '/php_error.log'); + +// Strip magic quotes from request data. +/** +Deprecated: Function get_magic_quotes_gpc() +**/ +//if (function_exists('get_magic_quotes_gpc') && get_magic_quotes_gpc()) +// Create lamba style unescaping function (for portability) +// $quotes_sybase = strtolower(ini_get('magic_quotes_sybase')); +{ + // Create lamba style unescaping function (for portability) + $quotes_sybase = strtolower(ini_get('magic_quotes_sybase')); + + /* create_function deprecated in PHP 7.2 + $unescape_function = (empty($quotes_sybase) || $quotes_sybase === 'off') ? 'stripslashes($value)' : 'str_replace("\'\'","\'",$value)'; + $stripslashes_deep = create_function('&$value, $fn', ' + if (is_string($value)) { + $value = ' . $unescape_function . '; + } else if (is_array($value)) { + foreach ($value as &$v) $fn($v, $fn); + } + '); */ + + $stripslashes_deep = function(&$value, $fn){ + if (is_string($value)) { + $value = (empty($quotes_sybase) || $quotes_sybase === 'off') ? stripslashes($value) : str_replace("\'\'","\'",$value); + } else if (is_array($value)) { + foreach ($value as &$v) $fn($v, $fn); + } +}; + + + // Unescape data + $stripslashes_deep($_POST, $stripslashes_deep); + $stripslashes_deep($_GET, $stripslashes_deep); + $stripslashes_deep($_COOKIE, $stripslashes_deep); + $stripslashes_deep($_REQUEST, $stripslashes_deep); + + + +} +?> diff --git a/src/bb-modules/Order/Service.php b/src/bb-modules/Order/Service.php index e2913996c..b85e5d3d4 100644 --- a/src/bb-modules/Order/Service.php +++ b/src/bb-modules/Order/Service.php @@ -65,11 +65,12 @@ class Service implements InjectionAwareInterface try { $order = $di['db']->getExistingModelById('ClientOrder', $order_id, 'Order not found');; - $s = $service->getOrderServiceData($order); - $orderArr = $service->toApiArray($order, true); + $identity = $di['loggedin_admin']; + $s = $service->getOrderServiceData($order, $identity); + $orderArr = $service->toApiArray($order, true, $identity); $email = $params; - $email['to_client'] = $order->client_id; + $email['to_client'] = $orderArr['client']['id']; $email['code'] = sprintf('mod_service%s_activated', $orderArr['service_type']); $email['service'] = $s; $email['order'] = $orderArr; @@ -359,9 +360,6 @@ class Service implements InjectionAwareInterface } } - $client = $this->di['db']->getExistingModelById('Client', $model->client_id, 'Client not found'); - $data['client'] = $clientService->toApiArray($client, false); - return $data; } @@ -1329,4 +1327,4 @@ class Service implements InjectionAwareInterface $stmt->execute(array('id'=>$client->id)); } -} +} \ No newline at end of file diff --git a/src/bb-modules/Servicelicense/Plugin/Simple.php b/src/bb-modules/Servicelicense/Plugin/Simple.php index 1f789a9a4..76255c1bf 100644 --- a/src/bb-modules/Servicelicense/Plugin/Simple.php +++ b/src/bb-modules/Servicelicense/Plugin/Simple.php @@ -15,24 +15,6 @@ namespace Box\Mod\Servicelicense\Plugin; class Simple { - protected $di; - - /** - * @param \Box_Di $di - */ - public function setDi($di) - { - $this->di = $di; - } - - /** - * @return \Box_Di - */ - public function getDi() - { - return $this->di; - } - /** * License generation script * @@ -43,9 +25,6 @@ class Simple */ public function generate(\Model_ServiceLicense $service, \Model_ClientOrder $order, array $config) { - // Optional: to get customer data - //$client = $this->di['db']->load('Client', $order->client_id); - $length = isset($config['length']) ? $config['length'] : 25; $prefix = isset($config['prefix']) ? $config['prefix'] : NULL; @@ -83,4 +62,4 @@ class Simple ); } */ -} +} \ No newline at end of file diff --git a/src/bb-modules/Servicelicense/Service.php b/src/bb-modules/Servicelicense/Service.php index 38326517c..ffa07099c 100644 --- a/src/bb-modules/Servicelicense/Service.php +++ b/src/bb-modules/Servicelicense/Service.php @@ -135,10 +135,6 @@ class Service implements InjectionAwareInterface throw new \Box_Exception('License plugin do not have generate method'); } - if(method_exists($plugin, 'setDi')) { - $plugin->setDi($this->di); - } - $i = 0; do { $licenseKey = $plugin->generate($model, $order, $c); diff --git a/src/bb-modules/Serviceyouhosting/Api/Guest.php b/src/bb-modules/Serviceyouhosting/Api/Guest.php index d6e887faa..3116b1daa 100644 --- a/src/bb-modules/Serviceyouhosting/Api/Guest.php +++ b/src/bb-modules/Serviceyouhosting/Api/Guest.php @@ -32,9 +32,7 @@ class Guest extends \Api_Abstract if (isset($config['yh_ips'])) { $allowed_ips = explode(PHP_EOL, $config['yh_ips']); - array_walk($allowed_ips, function(&$val){ - $val = trim($val); - }); + array_walk($allowed_ips, create_function('&$val', '$val = trim($val);')); } else { $allowed_ips = array( '212.1.209.2', diff --git a/src/bb-modules/Staff/Service.php b/src/bb-modules/Staff/Service.php index b76fce717..f4ca2bb52 100644 --- a/src/bb-modules/Staff/Service.php +++ b/src/bb-modules/Staff/Service.php @@ -680,4 +680,4 @@ class Service implements InjectionAwareInterface return $this->di['auth']->authorizeUser($model, $plainTextPassword); } -} +} \ No newline at end of file diff --git a/src/bb-modules/Theme/Service.php b/src/bb-modules/Theme/Service.php index dd4085cee..3407c7cce 100644 --- a/src/bb-modules/Theme/Service.php +++ b/src/bb-modules/Theme/Service.php @@ -276,6 +276,8 @@ class Service implements InjectionAwareInterface $path = $this->getThemesPath(); if ($handle = opendir($path)) { while (false !== ($file = readdir($handle))) { +//**Deprecated: Array and string offset access syntax with curly braces *// + if (is_dir($path . DIRECTORY_SEPARATOR . $file) && $file[0] != '.') { try { if (!$client && strpos($file, 'admin') !== false) { diff --git a/src/bb-themes/huraga/assets/css/logos.css b/src/bb-themes/huraga/assets/css/logos.css index 9d256382c..4b6606520 100644 --- a/src/bb-themes/huraga/assets/css/logos.css +++ b/src/bb-themes/huraga/assets/css/logos.css @@ -118,11 +118,3 @@ border: 0; margin: 10px; } -.logo-SimplePay{ - background: transparent url("../img/gateway_logos/simplepay.png") no-repeat scroll 0% 0%; - background-size: contain; - width:130px; - height: 30px; - border: 0; - margin: 10px; -} diff --git a/src/bb-themes/huraga/assets/img/gateway_logos/simplepay.png b/src/bb-themes/huraga/assets/img/gateway_logos/simplepay.png deleted file mode 100644 index 1ea0d360a648a402da05cfb4c500d7d0de42879a..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 3841 zcmV+c5B~6pP)ftqA4Wh1c ze6Z@C5OFN;(Bt9{ytO*(v$iV&_e^!q zgF#&nD)*c|T~+tity{nQt>5qa``!yZlvt=K|J+P=9@}B(I@?U`v`r_(!Sb~!{+=#I z8_J1=){GW>%T=^0nkZY{S*b)o2Ljgv4F^s5^(aPf6(YWu5Jm{{d`)Q0fH~)_$WIvZys%{Qx@-j4Gp!2~@^7Ad zd;sFg{~k2o*9-_9dpe43)0tTtPW{l|<_bVGer^l!>ukF-YpPP;${ue7K2byd=b-t% zZlR$_e*(-`)n{6a^k%!VX+*{q@XM@wXq{dk_$bR3OF@pa;(=H8)%l`{YxBEgpwm)ieY(R-%l|0R%C= zYsE`91K6fB7r3#n&J=EqCW3c$8r4h=1o;3sEPJWON(5&dz#tfc@NxF^LzM4W4Z)Vr z(`Rj{$){qh14i~^I(CR~Q6wH%ZHFDKc<{^95vDC32Y^*yz8x49Gm~ct@-u`Nta$0> zy2{mtYxq|JXZORs+-aLmsg!VeWKmGFfbwb;haAZ6QDKC1oeoBN)>-zePs13H{kZzm z`fycVw!_ZFRy_FBmntaLgq_0-SBI;}r#>-0sg9Sv44jv1;2K3&f_g#l39ug6MaI<~ z3w*~@e|&oj29PfC74K?Iw=V!HfnB)9U5hJI9LS;Ji$|9lIS1S6Y2YKzc@c0NaHt27 zPsU7Va5NFz@uiVPLwOdF^#X6X>Tb17XO|sL-7$Caf96KDFz>xwceIrVj<*uQOMSbG z#<{Aeh|4Ho1FB7iTXgBwjlnd)q-CS^5O?=16^=JtImK!$e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7R z@~P6jjaT;e5TkBoLB${U34|q+SM;FtYM<}a(>-1-qOjb-oxQg2Yy6+}V~kZb?{l1; zAP74(9-HX?lB};}iJ8vD0=Y$`j}?xOCW3qThLyT2n+CZ>#&3bs0j~$S$4UfmSu%MY zQ=7.4.9", - "ext-curl": "*", - "ext-zlib": "*", - "ext-PDO": "*", - "ext-mbstring" : "*", - "pimple/pimple": "v3.3.0", - "twig/twig": "v2.13.0", - "twig/extensions": "1.5.4", - "mpdf/mpdf": "v8.0.4", - "geoip2/geoip2": "v2.10.0", - "ircmaxell/password-compat": "v1.0.4", - "phpmailer/phpmailer": "6.1.6", - "mustangostang/spyc": "0.5.1", - "michelf/php-markdown": "1.7.0", - "stripe/stripe-php": "2.1.1", - "guzzlehttp/guzzle": "^v3.8.1" - - }, - "suggest": { - "ext-gettext": "*" - }, - "config": { - "vendor-dir": "bb-vendor" - }, - "autoload": { - "psr-0": {"": "bb-library"}, - "psr-4": {"Box\\Mod\\": "bb-modules"} - }, - - "require-dev": { - "phpunit/phpunit": "^9.0", - "squizlabs/php_codesniffer": "1.*" - - }, - "autoload-dev": { - "psr-0": { "": "../tests/bb-library" } - } -} - +{ + "name": "boxbilling/boxbilling", + "description": "Open Source Billing Software", + "type": "project", + "license": "Apache-2.0", + "keywords": ["billing", "invoice", "client management"], + "homepage": "http://www.boxbilling.com", + "authors": [ + { + "name": "Andrius Putna", + "email": "andrius@boxbilling.com" + } + ], + "require": { + + "php": ">=7.4.9", + "ext-curl": "*", + "ext-zlib": "*", + "ext-PDO": "*", + "ext-mbstring" : "*", + "pimple/pimple": "v3.3.0", + "twig/twig": "v2.13.0", + "twig/extensions": "1.5.4", + "mpdf/mpdf": "v8.0.4", + "geoip2/geoip2": "v2.10.0", + "ircmaxell/password-compat": "v1.0.4", + "phpmailer/phpmailer": "6.1.6", + "mustangostang/spyc": "0.5.1", + "michelf/php-markdown": "1.7.0", + "stripe/stripe-php": "2.1.1", + "guzzlehttp/guzzle": "^v3.8.1" + + }, + "suggest": { + "ext-gettext": "*" + }, + "config": { + "vendor-dir": "bb-vendor" + }, + "autoload": { + "psr-0": {"": "bb-library"}, + "psr-4": {"Box\\Mod\\": "bb-modules"} + }, + + "require-dev": { + "phpunit/phpunit": "^9.0", + "squizlabs/php_codesniffer": "1.*" + + }, + "autoload-dev": { + "psr-0": { "": "../tests/bb-library" } + } +} diff --git a/tests/bb-modules/Extension/ServiceTest.php b/tests/bb-modules/Extension/ServiceTest.php index 4cc79138c..77f8b36f9 100644 --- a/tests/bb-modules/Extension/ServiceTest.php +++ b/tests/bb-modules/Extension/ServiceTest.php @@ -594,17 +594,17 @@ class ServiceTest extends \BBTestCase { public function testdownloadAndExtract() { - $extensionMock = $this->getMockBuilder(\Box_Extension::class)->getMock(); + $extensionMock = $this->getMockBuilder('\Box_Extension')->getMock(); $extensionMock->expects($this->atLeastOnce()) ->method('getExtension') ->will($this->returnValue(array('download_url' => 'www.boxbillig.com'))); - $curlMock = $this->getMockBuilder(\Box_Curl::class)->disableOriginalConstructor()->getMock(); + $curlMock = $this->getMockBuilder('\Box_Curl')->disableOriginalConstructor()->getMock(); $curlMock->expects($this->atLeastOnce()) ->method('downloadTo'); - $zipArchiveMock = $this->getMockBuilder(\ZipArchive::class)->getMock(); + $zipArchiveMock = $this->getMockBuilder('ZipArchive')->getMock(); $zipArchiveMock->expects($this->atLeastOnce()) ->method('open') ->will($this->returnValue(TRUE)); @@ -615,7 +615,7 @@ class ServiceTest extends \BBTestCase { - $toolsMock = $this->getMockBuilder(\Box_tools::class)->getMock(); + $toolsMock = $this->getMockBuilder('\Box_tools')->getMock(); $toolsMock->expects($this->atLeastOnce()) ->method('fileExists') ->will($this->returnValue(false)); @@ -638,17 +638,17 @@ class ServiceTest extends \BBTestCase { public function testdownloadAndExtractTypeExceptionNotDefinedTypeException() { - $extensionMock = $this->getMockBuilder(\Box_Extension::class)->getMock(); + $extensionMock = $this->getMockBuilder('\Box_Extension')->getMock(); $extensionMock->expects($this->atLeastOnce()) ->method('getExtension') ->will($this->returnValue(array('download_url' => 'www.boxbillig.com'))); - $curlMock = $this->getMockBuilder(\Box_Curl::class)->disableOriginalConstructor()->getMock(); + $curlMock = $this->getMockBuilder('\Box_Curl')->disableOriginalConstructor()->getMock(); $curlMock->expects($this->atLeastOnce()) ->method('downloadTo'); - $zipArchiveMock = $this->getMockBuilder(\ZipArchive::class)->getMock(); + $zipArchiveMock = $this->getMockBuilder('ZipArchive')->getMock(); $zipArchiveMock->expects($this->atLeastOnce()) ->method('open') ->will($this->returnValue(TRUE)); @@ -670,17 +670,17 @@ class ServiceTest extends \BBTestCase { public function testdownloadAndExtractTranslationException() { - $extensionMock = $this->getMockBuilder(\Box_Extension::class)->getMock(); + $extensionMock = $this->getMockBuilder('\Box_Extension')->getMock(); $extensionMock->expects($this->atLeastOnce()) ->method('getExtension') ->will($this->returnValue(array('download_url' => 'www.boxbillig.com'))); - $curlMock = $this->getMockBuilder(\Box_Curl::class)->disableOriginalConstructor()->getMock(); + $curlMock = $this->getMockBuilder('\Box_Curl')->disableOriginalConstructor()->getMock(); $curlMock->expects($this->atLeastOnce()) ->method('downloadTo'); - $zipArchiveMock = $this->getMockBuilder(\ZipArchive::class)->getMock(); + $zipArchiveMock = $this->getMockBuilder('ZipArchive')->getMock(); $zipArchiveMock->expects($this->atLeastOnce()) ->method('open') ->will($this->returnValue(TRUE)); @@ -691,7 +691,7 @@ class ServiceTest extends \BBTestCase { - $toolsMock = $this->getMockBuilder(\Box_tools::class)->getMock(); + $toolsMock = $this->getMockBuilder('\Box_tools')->getMock(); $toolsMock->expects($this->atLeastOnce()) ->method('fileExists') ->will($this->returnValue(false)); @@ -718,17 +718,17 @@ class ServiceTest extends \BBTestCase { public function testdownloadAndExtractThemeTypeException() { - $extensionMock = $this->getMockBuilder(\Box_Extension::class)->getMock(); + $extensionMock = $this->getMockBuilder('\Box_Extension')->getMock(); $extensionMock->expects($this->atLeastOnce()) ->method('getExtension') ->will($this->returnValue(array('download_url' => 'www.boxbillig.com'))); - $curlMock = $this->getMockBuilder(\Box_Curl::class)->disableOriginalConstructor()->getMock(); + $curlMock = $this->getMockBuilder('\Box_Curl')->disableOriginalConstructor()->getMock(); $curlMock->expects($this->atLeastOnce()) ->method('downloadTo'); - $zipArchiveMock = $this->getMockBuilder(\ZipArchive::class)->getMock(); + $zipArchiveMock = $this->getMockBuilder('ZipArchive')->getMock(); $zipArchiveMock->expects($this->atLeastOnce()) ->method('open') ->will($this->returnValue(TRUE)); @@ -739,7 +739,7 @@ class ServiceTest extends \BBTestCase { - $toolsMock = $this->getMockBuilder(\Box_tools::class)->getMock(); + $toolsMock = $this->getMockBuilder('\Box_tools')->getMock(); $toolsMock->expects($this->atLeastOnce()) ->method('fileExists') ->will($this->returnValue(false)); @@ -762,17 +762,17 @@ class ServiceTest extends \BBTestCase { public function testdownloadAndExtractRenameException() { - $extensionMock = $this->getMockBuilder(\Box_Extension::class)->getMock(); + $extensionMock = $this->getMockBuilder('\Box_Extension')->getMock(); $extensionMock->expects($this->atLeastOnce()) ->method('getExtension') ->will($this->returnValue(array('download_url' => 'www.boxbillig.com'))); - $curlMock = $this->getMockBuilder(\Box_Curl::class)->disableOriginalConstructor()->getMock(); + $curlMock = $this->getMockBuilder('\Box_Curl')->disableOriginalConstructor()->getMock(); $curlMock->expects($this->atLeastOnce()) ->method('downloadTo'); - $zipArchiveMock = $this->getMockBuilder(\ZipArchive::class)->getMock(); + $zipArchiveMock = $this->getMockBuilder('ZipArchive')->getMock(); $zipArchiveMock->expects($this->atLeastOnce()) ->method('open') ->will($this->returnValue(TRUE)); @@ -783,7 +783,7 @@ class ServiceTest extends \BBTestCase { - $toolsMock = $this->getMockBuilder(\Box_tools::class)->getMock(); + $toolsMock = $this->getMockBuilder('\Box_tools')->getMock(); $toolsMock->expects($this->atLeastOnce()) ->method('fileExists') ->will($this->returnValue(false)); @@ -806,17 +806,17 @@ class ServiceTest extends \BBTestCase { public function testdownloadAndExtractFileExistsException() { - $extensionMock = $this->getMockBuilder(\Box_Extension::class)->getMock(); + $extensionMock = $this->getMockBuilder('\Box_Extension')->getMock(); $extensionMock->expects($this->atLeastOnce()) ->method('getExtension') ->will($this->returnValue(array('download_url' => 'www.boxbillig.com'))); - $curlMock = $this->getMockBuilder(\Box_Curl::class)->disableOriginalConstructor()->getMock(); + $curlMock = $this->getMockBuilder('\Box_Curl')->disableOriginalConstructor()->getMock(); $curlMock->expects($this->atLeastOnce()) ->method('downloadTo'); - $zipArchiveMock = $this->getMockBuilder(\ZipArchive::class)->getMock(); + $zipArchiveMock = $this->getMockBuilder('ZipArchive')->getMock(); $zipArchiveMock->expects($this->atLeastOnce()) ->method('open') ->will($this->returnValue(TRUE)); @@ -827,7 +827,7 @@ class ServiceTest extends \BBTestCase { - $toolsMock = $this->getMockBuilder(\Box_tools::class)->getMock(); + $toolsMock = $this->getMockBuilder('\Box_tools')->getMock(); $toolsMock->expects($this->atLeastOnce()) ->method('fileExists') ->will($this->returnValue(true)); @@ -847,17 +847,17 @@ class ServiceTest extends \BBTestCase { public function testdownloadAndExtractExceptionExtract() { - $extensionMock = $this->getMockBuilder(\Box_Extension::class)->getMock(); + $extensionMock = $this->getMockBuilder('\Box_Extension')->getMock(); $extensionMock->expects($this->atLeastOnce()) ->method('getExtension') ->will($this->returnValue(array('download_url' => 'www.boxbillig.com'))); - $curlMock = $this->getMockBuilder(\Box_Curl::class)->disableOriginalConstructor()->getMock(); + $curlMock = $this->getMockBuilder('\Box_Curl')->disableOriginalConstructor()->getMock(); $curlMock->expects($this->atLeastOnce()) ->method('downloadTo'); - $zipArchiveMock = $this->getMockBuilder(\ZipArchive::class)->getMock(); + $zipArchiveMock = $this->getMockBuilder('ZipArchive')->getMock(); $zipArchiveMock->expects($this->atLeastOnce()) ->method('open') ->will($this->returnValue(false)); @@ -875,7 +875,7 @@ class ServiceTest extends \BBTestCase { public function testdownloadAndExtractDownloadUrlMisssing() { - $extensionMock = $this->getMockBuilder(\Box_Extension::class)->getMock(); + $extensionMock = $this->getMockBuilder('\Box_Extension')->getMock(); $extensionMock->expects($this->atLeastOnce()) ->method('getExtension') @@ -885,14 +885,13 @@ class ServiceTest extends \BBTestCase { $di['extension'] = $extensionMock; $this->service->setDi($di); - $this->expectException(\Exception::class); - $this->expectExceptionMessage('Extensions download url is not valid'); + $this->expectException('\Exception', 'Extensions download url is not valid'); $this->service->downloadAndExtract('mod', 'extensionId'); } public function testgetInstalledMods() { - $pdoStatment = $this->getMockBuilder(\Box\Mod\Extension\PdoStatmentsMock::class)->getMock(); + $pdoStatment = $this->getMockBuilder('\Box\Mod\Extension\PdoStatmentsMock')->getMock(); $pdoStatment->expects($this->atLeastOnce()) ->method('execute'); $pdoStatment->expects($this->atLeastOnce()) @@ -934,7 +933,7 @@ class ServiceTest extends \BBTestCase { ->method('activate') ->will($this->returnValue(array())); - $dbMock = $this->getMockBuilder(\Box_Database::class)->getMock(); + $dbMock = $this->getMockBuilder('\Box_Database')->getMock(); $dbMock->expects($this->atLeastOnce()) ->method('dispense') ->will($this->returnValue($model)); @@ -942,7 +941,7 @@ class ServiceTest extends \BBTestCase { ->method('store') ->will($this->returnValue(1)); - $eventMock = $this->getMockBuilder(\Box_EventManager::class)->getMock(); + $eventMock = $this->getMockBuilder('\Box_EventManager')->getMock(); $eventMock->expects($this->atLeastOnce())-> method('fire'); @@ -977,7 +976,7 @@ class ServiceTest extends \BBTestCase { ->method('activate') ->will($this->throwException(new \Exception())); - $eventMock = $this->getMockBuilder(\Box_EventManager::class)->getMock(); + $eventMock = $this->getMockBuilder('\Box_EventManager')->getMock(); $eventMock->expects($this->atLeastOnce())-> method('fire'); @@ -999,16 +998,16 @@ class ServiceTest extends \BBTestCase { $model = new \Model_ExtensionMeta(); $model->loadBean(new \RedBeanPHP\OODBBean()); - $dbMock = $this->getMockBuilder(\Box_Database::class)->getMock(); + $dbMock = $this->getMockBuilder('\Box_Database')->getMock(); $dbMock->expects($this->atLeastOnce()) ->method('findOne') ->will($this->returnValue($model)); - $cryptMock = $this->getMockBuilder(\Box_Crypt::class)->getMock(); + $cryptMock = $this->getMockBuilder('\Box_Crypt')->getMock(); $cryptMock->expects($this->atLeastOnce()) ->method('decrypt'); - $toolsMock = $this->getMockBuilder(\Box_Tools::class)->getMock(); + $toolsMock = $this->getMockBuilder('\Box_Tools')->getMock(); $toolsMock->expects($this->atLeastOnce()) ->method('decodeJ') ->will($this->returnValue(array())); @@ -1034,7 +1033,7 @@ class ServiceTest extends \BBTestCase { $model = new \Model_ExtensionMeta(); $model->loadBean(new \RedBeanPHP\OODBBean()); - $dbMock = $this->getMockBuilder(\Box_Database::class)->getMock(); + $dbMock = $this->getMockBuilder('\Box_Database')->getMock(); $dbMock->expects($this->atLeastOnce()) ->method('findOne') ->will($this->returnValue(null)); @@ -1061,26 +1060,26 @@ class ServiceTest extends \BBTestCase { 'ext' => 'extensionName', ); - $serviceMock = $this->getMockBuilder(\Box\Mod\Extension\Service::class)->setMethods(['getConfig'])->getMock(); + $serviceMock = $this->getMockBuilder('Box\Mod\Extension\Service')->setMethods(array('getConfig'))->getMock(); $serviceMock->expects($this->atLeastOnce()) ->method('getConfig') ->will($this->returnValue(array())); - $toolsMock = $this->getMockBuilder(\Box_Tools::class)->getMock(); + $toolsMock = $this->getMockBuilder('\Box_Tools')->getMock(); - $cryptMock = $this->getMockBuilder(\Box_Crypt::class)->getMock(); + $cryptMock = $this->getMockBuilder('\Box_Crypt')->getMock(); $cryptMock->expects($this->atLeastOnce()) ->method('encrypt') ->will($this->returnValue('encryptedConfig')); $model = new \Model_ExtensionMeta(); $model->loadBean(new \RedBeanPHP\OODBBean()); - $dbMock = $this->getMockBuilder(\Box_Database::class)->getMock(); + $dbMock = $this->getMockBuilder('\Box_Database')->getMock(); $dbMock->expects($this->atLeastOnce()) ->method('exec') ->will($this->returnValue(array())); - $eventMock = $this->getMockBuilder(\Box_EventManager::class)->getMock(); + $eventMock = $this->getMockBuilder('\Box_EventManager')->getMock(); $eventMock->expects($this->atLeastOnce())-> method('fire'); diff --git a/tests/bb-modules/System/ServiceTest.php b/tests/bb-modules/System/ServiceTest.php index 631434c54..2537af68a 100644 --- a/tests/bb-modules/System/ServiceTest.php +++ b/tests/bb-modules/System/ServiceTest.php @@ -277,7 +277,7 @@ class ServiceTest extends \BBTestCase { $twigMock->expects($this->atLeastOnce()) ->method('addGlobal'); $twigMock->method('createTemplate') - ->will($this->throwException(new \Error('Error'))); + ->will($this->throwException(new \Twig\Error\SyntaxError('SyntaxError'))); $dbMock = $this->getMockBuilder('\Box_Database')->getMock(); $dbMock->expects($this->atLeastOnce()) @@ -290,7 +290,7 @@ class ServiceTest extends \BBTestCase { $di['api_client'] = new \Model_Client(); $this->service->setDi($di); - $this->expectException(\Error::class); + $this->expectException(\Twig\Error\SyntaxError::class); $this->service->renderString('test', false, $vars); } @@ -304,8 +304,6 @@ class ServiceTest extends \BBTestCase { ->method('addGlobal'); $twigMock->method('createTemplate') ->willReturn(new \FakeTemplateWrapper('test')); - $twigMock->method('load') - ->willReturn(new \FakeTemplateWrapper('test')); $dbMock = $this->getMockBuilder('\Box_Database')->getMock(); $dbMock->expects($this->atLeastOnce())