Changeset View
Changeset View
Standalone View
Standalone View
src/tests/TestCaseTrait.php
<?php | <?php | ||||
namespace Tests; | namespace Tests; | ||||
use App\Domain; | use App\Domain; | ||||
use App\Group; | |||||
use App\Transaction; | use App\Transaction; | ||||
use App\User; | use App\User; | ||||
use Carbon\Carbon; | use Carbon\Carbon; | ||||
use Illuminate\Contracts\Console\Kernel; | use Illuminate\Contracts\Console\Kernel; | ||||
use Illuminate\Support\Facades\Queue; | use Illuminate\Support\Facades\Queue; | ||||
use PHPUnit\Framework\Assert; | use PHPUnit\Framework\Assert; | ||||
trait TestCaseTrait | trait TestCaseTrait | ||||
▲ Show 20 Lines • Show All 130 Lines • ▼ Show 20 Lines | protected function deleteTestDomain($name) | ||||
} | } | ||||
$job = new \App\Jobs\Domain\DeleteJob($domain->id); | $job = new \App\Jobs\Domain\DeleteJob($domain->id); | ||||
$job->handle(); | $job->handle(); | ||||
$domain->forceDelete(); | $domain->forceDelete(); | ||||
} | } | ||||
protected function deleteTestGroup($email) | |||||
{ | |||||
Queue::fake(); | |||||
$group = Group::withTrashed()->where('email', $email)->first(); | |||||
if (!$group) { | |||||
return; | |||||
} | |||||
$job = new \App\Jobs\Group\DeleteJob($group->id); | |||||
$job->handle(); | |||||
$group->forceDelete(); | |||||
} | |||||
protected function deleteTestUser($email) | protected function deleteTestUser($email) | ||||
{ | { | ||||
Queue::fake(); | Queue::fake(); | ||||
$user = User::withTrashed()->where('email', $email)->first(); | $user = User::withTrashed()->where('email', $email)->first(); | ||||
if (!$user) { | if (!$user) { | ||||
return; | return; | ||||
Show All 12 Lines | trait TestCaseTrait | ||||
protected function getTestDomain($name, $attrib = []) | protected function getTestDomain($name, $attrib = []) | ||||
{ | { | ||||
// Disable jobs (i.e. skip LDAP oprations) | // Disable jobs (i.e. skip LDAP oprations) | ||||
Queue::fake(); | Queue::fake(); | ||||
return Domain::firstOrCreate(['namespace' => $name], $attrib); | return Domain::firstOrCreate(['namespace' => $name], $attrib); | ||||
} | } | ||||
/** | /** | ||||
* Get Group object by email, create it if needed. | |||||
* Skip LDAP jobs. | |||||
*/ | |||||
protected function getTestGroup($email, $attrib = []) | |||||
{ | |||||
// Disable jobs (i.e. skip LDAP oprations) | |||||
Queue::fake(); | |||||
return Group::firstOrCreate(['email' => $email], $attrib); | |||||
} | |||||
/** | |||||
* Get User object by email, create it if needed. | * Get User object by email, create it if needed. | ||||
* Skip LDAP jobs. | * Skip LDAP jobs. | ||||
*/ | */ | ||||
protected function getTestUser($email, $attrib = []) | protected function getTestUser($email, $attrib = []) | ||||
{ | { | ||||
// Disable jobs (i.e. skip LDAP oprations) | // Disable jobs (i.e. skip LDAP oprations) | ||||
Queue::fake(); | Queue::fake(); | ||||
$user = User::withTrashed()->where('email', $email)->first(); | $user = User::withTrashed()->where('email', $email)->first(); | ||||
▲ Show 20 Lines • Show All 42 Lines • Show Last 20 Lines |