wordpress-develop/tests/phpunit/tests/meta/isProtectedMeta.php
Sergey Biryukov d790be16dc Coding Standards: Remove superfluous blank lines at the end of various classes.
Note: This is enforced by WPCS 3.0.0.

Follow-up to [56536].

Props jrf.
See #59161, #58831.

git-svn-id: https://develop.svn.wordpress.org/trunk@56547 602fd350-edb4-49c9-b593-d223f7449a82
2023-09-08 09:30:38 +00:00

55 lines
1.3 KiB
PHP

<?php
/**
* @group meta
* @covers ::is_protected_meta
*/
class Tests_Meta_isProtectedMeta extends WP_UnitTestCase {
/**
* @dataProvider data_is_protected_meta_true
*/
public function test_is_protected_meta_true( $key ) {
$this->assertTrue( is_protected_meta( $key ) );
}
public function data_is_protected_meta_true() {
$protected_keys = array(
array( '_wp_attachment' ),
);
for ( $i = 0, $max = 31; $i < $max; $i++ ) {
$protected_keys[] = array( chr( $i ) . '_wp_attachment' );
}
for ( $i = 127, $max = 159; $i <= $max; $i++ ) {
$protected_keys[] = array( chr( $i ) . '_wp_attachment' );
}
$protected_keys[] = array( chr( 95 ) . '_wp_attachment' );
return $protected_keys;
}
/**
* @dataProvider data_is_protected_meta_false
*/
public function test_is_protected_meta_false( $key ) {
$this->assertFalse( is_protected_meta( $key ) );
}
public function data_is_protected_meta_false() {
$unprotected_keys = array(
array( 'singleword' ),
array( 'two_words' ),
array( 'ąŌ_not_so_protected_meta' ),
);
for ( $i = 32, $max = 94; $i <= $max; $i++ ) {
$unprotected_keys[] = array( chr( $i ) . '_wp_attachment' );
}
for ( $i = 96, $max = 126; $i <= $max; $i++ ) {
$unprotected_keys[] = array( chr( $i ) . '_wp_attachment' );
}
return $unprotected_keys;
}
}