8000 feature #35534 [FrameworkBundle] Use MailerAssertionsTrait in KernelT… · Pchol/symfony@626999c · GitHub
[go: up one dir, main page]

Skip to content

Commit 626999c

Browse files
committed
feature symfony#35534 [FrameworkBundle] Use MailerAssertionsTrait in KernelTestCase (adrienfr)
This PR was merged into the 5.1-dev branch. Discussion ---------- [FrameworkBundle] Use MailerAssertionsTrait in KernelTestCase | Q | A | ------------- | --- | Branch? | 4.4+ | Bug fix? | no | New feature? | yes | Deprecations? | no | Tickets | Fix symfony#35510 | License | MIT | Doc PR | Since 4.4, we have new PHPUnit constraints for the mailer component, but these are only available with `WebTestCase` and not `KernelTestCase`. I think this would be useful to access these constraints from both TestCase. I don't know if I should move these [tests](https://github.com/symfony/symfony/blob/master/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/MailerTest.php) or add new ones only for `KernelTestCase`? Commits ------- 1b1ab29 [FrameworkBundle] Use MailerAssertionsTrait in KernelTestCase
2 parents 7a4637e + 1b1ab29 commit 626999c

File tree

4 files changed

+3
-5
lines changed

4 files changed

+3
-5
lines changed

src/Symfony/Bundle/FrameworkBundle/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ CHANGELOG
5555
* Made `framework.session.handler_id` accept a DSN
5656
* Marked the `RouterDataCollector` class as `@final`.
5757
* [BC Break] The `framework.messenger.buses.<name>.middleware` config key is not deeply merged anymore.
58+
* Moved `MailerAssertionsTrait` in `KernelTestCase`
5859

5960
4.3.0
6061
-----

src/Symfony/Bundle/FrameworkBundle/Test/KernelTestCase.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@
2323
*/
2424
abstract class KernelTestCase extends TestCase
2525
{
26+
use MailerAssertionsTrait;
27+
2628
protected static $class;
2729

2830
/**

src/Symfony/Bundle/FrameworkBundle/Test/MailerAssertionsTrait.php

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -118,10 +118,6 @@ public static function getMailerMessage(int $index = 0, string $transport = null
118118

119119
private static function getMessageMailerEvents(): MessageEvents
120120
{
121-
if (!self::getClient()->getRequest()) {
122-
static::fail('Unable to make email assertions. Did you forget to make an HTTP request?');
123-
}
124-
125121
if (!$logger = self::$container->get('mailer.logger_message_listener')) {
126122
8570 static::fail('A client must have Mailer enabled to make email assertions. Did you forget to require symfony/mailer?');
127123
}

src/Symfony/Bundle/FrameworkBundle/Test/WebTestCase.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
abstract class WebTestCase extends KernelTestCase
2323
{
2424
use WebTestAssertionsTrait;
25-
use MailerAssertionsTrait;
2625

2726
protected function tearDown(): void
2827
{

0 commit comments

Comments
 (0)
0