Merge pull request #6 from timothygwebb/revert-5-master

Revert "Updating my branch with master"
This commit is contained in:
Mr. Timothy G Webb Sr authored and GitHub committed 2020-09-28 01:46:28 -04:00
commit 97e7e9f250
16 files changed
+151 -398

No files matched your search

-1
View File
@@ -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'];
+1
View File
@@ -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(
@@ -1,249 +0,0 @@
<?php
/**
* BoxBilling
*
* @copyright BoxBilling, Inc (http://www.boxbilling.com)
* @license Apache-2.0
*
* Copyright BoxBilling, Inc
* This source file is subject to the Apache-2.0 License that is bundled
* with this source code in the file LICENSE
*/
class Payment_Adapter_SimplePay implements \Box\InjectionAwareInterface
{
private $config = array();
protected $di;
public function setDi($di)
{
$this->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 = '<form action=":callbackUrl" method="POST" class="api_form" data-api-redirect=":redirectUrl">
<div class="loading" style="display:none;"><span>{% trans \'Loading ...\' %}</span></div>
<script src="https://checkout.simplepay.ng/simplepay.js"></script>
<script>
var handler = SimplePay.configure({
token: handleTokenCall,
key: \':key\',
image: ":image",
});
function handleTokenCall(token){
form = $(".api_form");
form.append($(\'<input type="hidden" name="simplePayToken" />\').val(token));
form.submit();
}
</script>
<script>
function openHandler(){
handler.open(SimplePay.CHECKOUT, {
email: ":email",
phone: ":phone",
description: ":description",
address: ":address",
postal_code: ":postal",
city: ":city",
country: ":country",
amount: ":amount",
currency: ":currency"
});
};
$(document).ready ( function(){
openHandler();
});
document.addEventListener("bb_ajax_post_message_error", function(e) {
openHandler();
});
</script>
</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'];
}
}
@@ -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);
+41
View File
@@ -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);
}
?>
+5 -7
View File
@@ -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));
}
}
}
@@ -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
);
}
*/
}
}
@@ -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);
@@ -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',
+1 -1
View File
@@ -680,4 +680,4 @@ class Service implements InjectionAwareInterface
return $this->di['auth']->authorizeUser($model, $plainTextPassword);
}
}
}
+2
View File
@@ -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) {
@@ -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;
}
Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.8 KiB

+53 -54
View File
@@ -1,54 +1,53 @@
{
"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" }
}
}
{
"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" }
}
}
+41 -42
View File
@@ -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');
+2 -4
View File
@@ -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())