|
| 1 | +<?php |
| 2 | + |
| 3 | +/* |
| 4 | + * This file is part of the Symfony package. |
| 5 | + * |
| 6 | + * (c) Fabien Potencier <fabien@symfony.com> |
| 7 | + * |
| 8 | + * For the full copyright and license information, please view the LICENSE |
| 9 | + * file that was distributed with this source code. |
| 10 | + */ |
| 11 | + |
| 12 | +namespace Symfony\Component\Notifier\Tests\Message; |
| 13 | + |
| 14 | +use PHPUnit\Framework\TestCase; |
| 15 | +use Symfony\Component\Notifier\Message\PushMessage; |
| 16 | +use Symfony\Component\Notifier\Notification\Notification; |
| 17 | + |
| 18 | +/** |
| 19 | + * @author Tomas Norkūnas <norkunas.tom@gmail.com> |
| 20 | + */ |
| 21 | +class PushMessageTest extends TestCase |
| 22 | +{ |
| 23 | + public function testCanBeConstructed() |
| 24 | + { |
| 25 | + $message = new PushMessage('Hello', 'World'); |
| 26 | + |
| 27 | + $this->assertSame('Hello', $message->getSubject()); |
| 28 | + $this->assertSame('World', $message->getContent()); |
| 29 | + } |
| 30 | + |
| 31 | + public function testSetSubject() |
| 32 | + { |
| 33 | + $message = new PushMessage('Hello', 'World'); |
| 34 | + $message->subject('dlrow olleH'); |
| 35 | + |
| 36 | + $this->assertSame('dlrow olleH', $message->getSubject()); |
| 37 | + } |
| 38 | + |
| 39 | + public function testSetContent() |
| 40 | + { |
| 41 | + $message = new PushMessage('Hello', 'World'); |
| 42 | + $message->content('dlrow olleH'); |
| 43 | + |
| 44 | + $this->assertSame('dlrow olleH', $message->getContent()); |
| 45 | + } |
| 46 | + |
| 47 | + public function testSetTransport() |
| 48 | + { |
| 49 | + $message = new PushMessage('Hello', 'World'); |
| 50 | + $message->transport('next_one'); |
| 51 | + |
| 52 | + $this->assertSame('next_one', $message->getTransport()); |
| 53 | + } |
| 54 | + |
| 55 | + public function testCreateFromNotification() |
| 56 | + { |
| 57 | + $notification = new Notification('Hello'); |
| 58 | + $notification->content('World'); |
| 59 | + |
| 60 | + $message = PushMessage::fromNotification($notification); |
| 61 | + |
| 62 | + $this->assertSame('Hello', $message->getSubject()); |
| 63 | + $this->assertSame('World', $message->getContent()); |
| 64 | + $this->assertSame($notification, $message->getNotification()); |
| 65 | + } |
| 66 | +} |
0 commit comments