Created
January 5, 2022 08:09
-
-
Save mbpating/9b4cd5fc03934619c28fe757a9f981ac to your computer and use it in GitHub Desktop.
Using laravel's HTTP tests, test the CustomerController's store method, make sure to mock the mailable "WelcomeNewCustomer" using mail-fake.
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
<?php | |
namespace Tests\Unit; | |
use PHPUnit\Framework\TestCase; | |
use Illuminate\Support\Facades\Mail; | |
class CustomerStoreTest extends TestCase | |
{ | |
public function test_customer_can_be_stored() | |
{ | |
Mail::fake(); | |
$customerData = [ | |
'name' => 'Mark Berlon A. Pating', | |
'email' => '[email protected]' | |
]; | |
$this->json('POST','/customer',$customerData,['Accept' => 'application/json']) | |
->assertStatus(201) | |
->assertJsonStructure([ | |
'saved' => true | |
]); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment