Changeset View
Changeset View
Standalone View
Standalone View
src/tests/Feature/UserTest.php
<?php | <?php | ||||
namespace Tests\Feature; | namespace Tests\Feature; | ||||
use App\Domain; | use App\Domain; | ||||
use App\EventLog; | use App\EventLog; | ||||
use App\Group; | use App\Group; | ||||
use App\Package; | use App\Package; | ||||
use App\PackageSku; | use App\PackageSku; | ||||
use App\Sku; | use App\Sku; | ||||
use App\User; | use App\User; | ||||
use App\Auth\Utils as AuthUtils; | |||||
use Carbon\Carbon; | use Carbon\Carbon; | ||||
use Illuminate\Support\Facades\Queue; | use Illuminate\Support\Facades\Queue; | ||||
use Tests\TestCase; | use Tests\TestCase; | ||||
class UserTest extends TestCase | class UserTest extends TestCase | ||||
{ | { | ||||
/** | /** | ||||
* {@inheritDoc} | * {@inheritDoc} | ||||
▲ Show 20 Lines • Show All 1,550 Lines • ▼ Show 20 Lines | public function testWallets(): void | ||||
$this->assertSame(1, $john->wallets()->count()); | $this->assertSame(1, $john->wallets()->count()); | ||||
$this->assertCount(1, $john->wallets); | $this->assertCount(1, $john->wallets); | ||||
$this->assertInstanceOf(\App\Wallet::class, $john->wallets->first()); | $this->assertInstanceOf(\App\Wallet::class, $john->wallets->first()); | ||||
$this->assertSame(1, $ned->wallets()->count()); | $this->assertSame(1, $ned->wallets()->count()); | ||||
$this->assertCount(1, $ned->wallets); | $this->assertCount(1, $ned->wallets); | ||||
$this->assertInstanceOf(\App\Wallet::class, $ned->wallets->first()); | $this->assertInstanceOf(\App\Wallet::class, $ned->wallets->first()); | ||||
} | } | ||||
/** | |||||
* Tests for User::findAndAuthenticate() | |||||
*/ | |||||
public function testFindAndAuthenticate(): void | |||||
{ | |||||
$user = $this->getTestUser('john@kolab.org'); | |||||
// Ensure we validate a token for the user: | |||||
$token = AuthUtils::tokenCreate($user->id); | |||||
$this->assertTrue(isset(User::findAndAuthenticate($user->email, $token)['user'])); | |||||
// Ensure we don't validate a token for another user: | |||||
$token = AuthUtils::tokenCreate($this->getTestUser('ned@kolab.org')->id); | |||||
$this->assertFalse(isset(User::findAndAuthenticate($user->email, $token)['user'])); | |||||
} | |||||
} | } |