forked from apiato/apiato
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: move tests and did some improvements
- Loading branch information
1 parent
021326a
commit 1e63234
Showing
2 changed files
with
16 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,7 @@ | |
namespace App\Containers\AppSection\User\Tests\Unit; | ||
|
||
use App\Containers\AppSection\User\Actions\RegisterUserAction; | ||
use App\Containers\AppSection\User\Tasks\CreateUserByCredentialsTask; | ||
use App\Containers\AppSection\User\Tests\TestCase; | ||
use App\Containers\AppSection\User\UI\API\Requests\RegisterUserRequest; | ||
use App\Ship\Exceptions\CreateResourceFailedException; | ||
|
@@ -15,6 +16,17 @@ | |
*/ | ||
class CreateUserByCredentialsTaskTest extends TestCase | ||
{ | ||
public function testCreateUserByCredentials(): void | ||
{ | ||
$data = [ | ||
'email' => '[email protected]', | ||
'password' => 'so-secret', | ||
]; | ||
|
||
$user = app(CreateUserByCredentialsTask::class)->run($data); | ||
|
||
$this->assertModelExists($user); | ||
} | ||
|
||
public function testCreateUserWithoutEmail(): void | ||
{ | ||
|
@@ -26,8 +38,7 @@ public function testCreateUserWithoutEmail(): void | |
'name' => 'Mahmoud', | ||
]; | ||
|
||
$request = new RegisterUserRequest($data); | ||
app(RegisterUserAction::class)->run($request); | ||
app(CreateUserByCredentialsTask::class)->run($data); | ||
} | ||
|
||
public function testCreateUserWithoutPassword(): void | ||
|
@@ -40,8 +51,7 @@ public function testCreateUserWithoutPassword(): void | |
'name' => 'Mahmoud', | ||
]; | ||
|
||
$request = new RegisterUserRequest($data); | ||
app(RegisterUserAction::class)->run($request); | ||
app(CreateUserByCredentialsTask::class)->run($data); | ||
} | ||
|
||
public function testCreateUserWithInvalidData(): void | ||
|
@@ -55,7 +65,6 @@ public function testCreateUserWithInvalidData(): void | |
'birth' => 'wrong-format', | ||
]; | ||
|
||
$request = new RegisterUserRequest($data); | ||
app(RegisterUserAction::class)->run($request); | ||
app(CreateUserByCredentialsTask::class)->run($data); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,19 +16,17 @@ | |
*/ | ||
class RegisterUserActionTest extends TestCase | ||
{ | ||
public function testCreateUser(): void | ||
public function testSendNotification_AfterUserRegistration(): void | ||
{ | ||
Notification::fake(); | ||
$data = [ | ||
'email' => '[email protected]', | ||
'password' => 'so-secret', | ||
'name' => 'Mahmoud', | ||
]; | ||
|
||
$request = new RegisterUserRequest($data); | ||
$user = app(RegisterUserAction::class)->run($request); | ||
|
||
$this->assertModelExists($user); | ||
Notification::assertSentTo($user, UserRegisteredNotification::class); | ||
} | ||
} |