WordPress.org

Make WordPress Core

Changeset 1071 in tests


Ignore:
Timestamp:
10/04/2012 05:02:37 AM (6 years ago)
Author:
alexkingorg
Message:

this completes the initial set of slash tests

Location:
trunk/tests
Files:
6 added
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/meta/slashes.php

    r1041 r1071  
    221221    }
    222222
     223    /**
     224     * Tests the model function that expects un-slashed data
     225     *
     226     */
     227    function test_add_user_meta() {
     228        $id = $this->factory->user->create();
     229
     230        add_user_meta( $id, 'slash_test_1', $this->slash_1 );
     231        add_user_meta( $id, 'slash_test_2', $this->slash_3 );
     232        add_user_meta( $id, 'slash_test_3', $this->slash_5 );
     233
     234        $this->assertEquals( $this->slash_1, get_user_meta( $id, 'slash_test_1', true ) );
     235        $this->assertEquals( $this->slash_3, get_user_meta( $id, 'slash_test_2', true ) );
     236        $this->assertEquals( $this->slash_5, get_user_meta( $id, 'slash_test_3', true ) );
     237
     238        add_user_meta( $id, 'slash_test_4', $this->slash_2 );
     239        add_user_meta( $id, 'slash_test_5', $this->slash_4 );
     240        add_user_meta( $id, 'slash_test_6', $this->slash_6 );
     241
     242        $this->assertEquals( $this->slash_2, get_user_meta( $id, 'slash_test_4', true ) );
     243        $this->assertEquals( $this->slash_4, get_user_meta( $id, 'slash_test_5', true ) );
     244        $this->assertEquals( $this->slash_6, get_user_meta( $id, 'slash_test_6', true ) );
     245    }
     246
     247    /**
     248     * Tests the model function that expects un-slashed data
     249     *
     250     */
     251    function test_update_user_meta() {
     252        $id = $this->factory->user->create();
     253
     254        add_user_meta( $id, 'slash_test_1', 'foo' );
     255        add_user_meta( $id, 'slash_test_2', 'foo' );
     256        add_user_meta( $id, 'slash_test_3', 'foo' );
     257
     258        update_user_meta( $id, 'slash_test_1', $this->slash_1 );
     259        update_user_meta( $id, 'slash_test_2', $this->slash_3 );
     260        update_user_meta( $id, 'slash_test_3', $this->slash_5 );
     261
     262        $this->assertEquals( $this->slash_1, get_user_meta( $id, 'slash_test_1', true ) );
     263        $this->assertEquals( $this->slash_3, get_user_meta( $id, 'slash_test_2', true ) );
     264        $this->assertEquals( $this->slash_5, get_user_meta( $id, 'slash_test_3', true ) );
     265
     266        update_user_meta( $id, 'slash_test_1', $this->slash_2 );
     267        update_user_meta( $id, 'slash_test_2', $this->slash_4 );
     268        update_user_meta( $id, 'slash_test_3', $this->slash_6 );
     269
     270        $this->assertEquals( $this->slash_2, get_user_meta( $id, 'slash_test_1', true ) );
     271        $this->assertEquals( $this->slash_4, get_user_meta( $id, 'slash_test_2', true ) );
     272        $this->assertEquals( $this->slash_6, get_user_meta( $id, 'slash_test_3', true ) );
     273    }
     274
    223275}
Note: See TracChangeset for help on using the changeset viewer.