Skip to content

Commit

Permalink
Publicize: Tweak Tests
Browse files Browse the repository at this point in the history
They fail :) But at least they now look at the right data
since the data structures changd from #9955 to b17be1f.
  • Loading branch information
mdawaffe committed Oct 24, 2018
1 parent b17be1f commit 6b8b2d0
Showing 1 changed file with 48 additions and 33 deletions.
81 changes: 48 additions & 33 deletions tests/php/modules/publicize/test_class.publicize.php
Original file line number Diff line number Diff line change
Expand Up @@ -310,34 +310,33 @@ public function test_get_filtered_connection_data_no_filters() {
);
$this->assertEquals(
'tumblr',
$test_c['name'],
$test_c['service_name'],
'Second test connection name should be \'tumbler\''
);
$this->assertTrue(
$test_c['checked'],
'The connection has not been shared to and there are no filters so connection should be \'checked\' by default.'
);
$this->assertEquals(
'',
$test_c['disabled'],
'Connection should not be disabled, so disabled string should be empty.'
'Tumblr: test-display-name456',
$test_c['label'],
'Label should follow pattern: [Service name]: [user-display-name].'
);
$this->assertTrue(
$test_c['active'],
'Connection should be active because there are no filters and the connection has not been shared to.'
$test_c['enabled'],
'The connection has not been shared to and there are no filters so connection should be \'enabled\' by default.'
);
$this->assertFalse(
$test_c['hidden_checkbox'],
'hidden_checkbox should be false since current user can use this connection.'
$test_c['done'],
'Connection should not be done since it has not been publicized to yet.'
);
$this->assertEquals(
'Tumblr: test-display-name456',
$test_c['label'],
'Label should follow pattern: [Service name]: [user-display-name].'
$this->assertTrue(
$test_c['toggleable'],
'Connection should be toggleable.'
);
$this->assertEquals(
'test-display-name456',
$test_c['display_name']
$this->assertFalse(
$test_c['global'],
'Connection should not be global.'
);
$this->assertTrue(
$test_c['visible'],
'Connection should be visible.'
);
}

Expand Down Expand Up @@ -376,10 +375,14 @@ public function test_get_filtered_connection_data_null_post() {
*/
$connection_list = $this->publicize->get_filtered_connection_data();
$tumblr_connection = $connection_list[ self::TUMBLR_CONNECTION_INDEX ];
$this->assertFalse(
$tumblr_connection['disabled'],
$this->assertTrue(
$tumblr_connection['enabled'],
'All connections should be enabled for null post id'
);
$this->assertFalse(
$tumblr_connection['done'],
'Connection should not yet be done for null post id'
);
}

/**
Expand All @@ -396,7 +399,7 @@ public function test_filter_wpas_submit_post() {
$facebook_connection = $connection_list[ self::FACEBOOK_CONNECTION_INDEX ];
$this->assertEquals(
'facebook',
$facebook_connection['name'],
$facebook_connection['service_name'],
'Facebook connection should be available prior to filtering'
);

Expand All @@ -413,7 +416,7 @@ public function test_filter_wpas_submit_post() {
$tumblr_connection = $connection_list[0];
$this->assertEquals(
'tumblr',
$tumblr_connection['name'],
$tumblr_connection['service_name'],
'Tumblr connection should still be available after filtering out facebook connection.'
);
}
Expand All @@ -432,7 +435,11 @@ public function test_filter_publicize_checkbox_global_default() {
$connection_list = $this->publicize->get_filtered_connection_data( $this->post->ID );
$facebook_connection = $connection_list[ self::FACEBOOK_CONNECTION_INDEX ];
$this->assertTrue(
$facebook_connection['hidden_checkbox'],
$facebook_connection['global'],
'Facebook connection checkbox should be global.'
);
$this->assertFalse(
$facebook_connection['visible'],
'Facebook connection checkbox should be hidden by default since test user does not have capability.'
);

Expand All @@ -441,8 +448,8 @@ public function test_filter_publicize_checkbox_global_default() {
// Get connection list again now that filter has been added.
$connection_list = $this->publicize->get_filtered_connection_data( $this->post->ID );
$facebook_connection = $connection_list[ self::FACEBOOK_CONNECTION_INDEX ];
$this->assertFalse(
$facebook_connection['hidden_checkbox'],
$this->assertTrue(
$facebook_connection['visible'],
'Facebook connection checkbox should not be set to hidden since filter set hidden to false.'
);

Expand All @@ -461,17 +468,17 @@ public function test_filter_publicize_checkbox_default() {
$connection_list = $this->publicize->get_filtered_connection_data( $this->post->ID );
$facebook_connection = $connection_list[ self::FACEBOOK_CONNECTION_INDEX ];
$this->assertTrue(
$facebook_connection['checked'],
'Facebook connection should be checked by default with no filtering applied.'
$facebook_connection['enabled'],
'Facebook connection should be enabled by default with no filtering applied.'
);

add_filter( 'publicize_checkbox_default', array( $this, 'publicize_connection_filter_no_facebook' ), 10, 4 );
$connection_list = $this->publicize->get_filtered_connection_data( $this->post->ID );

$facebook_connection = $connection_list[ self::FACEBOOK_CONNECTION_INDEX ];
$this->assertFalse(
$facebook_connection['checked'],
'Facebook connection should be un-checked by default after filtering applied.'
$facebook_connection['enabled'],
'Facebook connection should be un-enabled by default after filtering applied.'
);
}

Expand All @@ -489,8 +496,12 @@ public function test_get_filtered_connection_data_disabled_done_all() {
// First connection should be 'facebook' for unfiltered list.
$facebook_connection = $connection_list[ self::TUMBLR_CONNECTION_INDEX ];
$this->assertFalse(
$facebook_connection['disabled'],
'Facebook connection should not be disabled if the post is not \'done\'.'
$facebook_connection['done'],
'Facebook connection should not be done yet.'
);
$this->assertTrue(
$facebook_connection['toggleable'],
'Facebook connection should be toggleable if the post is not \'done\'.'
);

/**
Expand All @@ -503,7 +514,11 @@ public function test_get_filtered_connection_data_disabled_done_all() {
$connection_list = $this->publicize->get_filtered_connection_data( $this->post->ID );
$facebook_connection = $connection_list[ self::TUMBLR_CONNECTION_INDEX ];
$this->assertTrue(
$facebook_connection['disabled'],
$facebook_connection['done'],
'Facebook connection should be done now that it has been published.'
);
$this->assertFalse(
$facebook_connection['toggleable'],
'Facebook connection should be disabled if the post is \'done\'.'
);
}
Expand Down

0 comments on commit 6b8b2d0

Please sign in to comment.