Skip to content

Commit

Permalink
blog connector log meta updated.
Browse files Browse the repository at this point in the history
  • Loading branch information
kidunot89 committed Jan 5, 2021
1 parent 07b22b9 commit 532ea36
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 3 deletions.
12 changes: 12 additions & 0 deletions connectors/class-connector-blogs.php
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,8 @@ public function callback_wp_initialize_site( $new_site, $args ) {
),
array(
'site_name' => ! empty( $blogname ) ? $blogname : 'Site %d',
'siteurl' => $new_site->siteurl,
'id' => $new_site->blog_id,
),
$blog_id,
sanitize_key( $blogname ),
Expand All @@ -172,6 +174,8 @@ public function callback_wp_delete_site( $old_site ) {
),
array(
'site_name' => $old_site->blogname,
'siteurl' => $old_site->siteurl,
'id' => $old_site->blog_id,
),
$old_site->blog_id,
sanitize_key( $old_site->blogname ),
Expand Down Expand Up @@ -199,6 +203,8 @@ public function callback_wpmu_activate_blog( $blog_id, $user_id ) {
),
array(
'site_name' => $blog->blogname,
'siteurl' => $blog->siteurl,
'id' => $blog->blog_id,
),
$blog_id,
sanitize_key( $blog->blogname ),
Expand Down Expand Up @@ -234,6 +240,8 @@ public function callback_add_user_to_blog( $user_id, $role, $blog_id ) {
array(
'user_name' => $user->display_name,
'site_name' => $blog->blogname,
'siteurl' => $blog->siteurl,
'id' => $blog->blog_id,
'role_name' => $role,
),
$blog_id,
Expand Down Expand Up @@ -268,6 +276,8 @@ public function callback_remove_user_from_blog( $user_id, $blog_id ) {
array(
'user_name' => $user->display_name,
'site_name' => $blog->blogname,
'siteurl' => $blog->siteurl,
'id' => $blog->blog_id,
),
$blog_id,
sanitize_key( $blog->blogname ),
Expand Down Expand Up @@ -401,6 +411,8 @@ public function callback_update_blog_status( $blog_id, $status, $action ) {
),
array(
'site_name' => $blog->blogname,
'siteurl' => $blog->siteurl,
'id' => $blog->blog_id,
'status' => $status,
),
$blog_id,
Expand Down
51 changes: 48 additions & 3 deletions tests/tests/connectors/test-class-connector-blogs.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,16 @@ public function test_callback_wp_initialize_site() {
'stream'
)
),
$this->equalTo( array( 'site_name' => 'testsite' ) ),
$this->callback(
function( $meta ) {
$expected_meta = array(
'site_name' => 'testsite',
'siteurl' => '//testsite',
);

return $expected_meta === array_intersect_key( $expected_meta, $meta );
}
),
$this->greaterThan( 0 ),
$this->equalTo( 'testsite' ),
$this->equalTo( 'created' )
Expand Down Expand Up @@ -113,7 +122,13 @@ public function test_callback_wp_delete_site() {
'stream'
)
),
$this->equalTo( array( 'site_name' => 'testsite' ) ),
$this->equalTo(
array(
'site_name' => 'testsite',
'siteurl' => '//testsite',
'id' => $blog_id,
)
),
$this->greaterThan( 0 ),
$this->equalTo( 'testsite' ),
$this->equalTo( 'deleted' )
Expand Down Expand Up @@ -142,7 +157,13 @@ public function test_callback_wpmu_activate_blog() {
'stream'
)
),
$this->equalTo( array( 'site_name' => 'testsite' ) ),
$this->equalTo(
array(
'site_name' => 'testsite',
'siteurl' => '//testsite',
'id' => $blog_id,
)
),
$this->equalTo( $blog_id ),
$this->equalTo( 'testsite' ),
$this->equalTo( 'created' ),
Expand Down Expand Up @@ -176,6 +197,8 @@ public function test_callback_add_user_to_blog() {
array(
'user_name' => 'testuser',
'site_name' => 'testsite',
'siteurl' => '//testsite',
'id' => $blog_id,
'role_name' => 'subscriber',
)
),
Expand Down Expand Up @@ -212,6 +235,8 @@ public function test_callback_remove_user_from_blog() {
array(
'user_name' => 'testuser',
'site_name' => 'testsite',
'siteurl' => '//testsite',
'id' => $blog_id,
)
),
$this->equalTo( $blog_id ),
Expand Down Expand Up @@ -251,6 +276,8 @@ public function test_callback_update_blog_status() {
$this->equalTo(
array(
'site_name' => 'testsite',
'siteurl' => '//testsite',
'id' => $blog_id,
'status' => esc_html__( 'marked as spam', 'stream' ),
)
),
Expand All @@ -269,6 +296,8 @@ public function test_callback_update_blog_status() {
$this->equalTo(
array(
'site_name' => 'testsite',
'siteurl' => '//testsite',
'id' => $blog_id,
'status' => esc_html__( 'marked as not spam', 'stream' ),
)
),
Expand All @@ -287,6 +316,8 @@ public function test_callback_update_blog_status() {
$this->equalTo(
array(
'site_name' => 'testsite',
'siteurl' => '//testsite',
'id' => $blog_id,
'status' => esc_html__( 'marked as mature', 'stream' ),
)
),
Expand All @@ -305,6 +336,8 @@ public function test_callback_update_blog_status() {
$this->equalTo(
array(
'site_name' => 'testsite',
'siteurl' => '//testsite',
'id' => $blog_id,
'status' => esc_html__( 'marked as not mature', 'stream' ),
)
),
Expand All @@ -323,6 +356,8 @@ public function test_callback_update_blog_status() {
$this->equalTo(
array(
'site_name' => 'testsite',
'siteurl' => '//testsite',
'id' => $blog_id,
'status' => esc_html__( 'archived', 'stream' ),
)
),
Expand All @@ -341,6 +376,8 @@ public function test_callback_update_blog_status() {
$this->equalTo(
array(
'site_name' => 'testsite',
'siteurl' => '//testsite',
'id' => $blog_id,
'status' => esc_html__( 'restored from archive', 'stream' ),
)
),
Expand All @@ -359,6 +396,8 @@ public function test_callback_update_blog_status() {
$this->equalTo(
array(
'site_name' => 'testsite',
'siteurl' => '//testsite',
'id' => $blog_id,
'status' => esc_html__( 'trashed', 'stream' ),
)
),
Expand All @@ -377,6 +416,8 @@ public function test_callback_update_blog_status() {
$this->equalTo(
array(
'site_name' => 'testsite',
'siteurl' => '//testsite',
'id' => $blog_id,
'status' => esc_html__( 'restored', 'stream' ),
)
),
Expand All @@ -395,6 +436,8 @@ public function test_callback_update_blog_status() {
$this->equalTo(
array(
'site_name' => 'testsite',
'siteurl' => '//testsite',
'id' => $blog_id,
'status' => esc_html__( 'marked as public', 'stream' ),
)
),
Expand All @@ -413,6 +456,8 @@ public function test_callback_update_blog_status() {
$this->equalTo(
array(
'site_name' => 'testsite',
'siteurl' => '//testsite',
'id' => $blog_id,
'status' => esc_html__( 'marked as private', 'stream' ),
)
),
Expand Down

0 comments on commit 532ea36

Please sign in to comment.