chore: consistency (#3136)

This commit is contained in:
Alexis Saettler
2019-10-27 23:37:45 +01:00
committed by GitHub
parent 473f7a306e
commit 68ac253971
53 changed files with 137 additions and 110 deletions
+5 -1
View File
@@ -1,3 +1,7 @@
preset: laravel
enabled:
- fully_qualified_strict_types
- fully_qualified_strict_types
finder:
not-name:
- index.php
- server.php
+1
View File
@@ -41,6 +41,7 @@ class CronEvent
*/
public static function command(string $command) : self
{
/** @var \App\Models\Instance\Cron $cron */
$cron = Cron::firstOrCreate(['command' => $command]);
return new self($cron);
@@ -113,8 +113,9 @@ class RegisterController extends Controller
*/
protected function registered(Request $request, $user)
{
$first = Account::count() == 1;
if (! config('monica.signup_double_optin') || $first) {
/** @var int $count */
$count = Account::count();
if (! config('monica.signup_double_optin') || $count == 1) {
// if signup_double_optin is disabled, skip the confirm email part
$user->markEmailAsVerified();
}
+1 -1
View File
@@ -794,7 +794,7 @@ class Account extends Model
* Gets the RelationshipType object matching the given type.
*
* @param string $relationshipTypeName
* @return RelationshipType
* @return RelationshipType|null
*/
public function getRelationshipTypeByType(string $relationshipTypeName)
{
+3 -2
View File
@@ -465,14 +465,14 @@ class Contact extends Model
$builder->leftJoin('activity_contact', 'contacts.id', '=', 'activity_contact.contact_id');
$builder->leftJoin('activities', 'activity_contact.activity_id', '=', 'activities.id');
$builder->orderBy('activities.date_it_happened', 'desc');
$builder->select('*', 'contacts.id as id');
$builder->select(['*', 'contacts.id as id']);
return $builder;
case 'lastactivitydateOldtoNew':
$builder->leftJoin('activity_contact', 'contacts.id', '=', 'activity_contact.contact_id');
$builder->leftJoin('activities', 'activity_contact.activity_id', '=', 'activities.id');
$builder->orderBy('activities.date_it_happened', 'asc');
$builder->select('*', 'contacts.id as id');
$builder->select(['*', 'contacts.id as id']);
return $builder;
default:
@@ -1154,6 +1154,7 @@ class Contact extends Model
}
try {
/** @var Contact $contact */
$contact = self::where('account_id', $this->account_id)
->findOrFail($this->first_met_through_contact_id);
} catch (ModelNotFoundException $e) {
+1 -1
View File
@@ -51,7 +51,7 @@ class RelationshipType extends Model
/**
* Get the reverser relationship type of this one.
*
* @return self
* @return self|null
*/
public function reverseRelationshipType()
{
+3 -2
View File
@@ -36,8 +36,9 @@ class ConfirmEmail extends LaravelNotification implements ShouldQueue, MailNotif
public function via()
{
if (! $this->force) {
$first = Account::count() == 1;
if (! config('monica.signup_double_optin') || $first) {
/** @var int $count */
$count = Account::count();
if (! config('monica.signup_double_optin') || $count == 1) {
return [];
}
}
+3 -1
View File
@@ -1,6 +1,8 @@
#!/usr/bin/env php
<?php
define('LARAVEL_START', microtime(true));
/*
|--------------------------------------------------------------------------
| Register The Auto Loader
@@ -13,7 +15,7 @@
|
*/
require __DIR__.'/bootstrap/autoload.php';
require __DIR__.'/vendor/autoload.php';
$app = require_once __DIR__.'/bootstrap/app.php';
-34
View File
@@ -1,34 +0,0 @@
<?php
define('LARAVEL_START', microtime(true));
/*
|--------------------------------------------------------------------------
| Register The Composer Auto Loader
|--------------------------------------------------------------------------
|
| Composer provides a convenient, automatically generated class loader
| for our application. We just need to utilize it! We'll require it
| into the script here so that we do not have to worry about the
| loading of any our classes "manually". Feels great to relax.
|
*/
require __DIR__.'/../vendor/autoload.php';
/*
|--------------------------------------------------------------------------
| Include The Compiled Class File
|--------------------------------------------------------------------------
|
| To dramatically increase your application's performance, you may use a
| compiled class file which contains all of the classes commonly used
| by a request. The Artisan "optimize" is used to create this file.
|
*/
$compiledPath = __DIR__.'/cache/compiled.php';
if (file_exists($compiledPath)) {
require $compiledPath;
}
+1
View File
@@ -3,6 +3,7 @@ includes:
- ./vendor/thecodingmachine/phpstan-safe-rule/phpstan-safe-rule.neon
parameters:
inferPrivatePropertyTypeFromConstructor: true
level: 5
ignoreErrors:
# Level 1
+4 -2
View File
@@ -1,7 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit backupGlobals="false"
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="./vendor/phpunit/phpunit/phpunit.xsd"
backupGlobals="false"
backupStaticAttributes="false"
bootstrap="bootstrap/autoload.php"
bootstrap="vendor/autoload.php"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
+4 -2
View File
@@ -1,7 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit backupGlobals="false"
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="./vendor/phpunit/phpunit/phpunit.xsd"
backupGlobals="false"
backupStaticAttributes="false"
bootstrap="bootstrap/autoload.php"
bootstrap="vendor/autoload.php"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
+4 -1
View File
@@ -3,9 +3,12 @@
/**
* Laravel - A PHP Framework For Web Artisans.
*
* @package Laravel
* @author Taylor Otwell <taylorotwell@gmail.com>
*/
define('LARAVEL_START', microtime(true));
/*
|--------------------------------------------------------------------------
| Register The Auto Loader
@@ -18,7 +21,7 @@
|
*/
require __DIR__.'/../bootstrap/autoload.php';
require __DIR__.'/../vendor/autoload.php';
/*
|--------------------------------------------------------------------------
+2 -2
View File
@@ -1,6 +1,6 @@
<form method="POST" action="{{ $action }}">
{{ method_field($method) }}
{{ csrf_field() }}
@method($method)
@csrf
<h2>{{ trans('people.activities_add_title', ['name' => $contact->first_name]) }}</h2>
+2 -2
View File
@@ -44,8 +44,8 @@
</div>
<form method="POST" action="{{ route('activities.delete', [$activity, $contact]) }}" class="entry-delete-form hidden">
{{ method_field('DELETE') }}
{{ csrf_field() }}
@method('DELETE')
@csrf
</form>
</li>
+1 -1
View File
@@ -23,7 +23,7 @@
@endif
<form action="settings/emailchange1" method="post">
{{ csrf_field() }}
@csrf
<div class="form-group">
<label>{{ trans('auth.email_change_current_email') }}</label>
+1 -1
View File
@@ -23,7 +23,7 @@
@endif
<form action="settings/emailchange2" method="POST">
{{ csrf_field() }}
@csrf
<div class="form-group">
<label>{{ trans('auth.email_change_current_email') }}</label>
+1 -1
View File
@@ -35,7 +35,7 @@
@endif
<form action="login" method="post">
{{ csrf_field() }}
@csrf
<div class="form-group">
<label for="email">{{ trans('auth.email') }}</label>
@@ -16,7 +16,7 @@
@endif
<form class="form-horizontal" role="form" method="POST" action="{{ '/password/email' }}">
{{ csrf_field() }}
@csrf
<div class="form-group{{ $errors->has('email') ? ' has-error' : '' }}">
<label for="email" class="col-md-4 col-form-label">{{ trans('auth.password_reset_email') }}</label>
@@ -12,7 +12,7 @@
<div class="panel-body">
<form class="form-horizontal" role="form" method="POST" action="{{ '/password/reset' }}">
{{ csrf_field() }}
@csrf
<input type="hidden" name="token" value="{{ $token }}">
@@ -22,7 +22,7 @@
@endif
<form action="{{ route('recovery.login') }}" method="post">
{{ csrf_field() }}
@csrf
<div class="form-group">
<label for="recovery">{{ trans('auth.recovery') }}</label>
+1 -1
View File
@@ -51,7 +51,7 @@
@endif
<form action="register" method="post">
{{ csrf_field() }}
@csrf
<div class="form-group">
<label for="email">{{ trans('auth.register_email') }}</label>
+1 -1
View File
@@ -9,7 +9,7 @@
<p>{{ trans('app.compliance_desc_end') }}</p>
<form action="compliance/sign" method="POST" class="tc mt4">
{{ csrf_field() }}
@csrf
<button class="btn btn-primary" name="save" type="submit">{{ trans('app.compliance_terms') }}</button>
</form>
</div>
+1 -1
View File
@@ -26,7 +26,7 @@
<div class="row">
<div class="col-12 col-sm-6 offset-sm-3 offset-sm-3-right">
<form method="POST" action="{{ route('journal.save') }}">
{{ csrf_field() }}
@csrf
@include('partials.errors')
+1 -1
View File
@@ -27,7 +27,7 @@
<div class="col-xs-12 col-sm-6 col-sm-offset-3 col-sm-offset-3-right">
<form method="POST" action="{{ route('journal.update', ['entryId' => $entry->id]) }}">
@method('PUT')
{{ csrf_field() }}
@csrf
@include('partials.errors')
+1 -1
View File
@@ -11,7 +11,7 @@
<div class="mw7 center br3 ba b--gray-monica bg-white mb5">
<form method="POST" action="{{ route('people.avatar.update', $contact) }}" enctype="multipart/form-data">
{{ csrf_field() }}
@csrf
@include('partials.errors')
@@ -11,8 +11,8 @@
<h3 class="f3 fw5">{{ trans('people.conversation_edit_title') }}</h3>
<p><a href="#" onclick="if (confirm('{{ trans('people.conversation_edit_delete') }}')) { $('#conversation-delete-form').submit(); } return false;" class="w-auto-ns w-100 mb2 pb0-ns">{{ trans('people.conversation_delete_link') }}</a></p>
<form method="POST" action="{{ route('people.conversations.destroy', [$contact, $conversation]) }}" id="conversation-delete-form" class="hidden">
{{ method_field('DELETE') }}
{{ csrf_field() }}
@method('DELETE')
@csrf
</form>
</div>
</div>
@@ -29,7 +29,7 @@
<form action="{{ route('people.conversations.update', [$contact, $conversation]) }}" method="POST" enctype="multipart/form-data">
@method('PUT')
{{ csrf_field() }}
@csrf
{{-- When did it take place --}}
<div class="pa4-ns ph3 pv2 mb3 mb0-ns bb b--gray-monica">
@@ -23,7 +23,7 @@
@include('partials.errors')
<form action="{{ route('people.conversations.store', $contact) }}" method="POST">
{{ csrf_field() }}
@csrf
{{-- When did it take place --}}
<div class="pa4-ns ph3 pv2 mb3 mb0-ns bb b--gray-monica">
+1 -1
View File
@@ -26,7 +26,7 @@
@include('partials.errors')
<form action="{{ route('people.store') }}" method="POST">
{{ csrf_field() }}
@csrf
<div class="pa4-ns ph3 pv2 bb b--gray-monica">
{{-- This check is for the cultures that are used to say the last name first --}}
+2 -2
View File
@@ -1,6 +1,6 @@
<form method="POST" action="{{ $action }}">
{{ method_field($method) }}
{{ csrf_field() }}
@method($method)
@csrf
@include('partials.errors')
+2 -2
View File
@@ -55,8 +55,8 @@
</div>
<form method="POST" action="{{ route('people.debts.destroy', [$contact, $debt]) }}" class="entry-delete-form hidden">
{{ method_field('DELETE') }}
{{ csrf_field() }}
@method('DELETE')
@csrf
</form>
</li>
@endforeach
+3 -3
View File
@@ -16,7 +16,7 @@
<div class="mw7 center br3 ba b--gray-monica bg-white mb5">
<form method="POST" action="{{ route('people.update', $contact) }}" enctype="multipart/form-data">
@method('PUT')
{{ csrf_field() }}
@csrf
@include('partials.errors')
@@ -155,7 +155,7 @@
</div>
<form method="POST" action="{{ route('people.destroy', $contact) }}" id="contact-delete-form" class="hidden">
{{ method_field('DELETE') }}
{{ csrf_field() }}
@method('DELETE')
@csrf
</form>
@endsection
@@ -33,7 +33,7 @@
<div class="row">
<div class="col-12 col-sm-6 offset-sm-3 offset-sm-3-right">
<form method="POST" action="{{ route('people.food.update', $contact) }}">
{{ csrf_field() }}
@csrf
<h2>{{ trans('people.food_preferences_edit_title') }}</h2>
+2 -2
View File
@@ -1,6 +1,6 @@
<form method="POST" action="{{ $action }}">
{{ method_field($method) }}
{{ csrf_field() }}
@method($method)
@csrf
<h2>{{ trans('people.gifts_add_title', ['name' => $contact->first_name]) }}</h2>
+1 -1
View File
@@ -2,7 +2,7 @@
@section('content')
<div class="people-list">
{{ csrf_field() }}
@csrf
{{-- Breadcrumb --}}
<div class="breadcrumb">
@@ -35,7 +35,7 @@
<h2>{{ trans('people.introductions_title_edit', ['name' => $contact->first_name]) }}</h2>
<form method="POST" action="{{ route('people.introductions.update', $contact) }}">
{{ csrf_field() }}
@csrf
@include('partials.errors')
@@ -10,7 +10,7 @@
</div>
<div class="modal-body">
<form method="POST" action="{{ route('people.calls.store', $contact) }}">
{{ csrf_field() }}
@csrf
<div class="form-group">
<label for="content" class="col-form-label b">{{ trans('people.modal_call_comment') }}</label>
+3 -3
View File
@@ -4,7 +4,7 @@
@section('content')
<div class="people-show" >
{{ csrf_field() }}
@csrf
{{-- Breadcrumb --}}
<div class="breadcrumb">
@@ -70,8 +70,8 @@
<li>
<a id="link-delete-contact" class="pointer" onclick="if (confirm('{{ trans('people.people_delete_confirmation') }}')) { $('#contact-delete-form').submit(); } return false;" href="">{{ trans('people.people_delete_message') }}</a>
<form method="POST" action="{{ route('people.destroy', $contact) }}" id="contact-delete-form" class="hidden">
{{ method_field('DELETE') }}
{{ csrf_field() }}
@method('DELETE')
@csrf
</form>
</li>
</ul>
@@ -28,8 +28,8 @@
</a>
<form method="POST" action="{{ route('people.relationships.destroy', [$contact, $relationship]) }}" class="entry-delete-form hidden">
{{ method_field('DELETE') }}
{{ csrf_field() }}
@method('DELETE')
@csrf
</form>
</div>
<div class="cb"></div>
@@ -23,7 +23,7 @@
@include('partials.errors')
<form action="{{ route('people.relationships.store', $contact) }}" method="POST">
{{ csrf_field() }}
@csrf
{{-- New contact / link existing --}}
<div class="pa4-ns ph3 pv2 mb3 mb0-ns bb b--gray-monica">
@@ -1,6 +1,6 @@
<form method="POST" action="{{ $action }}">
{{ method_field($method) }}
{{ csrf_field() }}
@method($method)
@csrf
<h2>{{ trans('people.reminders_add_title', ['name' => $contact->first_name]) }}</h2>
@@ -68,8 +68,8 @@
</div>
<form method="POST" action="{{ route('people.reminders.destroy', [$contact, $reminder]) }}" class="entry-delete-form hidden">
{{ method_field('DELETE') }}
{{ csrf_field() }}
@method('DELETE')
@csrf
</form>
</li>
@endforeach
+1 -1
View File
@@ -30,7 +30,7 @@
<div class="row">
<div class="col-12 col-sm-6 offset-sm-3 offset-sm-3-right">
<form method="POST" action="{{ route('people.work.update', $contact) }}" enctype="multipart/form-data">
{{ csrf_field() }}
@csrf
@include('partials.errors')
@@ -56,7 +56,7 @@
@include('partials.errors')
<form action="{{ route('settings.storeImport') }}" method="POST" enctype="multipart/form-data">
{{ csrf_field() }}
@csrf
<div class="form-group">
<label for="vcard">{!! trans('settings.import_upload_form_file') !!}</label>
+3 -3
View File
@@ -40,7 +40,7 @@
@endif
<form action="{{ route('settings.save') }}" method="POST">
{{ csrf_field() }}
@csrf
{{-- id --}}
<input type="hidden" name="id" value="{{ auth()->user()->id }}" />
@@ -123,7 +123,7 @@
</div>
<form method="POST" action="{{ route('settings.reset') }}" class="settings-reset bg-white" onsubmit="return confirm('{{ trans('settings.reset_notice') }}')">
{{ csrf_field() }}
@csrf
<h2>{{ trans('settings.reset_title') }}</h2>
<p>{{ trans('settings.reset_desc') }}</p>
@@ -131,7 +131,7 @@
</form>
<form method="POST" action="{{ route('settings.delete') }}" class="settings-delete bg-white" onsubmit="return confirm('{{ trans('settings.delete_notice') }}')">
{{ csrf_field() }}
@csrf
<h2>{{ trans('settings.delete_title') }}</h2>
<p>{{ trans('settings.delete_desc') }}</p>
@@ -46,7 +46,7 @@
<p>{{ trans('settings.security_help') }}</p>
<form method="POST" action="{{ route('settings.security.passwordChange') }}" class="settings-reset">
{{ csrf_field() }}
@csrf
<h2>{{ trans('settings.password_change') }}</h2>
@@ -58,7 +58,7 @@
</ul>
<form method="POST" action="{{ route('settings.subscriptions.downgrade') }}">
{{ csrf_field() }}
@csrf
@if (auth()->user()->account->canDowngrade())
<p class="mb4"><button href="" class="btn btn-primary">{{ trans('settings.subscriptions_downgrade_cta') }}</button></p>
+2 -2
View File
@@ -78,8 +78,8 @@
</div>
<form method="POST" action="{{ route('settings.tags.delete', $tag) }}" class="entry-delete-form hidden">
{{ method_field('DELETE') }}
{{ csrf_field() }}
@method('DELETE')
@csrf
</form>
</li>
@endforeach
@@ -17,7 +17,7 @@
@include ('partials.errors')
<form action="{{ route('invitations.accept', $key) }}" method="post">
{{ csrf_field() }}
@csrf
<div class="form-group">
<label for="email">{{ trans('auth.register_email') }}</label>
+1 -1
View File
@@ -35,7 +35,7 @@
<div class="br3 ba b--gray-monica bg-white mb4">
<div class="pa3 bb b--gray-monica">
<form method="POST" action="{{ route('settings.users.store') }}">
{{ csrf_field() }}
@csrf
<h2>{{ trans('settings.users_add_title') }}</h2>
@@ -55,8 +55,8 @@
</div>
<form method="POST" action="{{ route('settings.users.destroy', $user) }}" class="entry-delete-form hidden">
{{ method_field('DELETE') }}
{{ csrf_field() }}
@method('DELETE')
@csrf
</form>
</li>
@endforeach
@@ -86,8 +86,8 @@
</div>
<form method="POST" action="{{ route('settings.users.invitation.delete', $invitation) }}" class="entry-delete-form hidden">
{{ method_field('DELETE') }}
{{ csrf_field() }}
@method('DELETE')
@csrf
</form>
</li>
@endforeach
+3 -3
View File
@@ -28,7 +28,7 @@
<!-- Authorize Button -->
<form method="post" action="oauth/authorize">
{{ csrf_field() }}
@csrf
<input type="hidden" name="state" value="{{ $request->state }}">
<input type="hidden" name="client_id" value="{{ $client->id }}">
@@ -37,8 +37,8 @@
<!-- Cancel Button -->
<form method="post" action="oauth/authorize">
{{ csrf_field() }}
{{ method_field('DELETE') }}
@csrf
@method('DELETE')
<input type="hidden" name="state" value="{{ $request->state }}">
<input type="hidden" name="client_id" value="{{ $client->id }}">
+43
View File
@@ -8,6 +8,7 @@ use Illuminate\Support\Arr;
use App\Models\Contact\Gift;
use App\Helpers\StringHelper;
use App\Models\Contact\Contact;
use App\Models\Account\Activity;
use App\Models\Contact\Reminder;
use Illuminate\Foundation\Testing\WithFaker;
use Illuminate\Foundation\Testing\DatabaseTransactions;
@@ -231,6 +232,48 @@ class ContactTest extends FeatureTestCase
$response->assertSee('1 contact');
}
public function test_user_can_see_contacts_sorted_by_lastactivitydateNewtoOld()
{
$user = $this->signIn();
$contacts = factory(Contact::class, 10)->create([
'account_id' => $user->account_id,
]);
foreach ($contacts as $contact) {
factory(Activity::class)->create([
'account_id' => $contact->account_id,
]);
}
$response = $this->get('/people/list?sort=lastactivitydateNewtoOld');
$response->assertJsonFragment([
'totalRecords' => 10,
]);
}
public function test_user_can_see_contacts_sorted_by_lastactivitydateOldtoNew()
{
$user = $this->signIn();
$contacts = factory(Contact::class, 10)->create([
'account_id' => $user->account_id,
]);
foreach ($contacts as $contact) {
factory(Activity::class)->create([
'account_id' => $contact->account_id,
]);
}
$response = $this->get('/people/list?sort=lastactivitydateOldtoNew');
$response->assertJsonFragment([
'totalRecords' => 10,
]);
}
public function test_user_can_be_reminded_about_an_event_once()
{
[$user, $contact] = $this->fetchUser();