���� JFIF �� � ( %"1"%)+...383,7(-.-
![]() Server : Apache/2.4.6 (CentOS) OpenSSL/1.0.2k-fips PHP/7.4.20 System : Linux st2.domain.com 3.10.0-1127.10.1.el7.x86_64 #1 SMP Wed Jun 3 14:28:03 UTC 2020 x86_64 User : apache ( 48) PHP Version : 7.4.20 Disable Function : NONE Directory : /var/www/html/123vid/vendor/monolog/monolog/tests/Monolog/Handler/ |
<?php /* * This file is part of the Monolog package. * * (c) Jordi Boggiano <[email protected]> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Monolog\Handler; use Monolog\TestCase; use Monolog\Logger; use InvalidArgumentException; function mail($to, $subject, $message, $additional_headers = null, $additional_parameters = null) { $GLOBALS['mail'][] = func_get_args(); } class NativeMailerHandlerTest extends TestCase { protected function setUp() { $GLOBALS['mail'] = array(); } /** * @expectedException InvalidArgumentException */ public function testConstructorHeaderInjection() { $mailer = new NativeMailerHandler('[email protected]', 'dear victim', "[email protected]\r\nFrom: [email protected]"); } /** * @expectedException InvalidArgumentException */ public function testSetterHeaderInjection() { $mailer = new NativeMailerHandler('[email protected]', 'dear victim', '[email protected]'); $mailer->addHeader("Content-Type: text/html\r\nFrom: [email protected]"); } /** * @expectedException InvalidArgumentException */ public function testSetterArrayHeaderInjection() { $mailer = new NativeMailerHandler('[email protected]', 'dear victim', '[email protected]'); $mailer->addHeader(array("Content-Type: text/html\r\nFrom: [email protected]")); } /** * @expectedException InvalidArgumentException */ public function testSetterContentTypeInjection() { $mailer = new NativeMailerHandler('[email protected]', 'dear victim', '[email protected]'); $mailer->setContentType("text/html\r\nFrom: [email protected]"); } /** * @expectedException InvalidArgumentException */ public function testSetterEncodingInjection() { $mailer = new NativeMailerHandler('[email protected]', 'dear victim', '[email protected]'); $mailer->setEncoding("utf-8\r\nFrom: [email protected]"); } public function testSend() { $to = '[email protected]'; $subject = 'dear victim'; $from = '[email protected]'; $mailer = new NativeMailerHandler($to, $subject, $from); $mailer->handleBatch(array()); // batch is empty, nothing sent $this->assertEmpty($GLOBALS['mail']); // non-empty batch $mailer->handle($this->getRecord(Logger::ERROR, "Foo\nBar\r\n\r\nBaz")); $this->assertNotEmpty($GLOBALS['mail']); $this->assertInternalType('array', $GLOBALS['mail']); $this->assertArrayHasKey('0', $GLOBALS['mail']); $params = $GLOBALS['mail'][0]; $this->assertCount(5, $params); $this->assertSame($to, $params[0]); $this->assertSame($subject, $params[1]); $this->assertStringEndsWith(" test.ERROR: Foo Bar Baz [] []\n", $params[2]); $this->assertSame("From: $from\r\nContent-type: text/plain; charset=utf-8\r\n", $params[3]); $this->assertSame('', $params[4]); } public function testMessageSubjectFormatting() { $mailer = new NativeMailerHandler('[email protected]', 'Alert: %level_name% %message%', '[email protected]'); $mailer->handle($this->getRecord(Logger::ERROR, "Foo\nBar\r\n\r\nBaz")); $this->assertNotEmpty($GLOBALS['mail']); $this->assertInternalType('array', $GLOBALS['mail']); $this->assertArrayHasKey('0', $GLOBALS['mail']); $params = $GLOBALS['mail'][0]; $this->assertCount(5, $params); $this->assertSame('Alert: ERROR Foo Bar Baz', $params[1]); } }