Changeset View
Changeset View
Standalone View
Standalone View
src/tests/Feature/WalletTest.php
Show All 21 Lines | private $users = [ | ||||
'WalletController2B@WalletController.com', | 'WalletController2B@WalletController.com', | ||||
]; | ]; | ||||
public function setUp(): void | public function setUp(): void | ||||
{ | { | ||||
parent::setUp(); | parent::setUp(); | ||||
foreach ($this->users as $user) { | foreach ($this->users as $user) { | ||||
User::where('email', $user)->delete(); | $this->deleteTestUser($user); | ||||
} | } | ||||
} | } | ||||
public function tearDown(): void | public function tearDown(): void | ||||
{ | { | ||||
foreach ($this->users as $user) { | foreach ($this->users as $user) { | ||||
User::where('email', $user)->delete(); | $this->deleteTestUser($user); | ||||
} | } | ||||
parent::tearDown(); | |||||
} | } | ||||
/** | /** | ||||
* Verify a wallet is created, when a user is created. | * Verify a wallet is created, when a user is created. | ||||
*/ | */ | ||||
public function testCreateUserCreatesWallet(): void | public function testCreateUserCreatesWallet(): void | ||||
{ | { | ||||
$user = $this->getTestUser('UserWallet1@UserWallet.com'); | $user = $this->getTestUser('UserWallet1@UserWallet.com'); | ||||
▲ Show 20 Lines • Show All 86 Lines • ▼ Show 20 Lines | public function testAddWalletController(): void | ||||
$userB = $this->getTestUser('WalletControllerB@WalletController.com'); | $userB = $this->getTestUser('WalletControllerB@WalletController.com'); | ||||
$userA->wallets()->each( | $userA->wallets()->each( | ||||
function ($wallet) use ($userB) { | function ($wallet) use ($userB) { | ||||
$wallet->addController($userB); | $wallet->addController($userB); | ||||
} | } | ||||
); | ); | ||||
$this->assertTrue($userB->accounts()->count() == 1); | $this->assertTrue( | ||||
$userB->accounts()->count() == 1, | |||||
"number of accounts (1 expected): {$userB->accounts()->count()}" | |||||
); | |||||
$aWallet = $userA->wallets()->get(); | $aWallet = $userA->wallets()->get(); | ||||
$bAccount = $userB->accounts()->get(); | $bAccount = $userB->accounts()->get(); | ||||
$this->assertTrue($bAccount[0]->id === $aWallet[0]->id); | $this->assertTrue($bAccount[0]->id === $aWallet[0]->id); | ||||
} | } | ||||
/** | /** | ||||
Show All 24 Lines |