WordPress.org

Make WordPress Core

Ticket #30180: 30180-unit-test.patch

File 30180-unit-test.patch, 825 bytes (added by collinsinternet, 5 years ago)

Unit test to test return of alt.

  • tests/phpunit/tests/media.php

     
    443443                $this->assertTrue( has_image_size( 'test-size' ) );
    444444        }
    445445
     446        /**
     447         * @ticket 30180
     448         */
     449        function test_wp_attachment_image_src_alt() {
     450                $post_id                 = $this->factory->post->create();
     451                $attachment_id   = $this->factory->attachment->create_object( $this->img_name, $post_id, array(
     452                        'post_mime_type' => 'image/jpeg',
     453                        'post_type'              => 'attachment'
     454                ) );
     455                $alt_text                = 'This is ALT text.';
     456                update_post_meta( $attachment_id, '_wp_attachment_image_alt', $alt_text );
     457                $attachment              = wp_get_attachment_image_src( $attachment_id );
     458                $this->assertEquals( $alt_text, $attachment[ 3 ], 'ALT tag returned matches what was set.' );
    446459}
     460
     461}