Test facades.

This commit is contained in:
James Cole 2020-03-13 08:02:38 +01:00
parent 3746cb8c71
commit 5145707b94
No known key found for this signature in database
GPG Key ID: C16961E655E74B5E
5 changed files with 207 additions and 67 deletions

View File

@ -25,6 +25,9 @@ namespace FireflyIII\Console\Commands;
use Illuminate\Console\Command;
/**
* Class SetLatestVersion
*/
class SetLatestVersion extends Command
{
/**
@ -53,19 +56,22 @@ class SetLatestVersion extends Command
/**
* Execute the console command.
*
* @return mixed
* @return int
*/
public function handle()
public function handle(): int
{
if (!$this->option('james-is-cool')) {
$this->error('Am too!');
return;
return 0;
}
app('fireflyconfig')->set('db_version', config('firefly.db_version'));
app('fireflyconfig')->set('ff3_version', config('firefly.version'));
$this->line('Updated version.');
//Telemetry::string('db_version', config('firefly.db_version'));
//Telemetry::string('ff3_version', config('firefly.version'));
return 0;
}
}

View File

@ -58,6 +58,7 @@ use FireflyIII\Support\Form\RuleForm;
use FireflyIII\Support\Navigation;
use FireflyIII\Support\Preferences;
use FireflyIII\Support\Steam;
use FireflyIII\Support\Telemetry;
use FireflyIII\Validation\FireflyValidator;
use Illuminate\Support\ServiceProvider;
use Validator;
@ -91,33 +92,33 @@ class FireflyServiceProvider extends ServiceProvider
{
$this->app->bind(
'preferences',
function () {
static function () {
return new Preferences;
}
);
$this->app->bind(
'fireflyconfig',
function () {
static function () {
return new FireflyConfig;
}
);
$this->app->bind(
'navigation',
function () {
static function () {
return new Navigation;
}
);
$this->app->bind(
'amount',
function () {
static function () {
return new Amount;
}
);
$this->app->bind(
'steam',
function () {
static function () {
return new Steam;
}
);
@ -155,6 +156,13 @@ class FireflyServiceProvider extends ServiceProvider
}
);
$this->app->bind(
'telemetry',
static function () {
return new Telemetry;
}
);
// chart generator:
$this->app->bind(GeneratorInterface::class, ChartJsGenerator::class);

View File

@ -0,0 +1,41 @@
<?php
/**
* Amount.php
* Copyright (c) 2019 james@firefly-iii.org
*
* This file is part of Firefly III (https://github.com/firefly-iii).
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
declare(strict_types=1);
namespace FireflyIII\Support\Facades;
use Illuminate\Support\Facades\Facade;
/**
* Class Telemetry
*/
class Telemetry extends Facade
{
/**
* Get the registered name of the component.
*
* @return string
*/
protected static function getFacadeAccessor(): string
{
return 'telemetry';
}
}

81
app/Support/Telemetry.php Normal file
View File

@ -0,0 +1,81 @@
<?php
/**
* Telemetry.php
* Copyright (c) 2020 thegrumpydictator@gmail.com
*
* This file is part of Firefly III (https://github.com/firefly-iii).
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
namespace FireflyIII\Support;
use Log;
/**
* Class Telemetry
*/
class Telemetry
{
/**
* Feature telemetry stores a boolean "true" for the given $flag.
*
* Examples:
* - use-help-pages
* - has-created-bill
* - do-big-import
* - first-time-install
* - more
*
* Its use should be limited to exotic and strange use cases in Firefly III.
* Because time and date are logged as well, useful to track users' evolution in Firefly III.
*
* Any meta-data stored is strictly non-financial.
*
* @param string $flag
*/
public function feature(string $flag): void
{
if (false === config('firefly.send_telemetry')) {
// hard stop if not allowed to do telemetry.
// do nothing!
return;
}
Log::info(sprintf('Logged telemetry feature flag "%s".', $flag));
// no storage backend yet, do nothing.
}
/**
* String telemetry stores a string value as a telemetry entry. Values could include:
*
* - "php-version", "php7.3"
* - "os-version", "linux"
*
* Any meta-data stored is strictly non-financial.
*
* @param string $name
* @param string $value
*/
public function string(string $name, string $value): void
{
if (false === config('firefly.send_telemetry')) {
// hard stop if not allowed to do telemetry.
// do nothing!
return;
}
Log::info(sprintf('Logged telemetry string "%s" with value "%s".', $name, $value));
}
}

122
composer.lock generated
View File

@ -8,26 +8,26 @@
"packages": [
{
"name": "adldap2/adldap2",
"version": "v10.2.2",
"version": "v10.2.3",
"source": {
"type": "git",
"url": "https://github.com/Adldap2/Adldap2.git",
"reference": "f09ca4ae3a65dbf123b56dc7e4ace8682ea16cdb"
"reference": "2baffac2dfef308f0a94afa360b6a77540730fd2"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/Adldap2/Adldap2/zipball/f09ca4ae3a65dbf123b56dc7e4ace8682ea16cdb",
"reference": "f09ca4ae3a65dbf123b56dc7e4ace8682ea16cdb",
"url": "https://api.github.com/repos/Adldap2/Adldap2/zipball/2baffac2dfef308f0a94afa360b6a77540730fd2",
"reference": "2baffac2dfef308f0a94afa360b6a77540730fd2",
"shasum": ""
},
"require": {
"ext-json": "*",
"ext-ldap": "*",
"illuminate/contracts": "~5.0|~6.0",
"illuminate/contracts": "~5.0|~6.0|~7.0",
"php": ">=7.0",
"psr/log": "~1.0",
"psr/simple-cache": "~1.0",
"tightenco/collect": "~5.0|~6.0"
"tightenco/collect": "~5.0|~6.0|~7.0"
},
"require-dev": {
"mockery/mockery": "~1.0",
@ -63,25 +63,25 @@
"ldap",
"windows"
],
"time": "2019-12-18T15:07:31+00:00"
"time": "2020-03-08T23:04:47+00:00"
},
{
"name": "adldap2/adldap2-laravel",
"version": "v6.0.8",
"version": "v6.0.9",
"source": {
"type": "git",
"url": "https://github.com/Adldap2/Adldap2-Laravel.git",
"reference": "c2809bcca39bd51fe3fbe426c5dc32e89a868a42"
"reference": "0c828772333936f4c26c1ce27bd372008eae7e6e"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/Adldap2/Adldap2-Laravel/zipball/c2809bcca39bd51fe3fbe426c5dc32e89a868a42",
"reference": "c2809bcca39bd51fe3fbe426c5dc32e89a868a42",
"url": "https://api.github.com/repos/Adldap2/Adldap2-Laravel/zipball/0c828772333936f4c26c1ce27bd372008eae7e6e",
"reference": "0c828772333936f4c26c1ce27bd372008eae7e6e",
"shasum": ""
},
"require": {
"adldap2/adldap2": "^10.1",
"illuminate/support": "~5.5|~6.0",
"illuminate/support": "~5.5|~6.0|~7.0",
"php": ">=7.1"
},
"require-dev": {
@ -117,7 +117,7 @@
"laravel",
"ldap"
],
"time": "2019-09-03T16:03:04+00:00"
"time": "2020-03-08T23:15:56+00:00"
},
{
"name": "bacon/bacon-qr-code",
@ -1239,7 +1239,7 @@
},
{
"name": "James Cole",
"email": "thegrumpydictator@gmail.com",
"email": "james@firefly-iii.org",
"role": "Developer"
}
],
@ -1390,16 +1390,16 @@
},
{
"name": "laravel/framework",
"version": "v6.18.0",
"version": "v6.18.1",
"source": {
"type": "git",
"url": "https://github.com/laravel/framework.git",
"reference": "077b895d935b7fbcfb1d1eb34217fa4f80a130d8"
"reference": "367c2c8dfdfe83cb2ddbc029c0222174098d093a"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/laravel/framework/zipball/077b895d935b7fbcfb1d1eb34217fa4f80a130d8",
"reference": "077b895d935b7fbcfb1d1eb34217fa4f80a130d8",
"url": "https://api.github.com/repos/laravel/framework/zipball/367c2c8dfdfe83cb2ddbc029c0222174098d093a",
"reference": "367c2c8dfdfe83cb2ddbc029c0222174098d093a",
"shasum": ""
},
"require": {
@ -1532,7 +1532,7 @@
"framework",
"laravel"
],
"time": "2020-03-03T13:14:27+00:00"
"time": "2020-03-10T14:11:04+00:00"
},
{
"name": "laravel/passport",
@ -1925,16 +1925,16 @@
},
{
"name": "league/flysystem",
"version": "1.0.64",
"version": "1.0.65",
"source": {
"type": "git",
"url": "https://github.com/thephpleague/flysystem.git",
"reference": "d13c43dbd4b791f815215959105a008515d1a2e0"
"reference": "8f17b3ba67097aafb8318cd5c553b1acf7c891c8"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/thephpleague/flysystem/zipball/d13c43dbd4b791f815215959105a008515d1a2e0",
"reference": "d13c43dbd4b791f815215959105a008515d1a2e0",
"url": "https://api.github.com/repos/thephpleague/flysystem/zipball/8f17b3ba67097aafb8318cd5c553b1acf7c891c8",
"reference": "8f17b3ba67097aafb8318cd5c553b1acf7c891c8",
"shasum": ""
},
"require": {
@ -2005,7 +2005,7 @@
"sftp",
"storage"
],
"time": "2020-02-05T18:14:17+00:00"
"time": "2020-03-08T18:53:20+00:00"
},
{
"name": "league/flysystem-replicate-adapter",
@ -2989,8 +2989,8 @@
"authors": [
{
"name": "Antonio Carlos Ribeiro",
"email": "acr@antoniocarlosribeiro.com",
"role": "Creator & Designer"
"role": "Creator & Designer",
"email": "acr@antoniocarlosribeiro.com"
}
],
"description": "QR Code package for Google2FA",
@ -3049,9 +3049,9 @@
"authors": [
{
"name": "Antonio Carlos Ribeiro",
"role": "Developer",
"email": "acr@antoniocarlosribeiro.com",
"homepage": "https://antoniocarlosribeiro.com",
"role": "Developer"
"homepage": "https://antoniocarlosribeiro.com"
}
],
"description": "Create random chars, numbers, strings",
@ -3111,9 +3111,9 @@
"authors": [
{
"name": "Antonio Carlos Ribeiro",
"role": "Developer",
"email": "acr@antoniocarlosribeiro.com",
"homepage": "https://antoniocarlosribeiro.com",
"role": "Developer"
"homepage": "https://antoniocarlosribeiro.com"
}
],
"description": "Create recovery codes for two factor auth",
@ -5230,16 +5230,16 @@
},
{
"name": "tightenco/collect",
"version": "v6.17.0",
"version": "v7.1.1",
"source": {
"type": "git",
"url": "https://github.com/tightenco/collect.git",
"reference": "bc554bfb79fc02b4e6e1dd463a7fa8470119e9ab"
"reference": "306a4def08c9781ff74fcf1e012f22cbf8686348"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/tightenco/collect/zipball/bc554bfb79fc02b4e6e1dd463a7fa8470119e9ab",
"reference": "bc554bfb79fc02b4e6e1dd463a7fa8470119e9ab",
"url": "https://api.github.com/repos/tightenco/collect/zipball/306a4def08c9781ff74fcf1e012f22cbf8686348",
"reference": "306a4def08c9781ff74fcf1e012f22cbf8686348",
"shasum": ""
},
"require": {
@ -5276,7 +5276,7 @@
"collection",
"laravel"
],
"time": "2020-02-25T19:45:47+00:00"
"time": "2020-03-09T16:52:33+00:00"
},
{
"name": "tijsverkoyen/css-to-inline-styles",
@ -5394,16 +5394,16 @@
},
{
"name": "vlucas/phpdotenv",
"version": "v3.6.0",
"version": "v3.6.1",
"source": {
"type": "git",
"url": "https://github.com/vlucas/phpdotenv.git",
"reference": "1bdf24f065975594f6a117f0f1f6cabf1333b156"
"reference": "8f7961f7b9deb3b432452c18093cf16f88205902"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/vlucas/phpdotenv/zipball/1bdf24f065975594f6a117f0f1f6cabf1333b156",
"reference": "1bdf24f065975594f6a117f0f1f6cabf1333b156",
"url": "https://api.github.com/repos/vlucas/phpdotenv/zipball/8f7961f7b9deb3b432452c18093cf16f88205902",
"reference": "8f7961f7b9deb3b432452c18093cf16f88205902",
"shasum": ""
},
"require": {
@ -5412,8 +5412,12 @@
"symfony/polyfill-ctype": "^1.9"
},
"require-dev": {
"ext-filter": "*",
"phpunit/phpunit": "^4.8.35 || ^5.0 || ^6.0 || ^7.0"
},
"suggest": {
"ext-filter": "Required to use the boolean validator."
},
"type": "library",
"extra": {
"branch-alias": {
@ -5447,7 +5451,7 @@
"env",
"environment"
],
"time": "2019-09-10T21:37:39+00:00"
"time": "2020-03-12T13:44:00+00:00"
}
],
"packages-dev": [
@ -5629,16 +5633,16 @@
},
{
"name": "composer/composer",
"version": "1.9.3",
"version": "1.10.0",
"source": {
"type": "git",
"url": "https://github.com/composer/composer.git",
"reference": "1291a16ce3f48bfdeca39d64fca4875098af4d7b"
"reference": "472c917b2a083ec7d2fa25c55fd099d1300e2515"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/composer/composer/zipball/1291a16ce3f48bfdeca39d64fca4875098af4d7b",
"reference": "1291a16ce3f48bfdeca39d64fca4875098af4d7b",
"url": "https://api.github.com/repos/composer/composer/zipball/472c917b2a083ec7d2fa25c55fd099d1300e2515",
"reference": "472c917b2a083ec7d2fa25c55fd099d1300e2515",
"shasum": ""
},
"require": {
@ -5651,17 +5655,17 @@
"psr/log": "^1.0",
"seld/jsonlint": "^1.4",
"seld/phar-utils": "^1.0",
"symfony/console": "^2.7 || ^3.0 || ^4.0",
"symfony/filesystem": "^2.7 || ^3.0 || ^4.0",
"symfony/finder": "^2.7 || ^3.0 || ^4.0",
"symfony/process": "^2.7 || ^3.0 || ^4.0"
"symfony/console": "^2.7 || ^3.0 || ^4.0 || ^5.0",
"symfony/filesystem": "^2.7 || ^3.0 || ^4.0 || ^5.0",
"symfony/finder": "^2.7 || ^3.0 || ^4.0 || ^5.0",
"symfony/process": "^2.7 || ^3.0 || ^4.0 || ^5.0"
},
"conflict": {
"symfony/console": "2.8.38"
},
"require-dev": {
"phpunit/phpunit": "^4.8.35 || ^5.7",
"phpunit/phpunit-mock-objects": "^2.3 || ^3.0"
"phpspec/prophecy": "^1.10",
"symfony/phpunit-bridge": "^3.4"
},
"suggest": {
"ext-openssl": "Enabling the openssl extension allows you to access https URLs for repositories and packages",
@ -5674,7 +5678,7 @@
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.9-dev"
"dev-master": "1.10-dev"
}
},
"autoload": {
@ -5705,7 +5709,7 @@
"dependency",
"package"
],
"time": "2020-02-04T11:58:49+00:00"
"time": "2020-03-10T13:08:05+00:00"
},
{
"name": "composer/semver",
@ -7935,26 +7939,26 @@
},
{
"name": "symfony/filesystem",
"version": "v4.4.5",
"version": "v5.0.5",
"source": {
"type": "git",
"url": "https://github.com/symfony/filesystem.git",
"reference": "266c9540b475f26122b61ef8b23dd9198f5d1cfd"
"reference": "3afadc0f57cd74f86379d073e694b0f2cda2a88c"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/filesystem/zipball/266c9540b475f26122b61ef8b23dd9198f5d1cfd",
"reference": "266c9540b475f26122b61ef8b23dd9198f5d1cfd",
"url": "https://api.github.com/repos/symfony/filesystem/zipball/3afadc0f57cd74f86379d073e694b0f2cda2a88c",
"reference": "3afadc0f57cd74f86379d073e694b0f2cda2a88c",
"shasum": ""
},
"require": {
"php": "^7.1.3",
"php": "^7.2.5",
"symfony/polyfill-ctype": "~1.8"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "4.4-dev"
"dev-master": "5.0-dev"
}
},
"autoload": {
@ -7981,7 +7985,7 @@
],
"description": "Symfony Filesystem Component",
"homepage": "https://symfony.com",
"time": "2020-01-21T08:20:44+00:00"
"time": "2020-01-21T08:40:24+00:00"
},
{
"name": "theseer/tokenizer",