-
-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c71c7a1
commit eb930b8
Showing
10 changed files
with
249 additions
and
1 deletion.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -44,6 +44,14 @@ public function testCreate() | |
$this->assertEquals($a, Address::create('[email protected]')); | ||
} | ||
|
||
public function testCreateWithInvalidFormat() | ||
{ | ||
$this->expectException(InvalidArgumentException::class); | ||
$this->expectExceptionMessage('Could not parse "<fabien@symfony" to a "Symfony\Component\Mime\Address" instance.'); | ||
|
||
Address::create('<fabien@symfony'); | ||
} | ||
|
||
/** | ||
* @dataProvider fromStringProvider | ||
*/ | ||
|
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the Symfony package. | ||
* | ||
* (c) Fabien Potencier <[email protected]> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Symfony\Component\Mime\Tests\Encoder; | ||
|
||
use PHPUnit\Framework\TestCase; | ||
use Symfony\Component\Mime\Encoder\QpContentEncoder; | ||
|
||
class QpContentEncoderTest extends TestCase | ||
{ | ||
public function testReplaceLastChar() | ||
{ | ||
$encoder = new QpContentEncoder(); | ||
|
||
$this->assertSame('message=09', $encoder->encodeString('message'.chr(0x09))); | ||
$this->assertSame('message=20', $encoder->encodeString('message'.chr(0x20))); | ||
} | ||
} |
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the Symfony package. | ||
* | ||
* (c) Fabien Potencier <[email protected]> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Symfony\Component\Mime\Tests\Test\Constraint; | ||
|
||
use PHPUnit\Framework\ExpectationFailedException; | ||
use PHPUnit\Framework\TestCase; | ||
use Symfony\Component\Mime\Email; | ||
use Symfony\Component\Mime\Header\Headers; | ||
use Symfony\Component\Mime\Test\Constraint\EmailAddressContains; | ||
|
||
class EmailAddressContainsTest extends TestCase | ||
{ | ||
public function testToString() | ||
{ | ||
$constraint = new EmailAddressContains('headerName', 'expectedValue'); | ||
|
||
$this->assertSame('contains address "headerName" with value "expectedValue"', $constraint->toString()); | ||
} | ||
|
||
public function testFailureDescription() | ||
{ | ||
$mailboxHeader = '[email protected]'; | ||
$headers = new Headers(); | ||
$headers->addMailboxHeader($mailboxHeader, '[email protected]'); | ||
|
||
$this->expectException(ExpectationFailedException::class); | ||
$this->expectExceptionMessage('Failed asserting that the Email contains address "[email protected]" with value "[email protected]" (value is [email protected]).'); | ||
|
||
(new EmailAddressContains($mailboxHeader, '[email protected]'))->evaluate(new Email($headers)); | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the Symfony package. | ||
* | ||
* (c) Fabien Potencier <[email protected]> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Symfony\Component\Mime\Tests\Test\Constraint; | ||
|
||
use PHPUnit\Framework\ExpectationFailedException; | ||
use PHPUnit\Framework\TestCase; | ||
use Symfony\Component\Mime\Email; | ||
use Symfony\Component\Mime\Test\Constraint\EmailAttachmentCount; | ||
|
||
class EmailAttachmentCountTest extends TestCase | ||
{ | ||
public function testToString() | ||
{ | ||
$constraint = new EmailAttachmentCount(1); | ||
|
||
$this->assertSame('has sent "1" attachment(s)', $constraint->toString()); | ||
} | ||
|
||
public function testFailureDescription() | ||
{ | ||
$email = new Email(); | ||
$email->attach('attachment content', 'attachment.txt'); | ||
|
||
$this->expectException(ExpectationFailedException::class); | ||
$this->expectExceptionMessage('Failed asserting that the Email has sent "2" attachment(s).'); | ||
|
||
(new EmailAttachmentCount(2))->evaluate($email); | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the Symfony package. | ||
* | ||
* (c) Fabien Potencier <[email protected]> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Symfony\Component\Mime\Tests\Test\Constraint; | ||
|
||
use PHPUnit\Framework\ExpectationFailedException; | ||
use PHPUnit\Framework\TestCase; | ||
use Symfony\Component\Mime\Email; | ||
use Symfony\Component\Mime\Header\Headers; | ||
use Symfony\Component\Mime\Test\Constraint\EmailHasHeader; | ||
|
||
class EmailHasHeaderTest extends TestCase | ||
{ | ||
public function testToString() | ||
{ | ||
$constraint = new EmailHasHeader('headerName'); | ||
|
||
$this->assertSame('has header "headerName"', $constraint->toString()); | ||
} | ||
|
||
public function testFailureDescription() | ||
{ | ||
$headers = new Headers(); | ||
$headers->addMailboxHeader('headerName', '[email protected]'); | ||
|
||
$this->expectException(ExpectationFailedException::class); | ||
$this->expectExceptionMessage('Failed asserting that the Email has header "not existing header".'); | ||
|
||
(new EmailHasHeader('not existing header'))->evaluate(new Email($headers)); | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the Symfony package. | ||
* | ||
* (c) Fabien Potencier <[email protected]> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Symfony\Component\Mime\Tests\Test\Constraint; | ||
|
||
use PHPUnit\Framework\ExpectationFailedException; | ||
use PHPUnit\Framework\TestCase; | ||
use Symfony\Component\Mime\Email; | ||
use Symfony\Component\Mime\Test\Constraint\EmailHtmlBodyContains; | ||
|
||
class EmailHtmlBodyContainsTest extends TestCase | ||
{ | ||
public function testToString() | ||
{ | ||
$constraint = new EmailHtmlBodyContains('expectedValue'); | ||
|
||
$this->assertSame('contains "expectedValue"', $constraint->toString()); | ||
} | ||
|
||
public function testFailureDescription() | ||
{ | ||
$expectedValue = 'expectedValue'; | ||
$email = new Email(); | ||
$email->html('actualValue')->text($expectedValue); | ||
|
||
$this->expectException(ExpectationFailedException::class); | ||
$this->expectExceptionMessage('Failed asserting that the Email HTML body contains "expectedValue".'); | ||
|
||
(new EmailHtmlBodyContains($expectedValue))->evaluate($email); | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the Symfony package. | ||
* | ||
* (c) Fabien Potencier <[email protected]> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Symfony\Component\Mime\Tests\Test\Constraint; | ||
|
||
use PHPUnit\Framework\ExpectationFailedException; | ||
use PHPUnit\Framework\TestCase; | ||
use Symfony\Component\Mime\Email; | ||
use Symfony\Component\Mime\Test\Constraint\EmailTextBodyContains; | ||
|
||
class EmailTextBodyContainsTest extends TestCase | ||
{ | ||
public function testToString() | ||
{ | ||
$constraint = new EmailTextBodyContains('expectedValue'); | ||
|
||
$this->assertSame('contains "expectedValue"', $constraint->toString()); | ||
} | ||
|
||
public function testFailureDescription() | ||
{ | ||
$expectedValue = 'expectedValue'; | ||
$email = new Email(); | ||
$email->html($expectedValue)->text('actualValue'); | ||
|
||
$this->expectException(ExpectationFailedException::class); | ||
$this->expectExceptionMessage('Failed asserting that the Email text body contains "expectedValue".'); | ||
|
||
(new EmailTextBodyContains($expectedValue))->evaluate($email); | ||
} | ||
} |