| | 458 | * Test that attachment file names are derived from array values when their |
| | 459 | * associative array keys are numeric. |
| | 460 | * |
| | 461 | * @ticket 28407 |
| | 462 | */ |
| | 463 | public function test_wp_mail_sends_attachments_with_original_name() { |
| | 464 | wp_mail( 'user@example.org', 'Subject', 'Hello World', '', array( |
| | 465 | DIR_TESTDATA . '/images/canola.jpg', |
| | 466 | DIR_TESTDATA . '/images/waffles.jpg' |
| | 467 | ) ); |
| | 468 | |
| | 469 | /** @var PHPMailer $mailer */ |
| | 470 | $mailer = tests_retrieve_phpmailer_instance(); |
| | 471 | |
| | 472 | $attachments = $mailer->getAttachments(); |
| | 473 | |
| | 474 | $this->assertTrue( $mailer->attachmentExists() ); |
| | 475 | $this->assertSame( $attachments[0][1], $attachments[0][2] ); |
| | 476 | $this->assertSame( $attachments[1][1], $attachments[1][2] ); |
| | 477 | } |
| | 478 | |
| | 479 | /** |
| | 480 | * Test that attachment file names are derived from array keys when they |
| | 481 | * are non-empty strings. |
| | 482 | * |
| | 483 | * @ticket 28407 |
| | 484 | */ |
| | 485 | public function test_wp_mail_sends_attachments_with_custom_name() { |
| | 486 | wp_mail( 'user@example.org', 'Subject', 'Hello World', '', array( |
| | 487 | 'alonac.jpg' => DIR_TESTDATA . '/images/canola.jpg', |
| | 488 | 'selffaw.jpg' => DIR_TESTDATA . '/images/waffles.jpg' |
| | 489 | ) ); |
| | 490 | |
| | 491 | /** @var PHPMailer $mailer */ |
| | 492 | $mailer = tests_retrieve_phpmailer_instance(); |
| | 493 | |
| | 494 | $attachments = $mailer->getAttachments(); |
| | 495 | |
| | 496 | $this->assertTrue( $mailer->attachmentExists() ); |
| | 497 | $this->assertSame( 'alonac.jpg', $attachments[0][2] ); |
| | 498 | $this->assertSame( 'selffaw.jpg', $attachments[1][2] ); |
| | 499 | } |
| | 500 | |
| | 501 | /** |