1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-10 05:02:36 +01:00

fixes for tests

This commit is contained in:
David Bomba 2019-07-05 08:36:40 +10:00
parent 5b0cb2a218
commit 83f6a88cb3
8 changed files with 129 additions and 10 deletions

View File

@ -34,7 +34,7 @@ class StoreInvoiceRequest extends Request
return [
'client_id' => 'required',
'invoice_type_id' => 'integer',
// 'invoice_type_id' => 'integer',
// 'documents' => 'mimes:png,ai,svg,jpeg,tiff,pdf,gif,psd,txt,doc,xls,ppt,xlsx,docx,pptx',
];

View File

@ -36,7 +36,7 @@ class UpdateInvoiceRequest extends Request
return [
'documents' => 'mimes:png,ai,svg,jpeg,tiff,pdf,gif,psd,txt,doc,xls,ppt,xlsx,docx,pptx',
'client_id' => 'required|integer',
'invoice_type_id' => 'integer',
//'invoice_type_id' => 'integer',
];
}

113
app/Utils/SystemHealth.php Normal file
View File

@ -0,0 +1,113 @@
<?php
/**
* Invoice Ninja (https://invoiceninja.com)
*
* @link https://github.com/invoiceninja/invoiceninja source repository
*
* @copyright Copyright (c) 2019. Invoice Ninja LLC (https://invoiceninja.com)
*
* @license https://opensource.org/licenses/AAL
*/
namespace App\Utils;
use App\Libraries\MultiDB;
use Illuminate\Support\Facades\DB;
/**
* Class SystemHealth.
*/
class SystemHealth
{
private static $extensions = [
'mysqli',
'gd',
'curl',
'zip',
];
private static $php_version = 7.1;
/**
* Check loaded extensions / PHP version / DB Connections
*
* @return array Result set of checks
*/
public static function check() : array
{
$system_health = TRUE;
if (in_array(FALSE, self::extensions()))
{
$system_health = FALSE;
}
elseif (phpversion() < self::$php_version)
{
$system_health = FALSE;
}
return [
'system_health' => $system_health,
'extensions' => self::extensions(),
'php_version' => phpversion(),
'min_php_version' => self::$php_version,
'dbs' => self::dbCheck(),
];
}
private static function extensions() :array
{
$loaded_extensions = [];
foreach(self::$extensions as $extension)
{
$loaded_extensions[] = [$extension => extension_loaded($extension)];
}
return $loaded_extensions;
}
private static function dbCheck() :array
{
$result = [];
if (! config('ninja.db.multi_db_enabled'))
{
$pdo = DB::connection()->getPdo();
if($pdo)
$result[] = [ DB::connection()->getDatabaseName() => TRUE ];
else
$result[] = [ config('database.connections.' . config('database.default') . '.database') => FALSE ];
}
else
{
foreach (MultiDB::$dbs as $db)
{
MultiDB::setDB($db);
$pdo = DB::connection()->getPdo();
if($pdo)
$result[] = [ DB::connection()->getDatabaseName() => TRUE ];
else
$result[] = [ config('database.connections.' . config('database.default') . '.database') => FALSE ];
}
return $result;
}
}
}

View File

@ -179,6 +179,7 @@ class InvoiceTest extends TestCase
$response->assertStatus(200);
$invoice_update = [
'client_id' => $invoice->client_id,
'status_id' => Invoice::STATUS_PAID
];

View File

@ -12,6 +12,7 @@ use Illuminate\Database\Eloquent\Model;
use Illuminate\Foundation\Testing\DatabaseTransactions;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Foundation\Testing\WithFaker;
use Illuminate\Support\Carbon;
use Illuminate\Support\Facades\Log;
use Illuminate\Support\Facades\Session;
use Tests\TestCase;
@ -46,8 +47,8 @@ class PaymentTest extends TestCase
$data = [
'first_name' => $this->faker->firstName,
'last_name' => $this->faker->lastName,
'name' => $this->faker->company,
'email' => $this->faker->unique()->safeEmail,
'name' => $this->faker->company,
'email' => $this->faker->unique()->safeEmail,
'password' => 'ALongAndBrilliantPassword123',
'_token' => csrf_token(),
'privacy_policy' => 1,
@ -110,8 +111,8 @@ class PaymentTest extends TestCase
$data = [
'first_name' => $this->faker->firstName,
'last_name' => $this->faker->lastName,
'name' => $this->faker->company,
'email' => $this->faker->unique()->safeEmail,
'name' => $this->faker->company,
'email' => $this->faker->unique()->safeEmail,
'password' => 'ALongAndBrilliantPassword123',
'_token' => csrf_token(),
'privacy_policy' => 1,
@ -176,7 +177,8 @@ class PaymentTest extends TestCase
$response->assertStatus(200);
$Payment_update = [
'amount' => 10
'amount' => 10,
'payment_date' => Carbon::now()
];
$this->assertNotNull($Payment);

View File

@ -178,7 +178,8 @@ class QuoteTest extends TestCase
$response->assertStatus(200);
$quote_update = [
'status_id' => Quote::STATUS_APPROVED
'status_id' => Quote::STATUS_APPROVED,
'client_id' => $quote->client_id,
];
$this->assertNotNull($quote);

View File

@ -179,7 +179,8 @@ Log::error($acc);
$response->assertStatus(200);
$RecurringInvoice_update = [
'status_id' => RecurringInvoice::STATUS_DRAFT
'status_id' => RecurringInvoice::STATUS_DRAFT,
'client_id' => $RecurringInvoice->client_id,
];
$this->assertNotNull($RecurringInvoice);

View File

@ -179,7 +179,8 @@ class RecurringQuoteTest extends TestCase
$response->assertStatus(200);
$RecurringQuote_update = [
'status_id' => RecurringQuote::STATUS_DRAFT
'status_id' => RecurringQuote::STATUS_DRAFT,
'client_id' => $RecurringQuote->client_id,
];
$this->assertNotNull($RecurringQuote);