1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-09-21 08:51:34 +02:00

Merge pull request #5345 from turbo124/v5-develop

PHP 8 support
This commit is contained in:
David Bomba 2021-04-06 14:02:56 +10:00 committed by GitHub
commit d385488ccb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 212 additions and 145 deletions

View File

@ -13,7 +13,7 @@ jobs:
strategy:
matrix:
operating-system: ['ubuntu-18.04', 'ubuntu-20.04']
php-versions: ['7.4']
php-versions: ['7.3','7.4','8.0']
phpunit-versions: ['latest']
env:

View File

@ -34,6 +34,7 @@ use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\SerializesModels;
use Illuminate\Support\Facades\Mail;
use Illuminate\Support\Str;
use Illuminate\Support\Facades\App;
/*Multi Mailer implemented*/
@ -104,6 +105,9 @@ class EmailEntity implements ShouldQueue
/* Set DB */
MultiDB::setDB($this->company->db);
App::setLocale($this->invitation->contact->preferredLocale());
$nmo = new NinjaMailerObject;
$nmo->mailable = new TemplateEmail($this->email_entity_builder,$this->invitation->contact, $this->invitation);
$nmo->company = $this->company;

View File

@ -53,6 +53,7 @@ class Account extends BaseModel
'deleted_at',
'promo_expires',
'discount_expires',
'trial_started',
];
const PLAN_FREE = 'free';
@ -238,14 +239,19 @@ class Account extends BaseModel
}
$trial_active = false;
if ($trial_plan && $include_trial) {
$trial_started = DateTime::createFromFormat('Y-m-d', $this->trial_started);
$trial_expires = clone $trial_started;
$trial_expires->modify('+2 weeks');
if ($trial_expires >= date_create()) {
if ($trial_plan && $include_trial) {
$trial_started = $this->trial_started;
$trial_expires = $this->trial_started->addSeconds($this->trial_duration);
// $trial_expires->modify('+2 weeks');
if($trial_expires->greaterThan(now())){
$trial_active = true;
}
}
// if ($trial_expires >= date_create()) {
// $trial_active = true;
// }
}
$plan_active = false;
@ -265,6 +271,7 @@ class Account extends BaseModel
return null;
}
// Should we show plan details or trial details?
if (($plan && ! $trial_plan) || ! $include_trial) {
$use_plan = true;

View File

@ -220,14 +220,14 @@ trait CompanySettingsSaver
switch ($key) {
case 'int':
case 'integer':
return ctype_digit(strval(abs($value)));
return ctype_digit(strval(abs((int)$value)));
// return is_int($value) || ctype_digit(strval(abs($value)));
case 'real':
case 'float':
case 'double':
return is_float($value) || is_numeric(strval($value));
case 'string':
return method_exists($value, '__toString') || is_null($value) || is_string($value);
return (is_string($value) && method_exists($value, '__toString')) || is_null($value) || is_string($value);
//return is_null($value) || is_string($value);
case 'bool':
case 'boolean':

View File

@ -26,7 +26,7 @@
],
"type": "project",
"require": {
"php": "^7.3|^7.4",
"php": "^7.3|^7.4|^8.0",
"ext-dom": "*",
"ext-json": "*",
"ext-libxml": "*",
@ -38,7 +38,7 @@
"coconutcraig/laravel-postmark": "^2.10",
"composer/composer": "^2",
"czproject/git-php": "^3.17",
"dacastro4/laravel-gmail": "^5.1",
"turbo124/laravel-gmail": "^5",
"doctrine/dbal": "^2.10",
"fideloper/proxy": "^4.2",
"fzaninotto/faker": "^1.4",
@ -71,7 +71,7 @@
"wildbit/swiftmailer-postmark": "^3.3"
},
"require-dev": {
"php": "^7.3|^7.4",
"php": "^7.3|^7.4|^8.0",
"anahkiasen/former": "^4.2",
"barryvdh/laravel-debugbar": "^3.4",
"brianium/paratest": "^6.1",

255
composer.lock generated
View File

@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "2307a2f3214da0d1cc772cc1a1405682",
"content-hash": "feb70f976b798dde6550a7b5439bb191",
"packages": [
{
"name": "authorizenet/authorizenet",
@ -51,16 +51,16 @@
},
{
"name": "aws/aws-sdk-php",
"version": "3.176.5",
"version": "3.176.8",
"source": {
"type": "git",
"url": "https://github.com/aws/aws-sdk-php.git",
"reference": "45d69a8da4f55879f8a24b0b659a5bc7ad077725"
"reference": "776b944988167fa3d563d2cbc5fcb6763424a9f0"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/aws/aws-sdk-php/zipball/45d69a8da4f55879f8a24b0b659a5bc7ad077725",
"reference": "45d69a8da4f55879f8a24b0b659a5bc7ad077725",
"url": "https://api.github.com/repos/aws/aws-sdk-php/zipball/776b944988167fa3d563d2cbc5fcb6763424a9f0",
"reference": "776b944988167fa3d563d2cbc5fcb6763424a9f0",
"shasum": ""
},
"require": {
@ -135,9 +135,9 @@
"support": {
"forum": "https://forums.aws.amazon.com/forum.jspa?forumID=80",
"issues": "https://github.com/aws/aws-sdk-php/issues",
"source": "https://github.com/aws/aws-sdk-php/tree/3.176.5"
"source": "https://github.com/aws/aws-sdk-php/tree/3.176.8"
},
"time": "2021-03-31T18:15:22+00:00"
"time": "2021-04-05T18:16:29+00:00"
},
{
"name": "bacon/bacon-qr-code",
@ -641,16 +641,16 @@
},
{
"name": "composer/composer",
"version": "2.0.11",
"version": "2.0.12",
"source": {
"type": "git",
"url": "https://github.com/composer/composer.git",
"reference": "a5a5632da0b1c2d6fa9a3b65f1f4e90d1f04abb9"
"reference": "6c12ce263da71641903e399c3ce8ecb08fd375fb"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/composer/composer/zipball/a5a5632da0b1c2d6fa9a3b65f1f4e90d1f04abb9",
"reference": "a5a5632da0b1c2d6fa9a3b65f1f4e90d1f04abb9",
"url": "https://api.github.com/repos/composer/composer/zipball/6c12ce263da71641903e399c3ce8ecb08fd375fb",
"reference": "6c12ce263da71641903e399c3ce8ecb08fd375fb",
"shasum": ""
},
"require": {
@ -718,7 +718,7 @@
"support": {
"irc": "irc://irc.freenode.org/composer",
"issues": "https://github.com/composer/composer/issues",
"source": "https://github.com/composer/composer/tree/2.0.11"
"source": "https://github.com/composer/composer/tree/2.0.12"
},
"funding": [
{
@ -734,7 +734,7 @@
"type": "tidelift"
}
],
"time": "2021-02-24T13:57:23+00:00"
"time": "2021-04-01T08:14:59+00:00"
},
{
"name": "composer/semver",
@ -1006,76 +1006,6 @@
},
"time": "2021-02-15T11:41:33+00:00"
},
{
"name": "dacastro4/laravel-gmail",
"version": "v5.1",
"source": {
"type": "git",
"url": "https://github.com/dacastro4/laravel-gmail.git",
"reference": "6d4cabe04f8cdd02b25ef73a1a489099b5e790bd"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/dacastro4/laravel-gmail/zipball/6d4cabe04f8cdd02b25ef73a1a489099b5e790bd",
"reference": "6d4cabe04f8cdd02b25ef73a1a489099b5e790bd",
"shasum": ""
},
"require": {
"google/apiclient": "^2.5",
"illuminate/auth": "~5.8|^6.0|^7.0|^8.0",
"illuminate/config": "~5.8|^6.0|^7.0|^8.0",
"illuminate/database": "~5.8|^6.0|^7.0|^8.0",
"illuminate/routing": "~5.8|^6.0|^7.0|^8.0",
"illuminate/session": "~5.8|^6.0|^7.0|^8.0",
"illuminate/support": "~5.8|^6.0|^7.0|^8.0",
"php": "^7.2",
"swiftmailer/swiftmailer": "~5.8|^6.0"
},
"require-dev": {
"mockery/mockery": "^1.0",
"orchestra/testbench": "^4.0",
"phpunit/phpunit": "^8.5",
"squizlabs/php_codesniffer": "~3.4"
},
"type": "library",
"extra": {
"laravel": {
"providers": [
"Dacastro4\\LaravelGmail\\LaravelGmailServiceProvider"
],
"aliases": {
"LaravelGmail": "Dacastro4\\LaravelGmail\\Facade\\LaravelGmail"
}
}
},
"autoload": {
"psr-4": {
"Dacastro4\\LaravelGmail\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Daniel Castro",
"email": "danielcastro04@gmail.com",
"homepage": "https://danielcastro.me"
}
],
"description": "Gmail API package for Laravel",
"keywords": [
"api",
"gmail",
"laravel"
],
"support": {
"issues": "https://github.com/dacastro4/laravel-gmail/issues",
"source": "https://github.com/dacastro4/laravel-gmail/tree/v5.1"
},
"time": "2020-12-13T19:17:07+00:00"
},
{
"name": "dasprid/enum",
"version": "1.0.3",
@ -1921,26 +1851,27 @@
},
{
"name": "fzaninotto/faker",
"version": "v1.9.2",
"version": "dev-master",
"source": {
"type": "git",
"url": "https://github.com/fzaninotto/Faker.git",
"reference": "848d8125239d7dbf8ab25cb7f054f1a630e68c2e"
"reference": "5ffe7db6c80f441f150fc88008d64e64af66634b"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/fzaninotto/Faker/zipball/848d8125239d7dbf8ab25cb7f054f1a630e68c2e",
"reference": "848d8125239d7dbf8ab25cb7f054f1a630e68c2e",
"url": "https://api.github.com/repos/fzaninotto/Faker/zipball/5ffe7db6c80f441f150fc88008d64e64af66634b",
"reference": "5ffe7db6c80f441f150fc88008d64e64af66634b",
"shasum": ""
},
"require": {
"php": "^5.3.3 || ^7.0"
"php": "^5.3.3 || ^7.0 || ^8.0"
},
"require-dev": {
"ext-intl": "*",
"phpunit/phpunit": "^4.8.35 || ^5.7",
"squizlabs/php_codesniffer": "^2.9.2"
},
"default-branch": true,
"type": "library",
"extra": {
"branch-alias": {
@ -1969,10 +1900,10 @@
],
"support": {
"issues": "https://github.com/fzaninotto/Faker/issues",
"source": "https://github.com/fzaninotto/Faker/tree/v1.9.2"
"source": "https://github.com/fzaninotto/Faker/tree/master"
},
"abandoned": true,
"time": "2020-12-11T09:56:16+00:00"
"time": "2020-12-11T09:59:14+00:00"
},
{
"name": "google/apiclient",
@ -2045,7 +1976,7 @@
},
{
"name": "google/apiclient-services",
"version": "v0.166.0",
"version": "v0.167.0",
"source": {
"type": "git",
"url": "https://github.com/googleapis/google-api-php-client-services.git",
@ -2080,7 +2011,7 @@
],
"support": {
"issues": "https://github.com/googleapis/google-api-php-client-services/issues",
"source": "https://github.com/googleapis/google-api-php-client-services/tree/v0.166.0"
"source": "https://github.com/googleapis/google-api-php-client-services/tree/v0.167.0"
},
"time": "2021-03-22T11:26:04+00:00"
},
@ -3824,27 +3755,28 @@
},
{
"name": "league/omnipay",
"version": "v3.1.0",
"version": "dev-master",
"source": {
"type": "git",
"url": "https://github.com/thephpleague/omnipay.git",
"reference": "1ba7c8a3312cf2342458b99c9e5b86eaae44aed2"
"reference": "e9439db0633ba988e6f6cdd029fad38aad73f9f6"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/thephpleague/omnipay/zipball/1ba7c8a3312cf2342458b99c9e5b86eaae44aed2",
"reference": "1ba7c8a3312cf2342458b99c9e5b86eaae44aed2",
"url": "https://api.github.com/repos/thephpleague/omnipay/zipball/e9439db0633ba988e6f6cdd029fad38aad73f9f6",
"reference": "e9439db0633ba988e6f6cdd029fad38aad73f9f6",
"shasum": ""
},
"require": {
"omnipay/common": "^3",
"php": "^7.2",
"php": "^7.2|^8.0",
"php-http/discovery": "^1.12",
"php-http/guzzle7-adapter": "^0.1"
},
"require-dev": {
"omnipay/tests": "^3"
},
"default-branch": true,
"type": "metapackage",
"extra": {
"branch-alias": {
@ -3875,22 +3807,22 @@
],
"support": {
"issues": "https://github.com/thephpleague/omnipay/issues",
"source": "https://github.com/thephpleague/omnipay/tree/v3.1.0"
"source": "https://github.com/thephpleague/omnipay/tree/master"
},
"time": "2020-09-22T14:02:17+00:00"
"time": "2021-03-12T09:17:59+00:00"
},
{
"name": "livewire/livewire",
"version": "v2.4.1",
"version": "v2.4.2",
"source": {
"type": "git",
"url": "https://github.com/livewire/livewire.git",
"reference": "b0cb782674673a67ddfd5910d2fcb5308bb32857"
"reference": "2495387841a3eb03ac62b2c984ccd2574303285b"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/livewire/livewire/zipball/b0cb782674673a67ddfd5910d2fcb5308bb32857",
"reference": "b0cb782674673a67ddfd5910d2fcb5308bb32857",
"url": "https://api.github.com/repos/livewire/livewire/zipball/2495387841a3eb03ac62b2c984ccd2574303285b",
"reference": "2495387841a3eb03ac62b2c984ccd2574303285b",
"shasum": ""
},
"require": {
@ -3941,7 +3873,7 @@
"description": "A front-end framework for Laravel.",
"support": {
"issues": "https://github.com/livewire/livewire/issues",
"source": "https://github.com/livewire/livewire/tree/v2.4.1"
"source": "https://github.com/livewire/livewire/tree/v2.4.2"
},
"funding": [
{
@ -3949,7 +3881,7 @@
"type": "github"
}
],
"time": "2021-03-22T14:03:36+00:00"
"time": "2021-04-04T15:46:50+00:00"
},
{
"name": "maennchen/zipstream-php",
@ -4628,21 +4560,21 @@
},
{
"name": "omnipay/common",
"version": "v3.0.5",
"version": "dev-master",
"source": {
"type": "git",
"url": "https://github.com/thephpleague/omnipay-common.git",
"reference": "0d1f4486c1c873537ac030d37c7ce2986c4de1d2"
"reference": "e1ebc22615f14219d31cefdf62d7036feb228b1c"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/thephpleague/omnipay-common/zipball/0d1f4486c1c873537ac030d37c7ce2986c4de1d2",
"reference": "0d1f4486c1c873537ac030d37c7ce2986c4de1d2",
"url": "https://api.github.com/repos/thephpleague/omnipay-common/zipball/e1ebc22615f14219d31cefdf62d7036feb228b1c",
"reference": "e1ebc22615f14219d31cefdf62d7036feb228b1c",
"shasum": ""
},
"require": {
"moneyphp/money": "^3.1",
"php": "^5.6|^7",
"php": "^5.6|^7|^8",
"php-http/client-implementation": "^1",
"php-http/discovery": "^1.2.1",
"php-http/message": "^1.5",
@ -4657,6 +4589,7 @@
"suggest": {
"league/omnipay": "The default Omnipay package provides a default HTTP Adapter."
},
"default-branch": true,
"type": "library",
"extra": {
"branch-alias": {
@ -4708,9 +4641,9 @@
],
"support": {
"issues": "https://github.com/thephpleague/omnipay-common/issues",
"source": "https://github.com/thephpleague/omnipay-common/tree/v3.0.5"
"source": "https://github.com/thephpleague/omnipay-common/tree/master"
},
"time": "2020-08-20T18:22:12+00:00"
"time": "2020-12-13T12:53:48+00:00"
},
{
"name": "omnipay/paypal",
@ -5645,23 +5578,22 @@
},
{
"name": "predis/predis",
"version": "v1.1.6",
"version": "v1.1.7",
"source": {
"type": "git",
"url": "https://github.com/predis/predis.git",
"reference": "9930e933c67446962997b05201c69c2319bf26de"
"reference": "b240daa106d4e02f0c5b7079b41e31ddf66fddf8"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/predis/predis/zipball/9930e933c67446962997b05201c69c2319bf26de",
"reference": "9930e933c67446962997b05201c69c2319bf26de",
"url": "https://api.github.com/repos/predis/predis/zipball/b240daa106d4e02f0c5b7079b41e31ddf66fddf8",
"reference": "b240daa106d4e02f0c5b7079b41e31ddf66fddf8",
"shasum": ""
},
"require": {
"php": ">=5.3.9"
},
"require-dev": {
"cweagans/composer-patches": "^1.6",
"phpunit/phpunit": "~4.8"
},
"suggest": {
@ -5669,18 +5601,6 @@
"ext-phpiredis": "Allows faster serialization and deserialization of the Redis protocol"
},
"type": "library",
"extra": {
"composer-exit-on-patch-failure": true,
"patches": {
"phpunit/phpunit-mock-objects": {
"Fix PHP 7 and 8 compatibility": "./tests/phpunit_mock_objects.patch"
},
"phpunit/phpunit": {
"Fix PHP 7 compatibility": "./tests/phpunit_php7.patch",
"Fix PHP 8 compatibility": "./tests/phpunit_php8.patch"
}
}
},
"autoload": {
"psr-4": {
"Predis\\": "src/"
@ -5712,7 +5632,7 @@
],
"support": {
"issues": "https://github.com/predis/predis/issues",
"source": "https://github.com/predis/predis/tree/v1.1.6"
"source": "https://github.com/predis/predis/tree/v1.1.7"
},
"funding": [
{
@ -5720,7 +5640,7 @@
"type": "github"
}
],
"time": "2020-09-11T19:18:05+00:00"
"time": "2021-04-04T19:34:46+00:00"
},
{
"name": "psr/cache",
@ -9761,6 +9681,75 @@
},
"time": "2021-03-23T09:54:29+00:00"
},
{
"name": "turbo124/laravel-gmail",
"version": "v5.0.1",
"source": {
"type": "git",
"url": "https://github.com/turbo124/laravel-gmail.git",
"reference": "55ca0271a54a568ebaa26febbe0790b2ce5ac966"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/turbo124/laravel-gmail/zipball/55ca0271a54a568ebaa26febbe0790b2ce5ac966",
"reference": "55ca0271a54a568ebaa26febbe0790b2ce5ac966",
"shasum": ""
},
"require": {
"google/apiclient": "^2.5",
"illuminate/auth": "~5.8|^6.0|^7.0|^8.0",
"illuminate/config": "~5.8|^6.0|^7.0|^8.0",
"illuminate/database": "~5.8|^6.0|^7.0|^8.0",
"illuminate/routing": "~5.8|^6.0|^7.0|^8.0",
"illuminate/session": "~5.8|^6.0|^7.0|^8.0",
"illuminate/support": "~5.8|^6.0|^7.0|^8.0",
"php": "^7.3|^7.4|^8.0",
"swiftmailer/swiftmailer": "~5.8|^6.0"
},
"require-dev": {
"mockery/mockery": "^1.0",
"orchestra/testbench": "^4.0",
"phpunit/phpunit": "^8.5",
"squizlabs/php_codesniffer": "~3.4"
},
"type": "library",
"extra": {
"laravel": {
"providers": [
"Dacastro4\\LaravelGmail\\LaravelGmailServiceProvider"
],
"aliases": {
"LaravelGmail": "Dacastro4\\LaravelGmail\\Facade\\LaravelGmail"
}
}
},
"autoload": {
"psr-4": {
"Dacastro4\\LaravelGmail\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Daniel Castro",
"email": "danielcastro04@gmail.com",
"homepage": "https://danielcastro.me"
}
],
"description": "Gmail API package for Laravel",
"keywords": [
"api",
"gmail",
"laravel"
],
"support": {
"source": "https://github.com/turbo124/laravel-gmail/tree/v5.0.1"
},
"time": "2021-04-06T00:53:48+00:00"
},
{
"name": "vlucas/phpdotenv",
"version": "v5.3.0",
@ -14133,13 +14122,13 @@
"prefer-stable": true,
"prefer-lowest": false,
"platform": {
"php": "^7.3|^7.4",
"php": "^7.3|^7.4|^8.0",
"ext-dom": "*",
"ext-json": "*",
"ext-libxml": "*"
},
"platform-dev": {
"php": "^7.3|^7.4"
"php": "^7.3|^7.4|^8.0"
},
"plugin-api-version": "2.0.0"
}

View File

@ -0,0 +1,67 @@
<?php
/**
* Invoice Ninja (https://invoiceninja.com).
*
* @link https://github.com/invoiceninja/invoiceninja source repository
*
* @copyright Copyright (c) 2021. Invoice Ninja LLC (https://invoiceninja.com)
*
* @license https://opensource.org/licenses/AAL
*/
namespace Tests\Feature\Ninja;
use App\Models\Account;
use App\Utils\Traits\MakesHash;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Foundation\Testing\DatabaseTransactions;
use Illuminate\Support\Facades\Session;
use Tests\MockAccountData;
use Tests\TestCase;
/**
* @test
*/
class PlanTest extends TestCase
{
use MakesHash;
use DatabaseTransactions;
use MockAccountData;
public function setUp() :void
{
parent::setUp();
$this->makeTestData();
Session::start();
$this->faker = \Faker\Factory::create();
Model::reguard();
}
public function testTrialPlans()
{
config(['ninja.production' => true]);
$this->assertFalse($this->account->hasFeature(Account::FEATURE_USERS));
$this->account->trial_plan = 'enterprise';
$this->account->trial_started = now();
$this->account->trial_duration = 60*60*24*31;
$this->account->save();
nlog($this->account->getPlanDetails());
$this->assertFalse($this->account->hasFeature(Account::FEATURE_USERS));
$this->account->trial_plan = 'pro';
$this->account->save();
$this->assertFalse($this->account->hasFeature(Account::FEATURE_USERS));
$this->assertTrue($this->account->hasFeature(Account::FEATURE_CUSTOM_URL));
}
}