Find this useful? Enter your email to receive occasional updates for securing PHP code.
Signing you up...
Thank you for signing up!
PHP Decode
<?php namespace Illuminate\Tests\Mail; use Illuminate\Mail\Mailable; use Illuminate\Mail..
Decoded Output download
<?php
namespace Illuminate\Tests\Mail;
use Illuminate\Mail\Mailable;
use Illuminate\Mail\Mailables\Address;
use Illuminate\Mail\Mailables\Content;
use Illuminate\Mail\Mailables\Envelope;
use PHPUnit\Framework\TestCase;
use ReflectionClass;
class MailableAlternativeSyntaxTest extends TestCase
{
public function testBasicMailableInspection()
{
$mailable = new MailableWithAlternativeSyntax;
$this->assertTrue($mailable->hasTo('[email protected]'));
$this->assertTrue($mailable->hasCc('[email protected]'));
$this->assertTrue($mailable->hasBcc('[email protected]'));
$this->assertTrue($mailable->hasTo('[email protected]', 'Taylor Otwell'));
$this->assertFalse($mailable->hasTo('[email protected]', 'Wrong Name'));
$mailable->to(new Address('[email protected]', 'Abigail Otwell'));
$this->assertTrue($mailable->hasTo('[email protected]', 'Taylor Otwell'));
$this->assertTrue($mailable->hasSubject('Test Subject'));
$this->assertFalse($mailable->hasSubject('Wrong Subject'));
$this->assertTrue($mailable->hasTag('tag-1'));
$this->assertTrue($mailable->hasMetadata('test-meta', 'test-meta-value'));
$reflection = new ReflectionClass($mailable);
$method = $reflection->getMethod('prepareMailableForDelivery');
$method->invoke($mailable);
$this->assertEquals('test-view', $mailable->view);
$this->assertEquals(['test-data-key' => 'test-data-value'], $mailable->viewData);
$this->assertEquals(2, count($mailable->to));
$this->assertEquals(1, count($mailable->cc));
$this->assertEquals(1, count($mailable->bcc));
}
public function testEnvelopesCanReceiveAdditionalRecipients()
{
$envelope = new Envelope(to: ['[email protected]']);
$envelope->to(new Address('[email protected]'));
$this->assertCount(2, $envelope->to);
$this->assertEquals('[email protected]', $envelope->to[0]->address);
$this->assertEquals('[email protected]', $envelope->to[1]->address);
$envelope->to('[email protected]', 'Abigail Otwell');
$this->assertEquals('[email protected]', $envelope->to[2]->address);
$this->assertEquals('Abigail Otwell', $envelope->to[2]->name);
$envelope->to('[email protected]');
$this->assertEquals('[email protected]', $envelope->to[3]->address);
$this->assertNull($envelope->to[3]->name);
$envelope->to(['[email protected]', '[email protected]']);
$this->assertEquals('[email protected]', $envelope->to[4]->address);
$this->assertEquals('[email protected]', $envelope->to[5]->address);
$envelope->from('[email protected]', 'Dries Vints');
$this->assertEquals('[email protected]', $envelope->from->address);
$this->assertEquals('Dries Vints', $envelope->from->name);
}
}
class MailableWithAlternativeSyntax extends Mailable
{
public function envelope()
{
return new Envelope(
to: [new Address('[email protected]', 'Taylor Otwell')],
cc: [new Address('[email protected]', 'Adam Wathan')],
bcc: [new Address('[email protected]', 'Tyler Blair')],
subject: 'Test Subject',
tags: ['tag-1', 'tag-2'],
metadata: ['test-meta' => 'test-meta-value'],
);
}
public function content()
{
return new Content(
view: 'test-view',
with: ['test-data-key' => 'test-data-value'],
);
}
}
?>
Did this file decode correctly?
Original Code
<?php
namespace Illuminate\Tests\Mail;
use Illuminate\Mail\Mailable;
use Illuminate\Mail\Mailables\Address;
use Illuminate\Mail\Mailables\Content;
use Illuminate\Mail\Mailables\Envelope;
use PHPUnit\Framework\TestCase;
use ReflectionClass;
class MailableAlternativeSyntaxTest extends TestCase
{
public function testBasicMailableInspection()
{
$mailable = new MailableWithAlternativeSyntax;
$this->assertTrue($mailable->hasTo('[email protected]'));
$this->assertTrue($mailable->hasCc('[email protected]'));
$this->assertTrue($mailable->hasBcc('[email protected]'));
$this->assertTrue($mailable->hasTo('[email protected]', 'Taylor Otwell'));
$this->assertFalse($mailable->hasTo('[email protected]', 'Wrong Name'));
$mailable->to(new Address('[email protected]', 'Abigail Otwell'));
$this->assertTrue($mailable->hasTo('[email protected]', 'Taylor Otwell'));
$this->assertTrue($mailable->hasSubject('Test Subject'));
$this->assertFalse($mailable->hasSubject('Wrong Subject'));
$this->assertTrue($mailable->hasTag('tag-1'));
$this->assertTrue($mailable->hasMetadata('test-meta', 'test-meta-value'));
$reflection = new ReflectionClass($mailable);
$method = $reflection->getMethod('prepareMailableForDelivery');
$method->invoke($mailable);
$this->assertEquals('test-view', $mailable->view);
$this->assertEquals(['test-data-key' => 'test-data-value'], $mailable->viewData);
$this->assertEquals(2, count($mailable->to));
$this->assertEquals(1, count($mailable->cc));
$this->assertEquals(1, count($mailable->bcc));
}
public function testEnvelopesCanReceiveAdditionalRecipients()
{
$envelope = new Envelope(to: ['[email protected]']);
$envelope->to(new Address('[email protected]'));
$this->assertCount(2, $envelope->to);
$this->assertEquals('[email protected]', $envelope->to[0]->address);
$this->assertEquals('[email protected]', $envelope->to[1]->address);
$envelope->to('[email protected]', 'Abigail Otwell');
$this->assertEquals('[email protected]', $envelope->to[2]->address);
$this->assertEquals('Abigail Otwell', $envelope->to[2]->name);
$envelope->to('[email protected]');
$this->assertEquals('[email protected]', $envelope->to[3]->address);
$this->assertNull($envelope->to[3]->name);
$envelope->to(['[email protected]', '[email protected]']);
$this->assertEquals('[email protected]', $envelope->to[4]->address);
$this->assertEquals('[email protected]', $envelope->to[5]->address);
$envelope->from('[email protected]', 'Dries Vints');
$this->assertEquals('[email protected]', $envelope->from->address);
$this->assertEquals('Dries Vints', $envelope->from->name);
}
}
class MailableWithAlternativeSyntax extends Mailable
{
public function envelope()
{
return new Envelope(
to: [new Address('[email protected]', 'Taylor Otwell')],
cc: [new Address('[email protected]', 'Adam Wathan')],
bcc: [new Address('[email protected]', 'Tyler Blair')],
subject: 'Test Subject',
tags: ['tag-1', 'tag-2'],
metadata: ['test-meta' => 'test-meta-value'],
);
}
public function content()
{
return new Content(
view: 'test-view',
with: ['test-data-key' => 'test-data-value'],
);
}
}
Function Calls
None |
Stats
MD5 | 41a5825901bcd81d3ccd399fec7289c3 |
Eval Count | 0 |
Decode Time | 85 ms |