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 Nov 3, 2020
1 parent 25e2639 commit ad7a424
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 @@ -76,7 +76,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 @@ -109,7 +118,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 @@ -138,7 +153,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 @@ -172,6 +193,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 @@ -208,6 +231,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 @@ -247,6 +272,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 @@ -265,6 +292,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 @@ -283,6 +312,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 @@ -301,6 +332,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 @@ -319,6 +352,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 @@ -337,6 +372,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 @@ -355,6 +392,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 @@ -373,6 +412,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 @@ -391,6 +432,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 @@ -409,6 +452,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 ad7a424

Please sign in to comment.