Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions schemas/post-type.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -249,8 +249,8 @@
"description": "[SCF Export Only] The order of this post type in the admin menu"
},
"menu_position": {
"type": ["integer", "string"],
"description": "The position in the menu order. SCF exports as empty string when not set, integer when set. Import accepts both and casts to integer."
"type": ["integer", "string", "null"],
"description": "The position in the menu order. SCF exports as empty string or null when not set, integer when set. Import accepts all types and casts to integer."
},
"menu_icon": {
"oneOf": [
Expand Down Expand Up @@ -300,7 +300,7 @@
"description": "Core feature(s) the post type supports. Common values: 'title', 'editor', 'author', 'thumbnail', 'excerpt', 'trackbacks', 'custom-fields', 'comments', 'revisions', 'page-attributes', 'post-formats'. Custom supports are also allowed."
},
"taxonomies": {
"oneOf": [
"anyOf": [
{
"type": "array",
"items": { "type": "string" },
Expand Down
72 changes: 63 additions & 9 deletions tests/php/PostTypeSchemaTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,15 +67,15 @@ public function test_post_type_schema_loads() {
*/
public function validPostTypesProvider() {
return array(
'basic valid' => array(
'basic valid' => array(
array(
'key' => 'post_type_book',
'title' => 'Book',
'post_type' => 'book',
),
'Basic post type should validate successfully',
),
'array with two items' => array(
'array with two items' => array(
array(
array(
'key' => 'post_type_book',
Expand All @@ -90,31 +90,31 @@ public function validPostTypesProvider() {
),
'Array of two post types should validate successfully',
),
'with dashes' => array(
'with dashes' => array(
array(
'key' => 'post_type_my_product',
'title' => 'My Product',
'post_type' => 'my-product',
),
'Post type with dashes should be valid',
),
'with underscores' => array(
'with underscores' => array(
array(
'key' => 'post_type_my_product',
'title' => 'My Product',
'post_type' => 'my_product',
),
'Post type with underscores should be valid',
),
'with numbers' => array(
'with numbers' => array(
array(
'key' => 'post_type_product123',
'title' => 'Product',
'post_type' => 'product123',
),
'Post type with numbers should be valid',
),
'custom supports' => array(
'custom supports' => array(
array(
'key' => 'post_type_book',
'title' => 'Book',
Expand All @@ -123,7 +123,7 @@ public function validPostTypesProvider() {
),
'Post type with custom supports should be valid',
),
'rewrite false' => array(
'rewrite false' => array(
array(
'key' => 'post_type_book',
'title' => 'Book',
Expand All @@ -132,7 +132,7 @@ public function validPostTypesProvider() {
),
'Post type with rewrite as false should validate',
),
'rewrite object' => array(
'rewrite object' => array(
array(
'key' => 'post_type_book',
'title' => 'Book',
Expand All @@ -146,7 +146,7 @@ public function validPostTypesProvider() {
),
'Post type with rewrite object should validate',
),
'with capabilities' => array(
'with capabilities' => array(
array(
'key' => 'post_type_book',
'title' => 'Book',
Expand All @@ -159,6 +159,60 @@ public function validPostTypesProvider() {
),
'Post type with valid capabilities should validate',
),
'taxonomies empty array' => array(
array(
'key' => 'post_type_test',
'title' => 'Test',
'post_type' => 'test',
'taxonomies' => array(),
),
'Post type with empty taxonomies array should validate',
),
'taxonomies empty string' => array(
array(
'key' => 'post_type_test',
'title' => 'Test',
'post_type' => 'test',
'taxonomies' => '',
),
'Post type with empty taxonomies string should validate',
),
'taxonomies array with values' => array(
array(
'key' => 'post_type_test',
'title' => 'Test',
'post_type' => 'test',
'taxonomies' => array( 'category', 'post_tag' ),
),
'Post type with taxonomies array should validate',
),
'menu_position null' => array(
array(
'key' => 'post_type_test',
'title' => 'Test',
'post_type' => 'test',
'menu_position' => null,
),
'Post type with null menu_position should validate',
),
'menu_position empty string' => array(
array(
'key' => 'post_type_test',
'title' => 'Test',
'post_type' => 'test',
'menu_position' => '',
),
'Post type with empty string menu_position should validate',
),
'menu_position integer' => array(
array(
'key' => 'post_type_test',
'title' => 'Test',
'post_type' => 'test',
'menu_position' => 20,
),
'Post type with integer menu_position should validate',
),
);
}

Expand Down
Loading