Repository: laravel/framework (php)

Issue:
Unable to fake cc in Mail::fake
<!-- DO NOT THROW THIS AWAY -->
<!-- Fill out the FULL versions with patch versions -->

- Laravel Version: 8.40.0
- PHP Version: 7.4.3
- Database Driver & Version: mysql

### Description: Unable to test any emails with `cc()`.

It is because Illuminate/Support/Testing/Fakes/MailFake has no `cc()` and this also causes you to not test `hasCc()` in `assertSent()` for emails that were cc'd instead of `to()`.

### Steps To Reproduce:

1. Setup any email with `cc()`

`Mail::cc('test@tester.com')->send(new TestMail());`

2.  Try to have a test to check if the mail was sent. 

```
Mail::assertSent(TestMail::class, function ($mail) {        
    return $mail->hasCc('test@tester.com');
});
```

Pull request:
[9.x] Testing MailFake add missing cc
`Mail::fake()` does not handle `Mail::cc()`

The `Mail` facade supports `cc` but somehow is not part of the `Mailer` contract.

---
Fixes #37238

Patch:
diff --git a/src/Illuminate/Foundation/Http/Middleware/VerifyCsrfToken.php b/src/Illuminate/Foundation/Http/Middleware/VerifyCsrfToken.php
index 28c979f105..bb9595fcfc 100644
--- a/src/Illuminate/Foundation/Http/Middleware/VerifyCsrfToken.php
+++ b/src/Illuminate/Foundation/Http/Middleware/VerifyCsrfToken.php
@@ -146,7 +146,7 @@ protected function tokensMatch($request)
      * Get the CSRF token from the request.
      *
      * @param  \Illuminate\Http\Request  $request
-     * @return string
+     * @return string|null
      */
     protected function getTokenFromRequest($request)
     {


Test patch:
diff --git a/src/Illuminate/Support/Testing/Fakes/MailFake.php b/src/Illuminate/Support/Testing/Fakes/MailFake.php
index c2d963d2e2..c95c15a55b 100644
--- a/src/Illuminate/Support/Testing/Fakes/MailFake.php
+++ b/src/Illuminate/Support/Testing/Fakes/MailFake.php
@@ -312,6 +312,17 @@ public function to($users)
         return (new PendingMailFake($this))->to($users);
     }
 
+    /**
+     * Begin the process of mailing a mailable class instance.
+     *
+     * @param  mixed  $users
+     * @return \Illuminate\Mail\PendingMail
+     */
+    public function cc($users)
+    {
+        return (new PendingMailFake($this))->cc($users);
+    }
+
     /**
      * Begin the process of mailing a mailable class instance.
      *
diff --git a/tests/Support/SupportTestingMailFakeTest.php b/tests/Support/SupportTestingMailFakeTest.php
index afaa49f62f..e46cef255b 100644
--- a/tests/Support/SupportTestingMailFakeTest.php
+++ b/tests/Support/SupportTestingMailFakeTest.php
@@ -54,6 +54,33 @@ public function testAssertSentWhenRecipientHasPreferredLocale()
         });
     }
 
+    public function testAssertTo()
+    {
+        $this->fake->to('taylor@laravel.com')->send($this->mailable);
+
+        $this->fake->assertSent(MailableStub::class, function ($mail) {
+            return $mail->hasTo('taylor@laravel.com');
+        });
+    }
+
+    public function testAssertCc()
+    {
+        $this->fake->cc('taylor@laravel.com')->send($this->mailable);
+
+        $this->fake->assertSent(MailableStub::class, function ($mail) {
+            return $mail->hasCc('taylor@laravel.com');
+        });
+    }
+
+    public function testAssertBcc()
+    {
+        $this->fake->bcc('taylor@laravel.com')->send($this->mailable);
+
+        $this->fake->assertSent(MailableStub::class, function ($mail) {
+            return $mail->hasBcc('taylor@laravel.com');
+        });
+    }
+
     public function testAssertNotSent()
     {
         $this->fake->assertNotSent(MailableStub::class);