1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-10 13:12:50 +01:00

Merge pull request #7238 from turbo124/v5-develop

Fixes for tests
This commit is contained in:
David Bomba 2022-02-26 23:26:07 +11:00 committed by GitHub
commit fbf4ecdf5f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
24 changed files with 45 additions and 29 deletions

View File

@ -1 +1 @@
5.3.61
5.3.62

View File

@ -310,7 +310,7 @@ class LoginController extends BaseController
*/
public function refresh(Request $request)
{
$company_token = CompanyToken::whereRaw('BINARY `token`= ?', [$request->header('X-API-TOKEN')])->first();
$company_token = CompanyToken::where('token', $request->header('X-API-TOKEN'))->first();
$cu = CompanyUser::query()
->where('user_id', $company_token->user_id);

View File

@ -45,10 +45,15 @@ class EntityViewController extends Controller
$key = $entity_type.'_id';
$invitation = $invitation_entity::whereRaw('BINARY `key`= ?', [$invitation_key])
$invitation = $invitation_entity::where('key', $invitation_key)
->with('contact.client')
->firstOrFail();
// $invitation = $invitation_entity::whereRaw('BINARY `key`= ?', [$invitation_key])
// ->with('contact.client')
// ->firstOrFail();
$contact = $invitation->contact;
$client = $contact->client;
$entity = $invitation->{$entity_type};
@ -105,7 +110,8 @@ class EntityViewController extends Controller
$key = $entity_type.'_id';
$invitation = $invitation_entity::whereRaw('BINARY `key`= ?', [$invitation_key])->firstOrFail();
$invitation = $invitation_entity::where('key', $invitation_key)->firstOrFail();
// $invitation = $invitation_entity::whereRaw('BINARY `key`= ?', [$invitation_key])->firstOrFail();
$contact = $invitation->contact;

View File

@ -181,10 +181,6 @@ class InvitationController extends Controller
$entity_obj = 'App\Models\\'.ucfirst(Str::camel($entity)).'Invitation';
// $invitation = $entity_obj::whereRaw('BINARY `key`= ?', [$invitation_key])
// ->with('contact.client')
// ->firstOrFail();
$invitation = $entity_obj::where('key', $invitation_key)
->with('contact.client')
->firstOrFail();

View File

@ -114,7 +114,7 @@ class PaymentController extends Controller
public function credit_response(Request $request)
{
$payment_hash = PaymentHash::whereRaw('BINARY `hash`= ?', [$request->input('payment_hash')])->first();
$payment_hash = PaymentHash::where('hash', $request->input('payment_hash'))->first();
/* Hydrate the $payment */
if ($payment_hash->payment()->exists()) {

View File

@ -29,7 +29,7 @@ class ContactTokenAuth
*/
public function handle($request, Closure $next)
{
if ($request->header('X-API-TOKEN') && ($client_contact = ClientContact::with(['company'])->whereRaw('BINARY `token`= ?', [$request->header('X-API-TOKEN')])->first())) {
if ($request->header('X-API-TOKEN') && ($client_contact = ClientContact::with(['company'])->where('token', $request->header('X-API-TOKEN'))->first())) {
$error = [
'message' => 'Authentication disabled for user.',
'errors' => new stdClass,

View File

@ -30,7 +30,7 @@ class TokenAuth
*/
public function handle($request, Closure $next)
{
if ($request->header('X-API-TOKEN') && ($company_token = CompanyToken::with(['user', 'company'])->whereRaw('BINARY `token`= ?', [$request->header('X-API-TOKEN')])->first())) {
if ($request->header('X-API-TOKEN') && ($company_token = CompanyToken::with(['user', 'company'])->where('token', $request->header('X-API-TOKEN'))->first())) {
$user = $company_token->user;
$error = [

View File

@ -34,7 +34,7 @@ class PaymentResponseRequest extends FormRequest
{
$input = $this->all();
return PaymentHash::whereRaw('BINARY `hash`= ?', [$input['payment_hash']])->first();
return PaymentHash::where('hash', $input['payment_hash'])->first();
}
public function shouldStoreToken(): bool

View File

@ -205,7 +205,7 @@ class MultiDB
$current_db = config('database.default');
foreach (self::$dbs as $db) {
if (ClientContact::on($db)->whereRaw('BINARY `token`= ?', [$token])->exists()) {
if (ClientContact::on($db)->where('token', $token)->exists()) {
self::setDb($db);
return true;
}
@ -257,7 +257,7 @@ class MultiDB
$current_db = config('database.default');
foreach (self::$dbs as $db) {
if (CompanyToken::on($db)->whereRaw('BINARY `token`= ?', [$token])->exists()) {
if (CompanyToken::on($db)->where('token', $token)->exists()) {
self::setDb($db);
return true;
}

View File

@ -97,7 +97,7 @@ class TemplateEmail extends Mailable
'footer' => $this->build_email->getFooter(),
'whitelabel' => $this->client->user->account->isPaid() ? true : false,
'settings' => $settings,
'unsubscribe_link' => $this->invitation->getUnsubscribeLink(),
'unsubscribe_link' => $this->invitation ? $this->invitation->getUnsubscribeLink() : '',
])
->view($template_name, [
'greeting' => ctrans('texts.email_salutation', ['name' => $this->contact->present()->name()]),

View File

@ -177,7 +177,7 @@ class User extends Authenticatable implements MustVerifyEmail
}
elseif (request()->header('X-API-TOKEN')) {
$company_token = CompanyToken::with(['company'])->whereRaw('BINARY `token`= ?', [request()->header('X-API-TOKEN')])->first();
$company_token = CompanyToken::with(['company'])->where('token', request()->header('X-API-TOKEN'))->first();
return $company_token->company;
}

View File

@ -223,7 +223,7 @@ class AuthorizeCreditCard
private function processSuccessfulResponse($data, $request)
{
$payment_hash = PaymentHash::whereRaw('BINARY `hash`= ?', [$request->input('payment_hash')])->firstOrFail();
$payment_hash = PaymentHash::where('hash', $request->input('payment_hash'))->firstOrFail();
$payment = $this->storePayment($payment_hash, $data);
$vars = [

View File

@ -224,7 +224,7 @@ class PayFastPaymentDriver extends BaseDriver
default:
$payment_hash = PaymentHash::whereRaw('BINARY `hash`= ?', [$data['m_payment_id']])->first();
$payment_hash = PaymentHash::where('hash', $data['m_payment_id'])->first();
$this->setPaymentMethod(GatewayType::CREDIT_CARD)
->setPaymentHash($payment_hash)

View File

@ -142,7 +142,7 @@ class BaseRepository
$invitation_class = sprintf('App\\Models\\%sInvitation', $resource);
$invitation = $invitation_class::whereRaw('BINARY `key`= ?', [$invitation['key']])->first();
$invitation = $invitation_class::where('key', $invitation['key'])->first();
return $invitation;
}

View File

@ -42,6 +42,6 @@ class CreditRepository extends BaseRepository
public function getInvitationByKey($key) :?CreditInvitation
{
return CreditInvitation::whereRaw('BINARY `key`= ?', [$key])->first();
return CreditInvitation::where('key', $key)->first();
}
}

View File

@ -50,7 +50,7 @@ class InvoiceRepository extends BaseRepository
public function getInvitationByKey($key) :?InvoiceInvitation
{
return InvoiceInvitation::whereRaw('BINARY `key`= ?', [$key])->first();
return InvoiceInvitation::where('key', $key)->first();
}
/**

View File

@ -26,6 +26,6 @@ class QuoteRepository extends BaseRepository
public function getInvitationByKey($key) :?QuoteInvitation
{
return QuoteInvitation::whereRaw('BINARY `key`= ?', [$key])->first();
return QuoteInvitation::where('key', $key)->first();
}
}

View File

@ -30,6 +30,6 @@ class RecurringInvoiceRepository extends BaseRepository
public function getInvitationByKey($key) :?RecurringInvoiceInvitation
{
return RecurringInvoiceInvitation::whereRaw('BINARY `key`= ?', [$key])->first();
return RecurringInvoiceInvitation::where('key', $key)->first();
}
}

View File

@ -96,7 +96,7 @@ class UserTransformer extends EntityTransformer
public function includeCompanyUser(User $user)
{
if (!$user->company_id && request()->header('X-API-TOKEN')) {
$company_token = CompanyToken::whereRaw('BINARY `token`= ?', [request()->header('X-API-TOKEN')])->first();
$company_token = CompanyToken::where('token', request()->header('X-API-TOKEN'))->first();
$user->company_id = $company_token->company_id;
}

View File

@ -169,7 +169,7 @@ class Phantom
$key = $entity.'_id';
$invitation_instance = 'App\Models\\'.ucfirst(Str::camel($entity)).'Invitation';
$invitation = $invitation_instance::whereRaw('BINARY `key`= ?', [$invitation_key])->first();
$invitation = $invitation_instance::where('key', $invitation_key)->first();
$entity_obj = $invitation->{$entity};

View File

@ -14,8 +14,8 @@ return [
'require_https' => env('REQUIRE_HTTPS', true),
'app_url' => rtrim(env('APP_URL', ''), '/'),
'app_domain' => env('APP_DOMAIN', 'invoicing.co'),
'app_version' => '5.3.61',
'app_tag' => '5.3.61',
'app_version' => '5.3.62',
'app_tag' => '5.3.62',
'minimum_client_version' => '5.0.16',
'terms_version' => '1.0.1',
'api_secret' => env('API_SECRET', ''),

View File

@ -37,6 +37,10 @@ CREATE TABLE `accounts` (
`is_onboarding` tinyint(1) NOT NULL DEFAULT '0',
`onboarding` mediumtext COLLATE utf8mb4_unicode_ci,
`is_migrated` tinyint(1) NOT NULL DEFAULT '0',
`platform` varchar(128) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`hosted_client_count` int(10) unsigned DEFAULT NULL,
`hosted_company_count` int(10) unsigned DEFAULT NULL,
`inapp_transaction_id` varchar(100) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `accounts_payment_id_index` (`payment_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci ROW_FORMAT=COMPRESSED KEY_BLOCK_SIZE=8;
@ -385,6 +389,7 @@ CREATE TABLE `companies` (
`use_comma_as_decimal_place` tinyint(1) NOT NULL DEFAULT '0',
`report_include_drafts` tinyint(1) NOT NULL DEFAULT '0',
`client_registration_fields` mediumtext COLLATE utf8mb4_unicode_ci,
`convert_rate_to_client` tinyint(1) NOT NULL DEFAULT '1',
PRIMARY KEY (`id`),
UNIQUE KEY `companies_company_key_unique` (`company_key`),
KEY `companies_industry_id_foreign` (`industry_id`),
@ -2116,3 +2121,12 @@ INSERT INTO `migrations` VALUES (113,'2021_11_08_131308_onboarding',6);
INSERT INTO `migrations` VALUES (114,'2021_11_09_115919_update_designs',6);
INSERT INTO `migrations` VALUES (115,'2021_11_10_184847_add_is_migrate_column_to_accounts_table',6);
INSERT INTO `migrations` VALUES (116,'2021_11_11_163121_add_instant_bank_transfer',7);
INSERT INTO `migrations` VALUES (117,'2021_12_20_095542_add_serbian_language_translations',8);
INSERT INTO `migrations` VALUES (118,'2022_01_02_022421_add_slovak_language',8);
INSERT INTO `migrations` VALUES (119,'2022_01_06_061231_add_app_domain_id_to_gateways_table',8);
INSERT INTO `migrations` VALUES (120,'2022_01_18_004856_add_estonian_language',8);
INSERT INTO `migrations` VALUES (121,'2022_01_19_085907_add_platform_column_to_accounts_table',8);
INSERT INTO `migrations` VALUES (122,'2022_01_19_232436_add_kyd_currency',8);
INSERT INTO `migrations` VALUES (123,'2022_01_27_223617_add_client_count_to_accounts_table',8);
INSERT INTO `migrations` VALUES (124,'2022_02_06_091629_add_client_currency_conversion_to_companies_table',8);
INSERT INTO `migrations` VALUES (125,'2022_02_25_015411_update_stripe_apple_domain_config',9);

View File

@ -121,7 +121,7 @@ class MultiPaymentDeleteTest extends TestCase
$this->assertEquals(0, $invoice->balance);
//mark sent
$invoice = $invoice->service()->markSent()->save();
$invoice = $invoice->service()->markSent()->createInvitations()->save();
$invoice->fresh();
$invoice->client->fresh();

View File

@ -297,7 +297,7 @@ class PaymentTest extends TestCase
$this->invoice = $this->invoice_calc->getInvoice();
$this->invoice->save();
$this->invoice->service()->markSent()->save();
$this->invoice->service()->markSent()->createInvitations()->save();
$data = [
'amount' => 2.0,