Changeset 43571 for trunk/tests/phpunit/tests/post/getPostTypeLabels.php
- Timestamp:
- 08/17/2018 01:50:26 AM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/post/getPostTypeLabels.php
r42490 r43571 6 6 class Tests_Get_Post_Type_Labels extends WP_UnitTestCase { 7 7 public function test_returns_an_object() { 8 $this->assertInternalType( 'object', get_post_type_labels( (object) array( 9 'name' => 'foo', 10 'labels' => array(), 11 'hierarchical' => false, 12 ) ) ); 8 $this->assertInternalType( 9 'object', 10 get_post_type_labels( 11 (object) array( 12 'name' => 'foo', 13 'labels' => array(), 14 'hierarchical' => false, 15 ) 16 ) 17 ); 13 18 } 14 19 15 20 public function test_returns_hierachical_labels() { 16 $labels = get_post_type_labels( (object) array( 17 'name' => 'foo', 18 'labels' => array(), 19 'hierarchical' => true, 20 ) ); 21 $labels = get_post_type_labels( 22 (object) array( 23 'name' => 'foo', 24 'labels' => array(), 25 'hierarchical' => true, 26 ) 27 ); 21 28 22 29 $this->assertSame( 'Pages', $labels->name ); … … 24 31 25 32 public function test_existing_labels_are_not_overridden() { 26 $labels = get_post_type_labels( (object) array( 27 'name' => 'foo', 28 'labels' => array( 29 'singular_name' => 'Foo', 30 ), 31 'hierarchical' => false, 32 ) ); 33 $labels = get_post_type_labels( 34 (object) array( 35 'name' => 'foo', 36 'labels' => array( 37 'singular_name' => 'Foo', 38 ), 39 'hierarchical' => false, 40 ) 41 ); 33 42 34 43 $this->assertSame( 'Foo', $labels->singular_name ); … … 36 45 37 46 public function test_name_admin_bar_label_should_fall_back_to_singular_name() { 38 $labels = get_post_type_labels( (object) array( 39 'name' => 'foo', 40 'labels' => array( 41 'singular_name' => 'Foo', 42 ), 43 'hierarchical' => false, 44 ) ); 47 $labels = get_post_type_labels( 48 (object) array( 49 'name' => 'foo', 50 'labels' => array( 51 'singular_name' => 'Foo', 52 ), 53 'hierarchical' => false, 54 ) 55 ); 45 56 46 57 $this->assertSame( 'Foo', $labels->name_admin_bar ); … … 49 60 50 61 public function test_name_admin_bar_label_should_fall_back_to_post_type_name() { 51 $labels = get_post_type_labels( (object) array( 52 'name' => 'bar', 53 'labels' => array(), 54 'hierarchical' => false, 55 ) ); 62 $labels = get_post_type_labels( 63 (object) array( 64 'name' => 'bar', 65 'labels' => array(), 66 'hierarchical' => false, 67 ) 68 ); 56 69 57 70 $this->assertSame( 'bar', $labels->name_admin_bar ); … … 59 72 60 73 public function test_menu_name_should_fall_back_to_name() { 61 $labels = get_post_type_labels( (object) array( 62 'name' => 'foo', 63 'labels' => array( 64 'name' => 'Bar', 65 ), 66 'hierarchical' => false, 67 ) ); 74 $labels = get_post_type_labels( 75 (object) array( 76 'name' => 'foo', 77 'labels' => array( 78 'name' => 'Bar', 79 ), 80 'hierarchical' => false, 81 ) 82 ); 68 83 69 84 $this->assertSame( 'Bar', $labels->menu_name ); … … 71 86 72 87 public function test_labels_should_be_added_when_registering_a_post_type() { 73 $post_type_object = register_post_type( 'foo', array( 74 'labels' => array( 75 'singular_name' => 'bar', 76 ), 77 ) ); 88 $post_type_object = register_post_type( 89 'foo', 90 array( 91 'labels' => array( 92 'singular_name' => 'bar', 93 ), 94 ) 95 ); 78 96 79 97 unregister_post_type( 'foo' ); … … 85 103 86 104 public function test_label_should_be_derived_from_labels_when_registering_a_post_type() { 87 $post_type_object = register_post_type( 'foo', array( 88 'labels' => array( 89 'name' => 'bar', 90 ), 91 ) ); 105 $post_type_object = register_post_type( 106 'foo', 107 array( 108 'labels' => array( 109 'name' => 'bar', 110 ), 111 ) 112 ); 92 113 93 114 $this->assertSame( 'bar', $post_type_object->label );
Note: See TracChangeset
for help on using the changeset viewer.