|
@@ 368-396 (lines=29) @@
|
| 365 |
|
/** |
| 366 |
|
* Test WP_Fields_API::get_section() |
| 367 |
|
*/ |
| 368 |
|
public function test_get_section() { |
| 369 |
|
|
| 370 |
|
/** |
| 371 |
|
* @var $wp_fields WP_Fields_API |
| 372 |
|
*/ |
| 373 |
|
global $wp_fields; |
| 374 |
|
|
| 375 |
|
// Add a form |
| 376 |
|
$this->test_add_section( $this->object_type, $this->object_name ); |
| 377 |
|
|
| 378 |
|
// Section exists for this object type / name |
| 379 |
|
$section = $wp_fields->get_section( $this->object_type, 'my_test_section', $this->object_name ); |
| 380 |
|
|
| 381 |
|
$this->assertNotEmpty( $section ); |
| 382 |
|
|
| 383 |
|
$this->assertEquals( 'my_test_section', $section->id ); |
| 384 |
|
$this->assertEquals( 'my_test_form', $section->get_form()->id ); |
| 385 |
|
|
| 386 |
|
// Section doesn't exist for this object type / name |
| 387 |
|
$section = $wp_fields->get_section( $this->object_type, 'my_test_section', 'some_other_post_type' ); |
| 388 |
|
|
| 389 |
|
$this->assertEmpty( $section ); |
| 390 |
|
|
| 391 |
|
// Section doesn't exist for this object type / name |
| 392 |
|
$section = $wp_fields->get_section( $this->object_type, 'my_test_section2', $this->object_name ); |
| 393 |
|
|
| 394 |
|
$this->assertEmpty( $section ); |
| 395 |
|
|
| 396 |
|
} |
| 397 |
|
|
| 398 |
|
/** |
| 399 |
|
* Test WP_Fields_API::remove_section() |
|
@@ 485-512 (lines=28) @@
|
| 482 |
|
/** |
| 483 |
|
* Test WP_Fields_API::get_field() |
| 484 |
|
*/ |
| 485 |
|
public function test_get_field() { |
| 486 |
|
|
| 487 |
|
/** |
| 488 |
|
* @var $wp_fields WP_Fields_API |
| 489 |
|
*/ |
| 490 |
|
global $wp_fields; |
| 491 |
|
|
| 492 |
|
// Add a field |
| 493 |
|
$this->test_add_field( $this->object_type, $this->object_name ); |
| 494 |
|
|
| 495 |
|
// Field exists for this object type / name |
| 496 |
|
$field = $wp_fields->get_field( $this->object_type, 'my_test_field', $this->object_name ); |
| 497 |
|
|
| 498 |
|
$this->assertNotEmpty( $field ); |
| 499 |
|
|
| 500 |
|
$this->assertEquals( 'my_test_field', $field->id ); |
| 501 |
|
|
| 502 |
|
// Field doesn't exist for this object type / name |
| 503 |
|
$field = $wp_fields->get_field( $this->object_type, 'my_test_field', 'some_other_post_type' ); |
| 504 |
|
|
| 505 |
|
$this->assertEmpty( $field ); |
| 506 |
|
|
| 507 |
|
// Field doesn't exist for this object type / name |
| 508 |
|
$field = $wp_fields->get_field( $this->object_type, 'my_test_field2', $this->object_name ); |
| 509 |
|
|
| 510 |
|
$this->assertEmpty( $field ); |
| 511 |
|
|
| 512 |
|
} |
| 513 |
|
|
| 514 |
|
/** |
| 515 |
|
* Test WP_Fields_API::remove_field() |