Make WordPress Core


Ignore:
Timestamp:
11/30/2017 11:09:33 PM (9 years ago)
Author:
pento
Message:

Code is Poetry.
WordPress' code just... wasn't.
This is now dealt with.

Props jrf, pento, netweb, GaryJ, jdgrimes, westonruter, Greg Sherwood from PHPCS, and everyone who's ever contributed to WPCS and PHPCS.
Fixes #41057.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/post/getPostsByAuthorSql.php

    r36050 r42343  
    66class Tests_Post_GetPostsByAuthorSql extends WP_UnitTestCase {
    77
    8         public function test_post_type_post(){
     8        public function test_post_type_post() {
    99                $maybe_string = get_posts_by_author_sql( 'post' );
    1010                $this->assertContains( "post_type = 'post'", $maybe_string );
    1111        }
    1212
    13         public function test_post_type_page(){
     13        public function test_post_type_page() {
    1414                $maybe_string = get_posts_by_author_sql( 'page' );
    1515                $this->assertContains( "post_type = 'page'", $maybe_string );
    1616        }
    1717
    18         public function test_non_existent_post_type(){
     18        public function test_non_existent_post_type() {
    1919                $maybe_string = get_posts_by_author_sql( 'non_existent_post_type' );
    2020                $this->assertContains( '1 = 0', $maybe_string );
    2121        }
    2222
    23         public function test_multiple_post_types(){
     23        public function test_multiple_post_types() {
    2424                register_post_type( 'foo' );
    2525                register_post_type( 'bar' );
     
    3333        }
    3434
    35         public function test_full_true(){
     35        public function test_full_true() {
    3636                $maybe_string = get_posts_by_author_sql( 'post', true );
    3737                $this->assertRegExp( '/^WHERE /', $maybe_string );
    3838        }
    3939
    40         public function test_full_false(){
     40        public function test_full_false() {
    4141                $maybe_string = get_posts_by_author_sql( 'post', false );
    4242                $this->assertNotRegExp( '/^WHERE /', $maybe_string );
    4343        }
    4444
    45         public function test_post_type_clause_should_be_included_when_full_is_true(){
     45        public function test_post_type_clause_should_be_included_when_full_is_true() {
    4646                $maybe_string = get_posts_by_author_sql( 'post', true );
    4747                $this->assertContains( "post_type = 'post'", $maybe_string );
    4848        }
    4949
    50         public function test_post_type_clause_should_be_included_when_full_is_false(){
     50        public function test_post_type_clause_should_be_included_when_full_is_false() {
    5151                $maybe_string = get_posts_by_author_sql( 'post', false );
    5252                $this->assertContains( "post_type = 'post'", $maybe_string );
    5353        }
    5454
    55         public function test_post_author_should_create_post_author_clause(){
    56                 $maybe_string = get_posts_by_author_sql( 'post', true, 1  );
     55        public function test_post_author_should_create_post_author_clause() {
     56                $maybe_string = get_posts_by_author_sql( 'post', true, 1 );
    5757                $this->assertContains( 'post_author = 1', $maybe_string );
    5858        }
    5959
    60         public function test_public_only_true_should_not_allow_any_private_posts_for_loggedin_user(){
     60        public function test_public_only_true_should_not_allow_any_private_posts_for_loggedin_user() {
    6161                $current_user = get_current_user_id();
    62                 $u = self::factory()->user->create();
     62                $u            = self::factory()->user->create();
    6363                wp_set_current_user( $u );
    6464
     
    6969        }
    7070
    71         public function test_public_only_should_default_to_false(){
     71        public function test_public_only_should_default_to_false() {
    7272                $current_user = get_current_user_id();
    73                 $u = self::factory()->user->create();
     73                $u            = self::factory()->user->create();
    7474                wp_set_current_user( $u );
    7575
     
    7979        }
    8080
    81         public function test_public_only_false_should_allow_current_user_access_to_own_private_posts_when_current_user_matches_post_author(){
     81        public function test_public_only_false_should_allow_current_user_access_to_own_private_posts_when_current_user_matches_post_author() {
    8282                $current_user = get_current_user_id();
    83                 $u = self::factory()->user->create();
     83                $u            = self::factory()->user->create();
    8484                wp_set_current_user( $u );
    8585
     
    9090        }
    9191
    92         public function test_public_only_false_should_not_allow_access_to_private_posts_if_current_user_is_not_post_author(){
     92        public function test_public_only_false_should_not_allow_access_to_private_posts_if_current_user_is_not_post_author() {
    9393                $current_user = get_current_user_id();
    94                 $u1 = self::factory()->user->create();
    95                 $u2 = self::factory()->user->create();
     94                $u1           = self::factory()->user->create();
     95                $u2           = self::factory()->user->create();
    9696                wp_set_current_user( $u1 );
    9797
     
    102102        }
    103103
    104         public function test_public_only_false_should_allow_current_user_access_to_own_private_posts_when_post_author_is_not_provided(){
     104        public function test_public_only_false_should_allow_current_user_access_to_own_private_posts_when_post_author_is_not_provided() {
    105105                $current_user = get_current_user_id();
    106                 $u = self::factory()->user->create();
     106                $u            = self::factory()->user->create();
    107107                wp_set_current_user( $u );
    108108
     
    114114        }
    115115
    116         public function test_administrator_should_have_access_to_private_posts_when_public_only_is_false(){
     116        public function test_administrator_should_have_access_to_private_posts_when_public_only_is_false() {
    117117                $current_user = get_current_user_id();
    118                 $u = self::factory()->user->create( array( 'role' => 'administrator' ) );
     118                $u            = self::factory()->user->create( array( 'role' => 'administrator' ) );
    119119                wp_set_current_user( $u );
    120120
     
    126126        }
    127127
    128         public function test_user_has_access_only_to_private_posts_for_certain_post_types(){
    129                 register_post_type( 'foo', array( 'capabilities' => array( 'read_private_posts' => 'read_private_foo' ) )  );
     128        public function test_user_has_access_only_to_private_posts_for_certain_post_types() {
     129                register_post_type( 'foo', array( 'capabilities' => array( 'read_private_posts' => 'read_private_foo' ) ) );
    130130                register_post_type( 'bar', array( 'capabilities' => array( 'read_private_posts' => 'read_private_bar' ) ) );
    131131                register_post_type( 'baz', array( 'capabilities' => array( 'read_private_posts' => 'read_private_baz' ) ) );
    132132                $current_user = get_current_user_id();
    133                 $u = self::factory()->user->create( array( 'role' => 'editor' ) );
    134                 $editor_role = get_role('editor');
     133                $u            = self::factory()->user->create( array( 'role' => 'editor' ) );
     134                $editor_role  = get_role( 'editor' );
    135135                $editor_role->add_cap( 'read_private_baz' );
    136136                wp_set_current_user( $u );
Note: See TracChangeset for help on using the changeset viewer.