| | 394 | |
| | 395 | /** |
| | 396 | * @ticket 28407 |
| | 397 | */ |
| | 398 | public function test_wp_mail_sends_attachments_with_original_name() { |
| | 399 | wp_mail( 'user@example.org', 'Subject', 'Hello World', '', array( |
| | 400 | DIR_TESTDATA . '/images/canola.jpg', |
| | 401 | DIR_TESTDATA . '/images/waffles.jpg' |
| | 402 | ) ); |
| | 403 | |
| | 404 | /** @var PHPMailer $mailer */ |
| | 405 | $mailer = tests_retrieve_phpmailer_instance(); |
| | 406 | |
| | 407 | $attachments = $mailer->getAttachments(); |
| | 408 | |
| | 409 | $expected = array( |
| | 410 | array( |
| | 411 | DIR_TESTDATA . '/images/canola.jpg', |
| | 412 | 'canola.jpg', |
| | 413 | 'canola.jpg', |
| | 414 | 'base64', |
| | 415 | 'image/jpeg', |
| | 416 | false, |
| | 417 | 'attachment', |
| | 418 | 0 |
| | 419 | ), |
| | 420 | array( |
| | 421 | DIR_TESTDATA . '/images/waffles.jpg', |
| | 422 | 'waffles.jpg', |
| | 423 | 'waffles.jpg', |
| | 424 | 'base64', |
| | 425 | 'image/jpeg', |
| | 426 | false, |
| | 427 | 'attachment', |
| | 428 | 0 |
| | 429 | ) |
| | 430 | ); |
| | 431 | |
| | 432 | $this->assertEqualSets( $expected, $attachments ); |
| | 433 | } |
| | 434 | |
| | 435 | /** |
| | 436 | * @ticket 28407 |
| | 437 | */ |
| | 438 | public function test_wp_mail_sends_attachments_with_custom_values() { |
| | 439 | wp_mail( 'user@example.org', 'Subject', 'Hello World', '', array( |
| | 440 | array( |
| | 441 | 'path' => DIR_TESTDATA . '/images/canola.jpg', |
| | 442 | 'name' => 'myawesomeimage.jpg', |
| | 443 | 'encoding' => '8bit', |
| | 444 | 'type' => 'image/jpeg', |
| | 445 | 'disposition' => 'attachment', |
| | 446 | ), |
| | 447 | array( |
| | 448 | 'path' => DIR_TESTDATA . '/images/waffles.jpg', |
| | 449 | 'name' => 'foobar.jpg', |
| | 450 | 'encoding' => 'base64', |
| | 451 | 'type' => 'image/png', |
| | 452 | 'disposition' => 'inline', |
| | 453 | ), |
| | 454 | ) ); |
| | 455 | |
| | 456 | /** @var PHPMailer $mailer */ |
| | 457 | $mailer = tests_retrieve_phpmailer_instance(); |
| | 458 | |
| | 459 | $attachments = $mailer->getAttachments(); |
| | 460 | |
| | 461 | $expected = array( |
| | 462 | array( |
| | 463 | DIR_TESTDATA . '/images/canola.jpg', |
| | 464 | 'canola.jpg', |
| | 465 | 'myawesomeimage.jpg', |
| | 466 | '8bit', |
| | 467 | 'image/jpeg', |
| | 468 | false, |
| | 469 | 'attachment', |
| | 470 | 0 |
| | 471 | ), |
| | 472 | array( |
| | 473 | DIR_TESTDATA . '/images/waffles.jpg', |
| | 474 | 'waffles.jpg', |
| | 475 | 'foobar.jpg', |
| | 476 | 'base64', |
| | 477 | 'image/png', |
| | 478 | false, |
| | 479 | 'inline', |
| | 480 | 0 |
| | 481 | ) |
| | 482 | ); |
| | 483 | |
| | 484 | $this->assertEqualSets( $expected, $attachments ); |
| | 485 | } |