Changeset 42343 for trunk/tests/phpunit/tests/oembed/controller.php
- Timestamp:
- 11/30/2017 11:09:33 PM (8 years ago)
- File:
-
- 1 edited
-
trunk/tests/phpunit/tests/oembed/controller.php (modified) (12 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/oembed/controller.php
r41139 r42343 13 13 protected static $administrator; 14 14 protected static $subscriber; 15 const YOUTUBE_VIDEO_ID = 'OQSNhk5ICTI';15 const YOUTUBE_VIDEO_ID = 'OQSNhk5ICTI'; 16 16 const INVALID_OEMBED_URL = 'https://www.notreallyanoembedprovider.com/watch?v=awesome-cat-video'; 17 17 18 18 public static function wpSetUpBeforeClass( $factory ) { 19 self::$subscriber = $factory->user->create( array( 20 'role' => 'subscriber', 21 ) ); 22 self::$editor = $factory->user->create( array( 23 'role' => 'editor', 24 'user_email' => 'editor@example.com', 25 ) ); 26 self::$administrator = $factory->user->create( array( 27 'role' => 'administrator', 28 'user_email' => 'administrator@example.com', 29 ) ); 19 self::$subscriber = $factory->user->create( 20 array( 21 'role' => 'subscriber', 22 ) 23 ); 24 self::$editor = $factory->user->create( 25 array( 26 'role' => 'editor', 27 'user_email' => 'editor@example.com', 28 ) 29 ); 30 self::$administrator = $factory->user->create( 31 array( 32 'role' => 'administrator', 33 'user_email' => 'administrator@example.com', 34 ) 35 ); 30 36 } 31 37 … … 81 87 'code' => 200, 82 88 ), 83 'body' => wp_json_encode(89 'body' => wp_json_encode( 84 90 array( 85 91 'version' => '1.0', … … 116 122 117 123 function test_oembed_create_xml() { 118 $actual = _oembed_create_xml( array( 119 'foo' => 'bar', 120 'bar' => 'baz', 121 'ping' => 'pong', 122 ) ); 124 $actual = _oembed_create_xml( 125 array( 126 'foo' => 'bar', 127 'bar' => 'baz', 128 'ping' => 'pong', 129 ) 130 ); 123 131 124 132 $expected = '<oembed><foo>bar</foo><bar>baz</bar><ping>pong</ping></oembed>'; … … 126 134 $this->assertStringEndsWith( $expected, trim( $actual ) ); 127 135 128 $actual = _oembed_create_xml( array( 129 'foo' => array( 130 'bar' => 'baz', 131 ), 132 'ping' => 'pong', 133 ) ); 136 $actual = _oembed_create_xml( 137 array( 138 'foo' => array( 139 'bar' => 'baz', 140 ), 141 'ping' => 'pong', 142 ) 143 ); 134 144 135 145 $expected = '<oembed><foo><bar>baz</bar></foo><ping>pong</ping></oembed>'; … … 137 147 $this->assertStringEndsWith( $expected, trim( $actual ) ); 138 148 139 $actual = _oembed_create_xml( array( 140 'foo' => array( 141 'bar' => array( 142 'ping' => 'pong', 149 $actual = _oembed_create_xml( 150 array( 151 'foo' => array( 152 'bar' => array( 153 'ping' => 'pong', 154 ), 143 155 ), 144 ),145 'hello' => 'world',146 ) );156 'hello' => 'world', 157 ) 158 ); 147 159 148 160 $expected = '<oembed><foo><bar><ping>pong</ping></bar></foo><hello>world</hello></oembed>'; … … 150 162 $this->assertStringEndsWith( $expected, trim( $actual ) ); 151 163 152 $actual = _oembed_create_xml( array( 153 array( 154 'foo' => array( 155 'bar', 164 $actual = _oembed_create_xml( 165 array( 166 array( 167 'foo' => array( 168 'bar', 169 ), 156 170 ), 157 ),158 'helloworld',159 ) );171 'helloworld', 172 ) 173 ); 160 174 161 175 $expected = '<oembed><oembed><foo><oembed>bar</oembed></foo></oembed><oembed>helloworld</oembed></oembed>'; … … 228 242 229 243 function test_request_json() { 230 $user = self::factory()->user->create_and_get( array( 231 'display_name' => 'John Doe', 232 ) ); 233 $post = self::factory()->post->create_and_get( array( 234 'post_author' => $user->ID, 235 'post_title' => 'Hello World', 236 ) ); 244 $user = self::factory()->user->create_and_get( 245 array( 246 'display_name' => 'John Doe', 247 ) 248 ); 249 $post = self::factory()->post->create_and_get( 250 array( 251 'post_author' => $user->ID, 252 'post_title' => 'Hello World', 253 ) 254 ); 237 255 238 256 $request = new WP_REST_Request( 'GET', '/oembed/1.0/embed' ); … … 269 287 */ 270 288 function test_request_static_front_page() { 271 $post = self::factory()->post->create_and_get( array( 272 'post_title' => 'Front page', 273 'post_type' => 'page', 274 ) ); 289 $post = self::factory()->post->create_and_get( 290 array( 291 'post_title' => 'Front page', 292 'post_type' => 'page', 293 ) 294 ); 275 295 276 296 update_option( 'show_on_front', 'page' ); … … 309 329 310 330 function test_request_xml() { 311 $user = self::factory()->user->create_and_get( array( 312 'display_name' => 'John Doe', 313 ) ); 314 $post = self::factory()->post->create_and_get( array( 315 'post_author' => $user->ID, 316 'post_title' => 'Hello World', 317 ) ); 331 $user = self::factory()->user->create_and_get( 332 array( 333 'display_name' => 'John Doe', 334 ) 335 ); 336 $post = self::factory()->post->create_and_get( 337 array( 338 'post_author' => $user->ID, 339 'post_title' => 'Hello World', 340 ) 341 ); 318 342 319 343 $request = new WP_REST_Request( 'GET', '/oembed/1.0/embed' ); … … 355 379 switch_to_blog( $child ); 356 380 357 $post = self::factory()->post->create_and_get( array( 358 'post_title' => 'Hello Child Blog', 359 ) ); 381 $post = self::factory()->post->create_and_get( 382 array( 383 'post_title' => 'Hello Child Blog', 384 ) 385 ); 360 386 361 387 $request = new WP_REST_Request( 'GET', '/oembed/1.0/embed' ); … … 373 399 374 400 function test_rest_pre_serve_request() { 375 $user = $this->factory()->user->create_and_get( array( 376 'display_name' => 'John Doe', 377 ) ); 378 $post = $this->factory()->post->create_and_get( array( 379 'post_author' => $user->ID, 380 'post_title' => 'Hello World', 381 ) ); 401 $user = $this->factory()->user->create_and_get( 402 array( 403 'display_name' => 'John Doe', 404 ) 405 ); 406 $post = $this->factory()->post->create_and_get( 407 array( 408 'post_author' => $user->ID, 409 'post_title' => 'Hello World', 410 ) 411 ); 382 412 383 413 $request = new WP_REST_Request( 'GET', '/oembed/1.0/embed' ); … … 447 477 public function test_proxy_without_permission() { 448 478 // Test without a login. 449 $request = new WP_REST_Request( 'GET', '/oembed/1.0/proxy' );479 $request = new WP_REST_Request( 'GET', '/oembed/1.0/proxy' ); 450 480 $response = $this->server->dispatch( $request ); 451 481
Note: See TracChangeset
for help on using the changeset viewer.