WordPress.org

Make WordPress Core

Ticket #21570: 21570-ut.diff

File 21570-ut.diff, 1.0 KB (added by mdawaffe, 6 years ago)
  • tests/ms.php

     
    420420                $this->assertEquals( $post_id2, $post->ID );
    421421                restore_current_blog();
    422422        }
     423
     424        /**
     425         * @ticket 21570
     426         */
     427        function test_is_email_address_unsafe() {
     428                $banned_email_domains = get_site_option( 'banned_email_domains' );
     429                update_site_option( 'banned_email_domains', 'bar.com' );
     430
     431                foreach ( array( 'test@bar.com', 'test@foo.bar.com' ) as $email_address ) {
     432                        $this->assertTrue( is_email_address_unsafe( $email_address ), "$email_address should be UNSAFE" );
     433                }
     434
     435                foreach ( array( 'test@foobar.com', 'test@foo-bar.com' ) as $email_address ) {
     436                        $this->assertFalse( is_email_address_unsafe( $email_address ), "$email_address should be SAFE" );
     437                }
     438
     439                if ( $banned_email_domains ) {
     440                        update_site_option( 'banned_email_domains', $banned_email_domains );
     441                } else {
     442                        delete_site_option( 'banned_email_domains' );
     443                }
     444        }
    423445}
    424446
    425447endif;