Ngiler SH3LL 360
Home
Information
Create File
Create Folder
:
/
home
/
tbf
/
conferinta_tbf
/
vendor
/
symfony
/
mime
/
Tests
/
Part
/
Information Server
MySQL :
OFF
Perl :
OFF
CURL :
ON
WGET :
OFF
PKEXEC :
OFF
Directive
Local Value
IP Address
89.40.16.97
System
Linux server.atelieruldeit.ro 3.10.0-1160.el7.x86_64 #1 SMP Mon Oct 19 16:18:59 UTC 2020 x86_64
User
tbf
PHP Version
7.3.33
Software
Apache
Doc root
Writable
close
Edit File :
TextPartTest.php
| Size :
3.29
KB
Copy
<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Mime\Tests\Part; use PHPUnit\Framework\TestCase; use Symfony\Component\Mime\Header\Headers; use Symfony\Component\Mime\Header\ParameterizedHeader; use Symfony\Component\Mime\Header\UnstructuredHeader; use Symfony\Component\Mime\Part\TextPart; class TextPartTest extends TestCase { public function testConstructor() { $p = new TextPart('content'); $this->assertEquals('content', $p->getBody()); $this->assertEquals('content', $p->bodyToString()); $this->assertEquals('content', implode('', iterator_to_array($p->bodyToIterable()))); // bodyToIterable() can be called several times $this->assertEquals('content', implode('', iterator_to_array($p->bodyToIterable()))); $this->assertEquals('text', $p->getMediaType()); $this->assertEquals('plain', $p->getMediaSubType()); $p = new TextPart('content', null, 'html'); $this->assertEquals('html', $p->getMediaSubType()); } public function testConstructorWithResource() { $f = fopen('php://memory', 'r+', false); fwrite($f, 'content'); rewind($f); $p = new TextPart($f); $this->assertEquals('content', $p->getBody()); $this->assertEquals('content', $p->bodyToString()); $this->assertEquals('content', implode('', iterator_to_array($p->bodyToIterable()))); fclose($f); } public function testConstructorWithNonStringOrResource() { $this->expectException(\TypeError::class); new TextPart(new \stdClass()); } public function testHeaders() { $p = new TextPart('content'); $this->assertEquals(new Headers( new ParameterizedHeader('Content-Type', 'text/plain', ['charset' => 'utf-8']), new UnstructuredHeader('Content-Transfer-Encoding', 'quoted-printable') ), $p->getPreparedHeaders()); $p = new TextPart('content', 'iso-8859-1'); $this->assertEquals(new Headers( new ParameterizedHeader('Content-Type', 'text/plain', ['charset' => 'iso-8859-1']), new UnstructuredHeader('Content-Transfer-Encoding', 'quoted-printable') ), $p->getPreparedHeaders()); } public function testEncoding() { $p = new TextPart('content', 'utf-8', 'plain', 'base64'); $this->assertEquals(base64_encode('content'), $p->bodyToString()); $this->assertEquals(base64_encode('content'), implode('', iterator_to_array($p->bodyToIterable()))); $this->assertEquals(new Headers( new ParameterizedHeader('Content-Type', 'text/plain', ['charset' => 'utf-8']), new UnstructuredHeader('Content-Transfer-Encoding', 'base64') ), $p->getPreparedHeaders()); } public function testSerialize() { $r = fopen('php://memory', 'r+', false); fwrite($r, 'Text content'); rewind($r); $p = new TextPart($r); $p->getHeaders()->addTextHeader('foo', 'bar'); $expected = clone $p; $this->assertEquals($expected->toString(), unserialize(serialize($p))->toString()); } }
Back