Skip to content

Commit

Permalink
Remove copypastaed tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
boonebgorges committed May 4, 2015
1 parent 0d6a4d2 commit eff5b44
Showing 1 changed file with 0 additions and 176 deletions.
176 changes: 0 additions & 176 deletions tests/phpunit/tests/activity/eventDelete.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,182 +71,6 @@ public function test_delete_event_connected_to_groups() {
$this->assertEquals( 1, $a[2]->hide_sitewide );
}

public function test_action_string_for_new_event_not_connected_to_groups() {
$u = $this->factory->user->create();

$now = time();
$e = eo_insert_event( array(
'post_author' => $u,
'start' => new DateTime( date( 'Y-m-d H:i:s', $now - 60*60 ) ),
'end' => new DateTime( date( 'Y-m-d H:i:s' ) ),
) );

$a = bpeo_get_activity_by_event_id( $e );

$event = get_post( $e );

$expected = sprintf(
'%s created the event %s',
sprintf( '<a href="%s">%s</a>', esc_url( bp_core_get_user_domain( $u ) ), esc_html( bp_core_get_user_displayname( $u ) ) ),
sprintf( '<a href="%s">%s</a>', esc_url( get_permalink( $event ) ), esc_html( $event->post_title ) )
);

$this->assertSame( $expected, $a[0]->action );
}

public function test_action_string_for_new_event_connected_to_groups_where_groups_are_public() {
$u = $this->factory->user->create();
$this->groups = array();
$this->groups[] = $this->factory->group->create( array(
'name' => 'aaa',
) );
$this->groups[] = $this->factory->group->create( array(
'name' => 'bbb',
) );
$this->groups[] = $this->factory->group->create( array(
'name' => 'ccc',
) );

// Group connections happen on 'save_post'. Whee!
add_action( 'save_post', array( $this, 'connect_events' ), 15 );

$now = time();
$e = eo_insert_event( array(
'post_author' => $u,
'start' => new DateTime( date( 'Y-m-d H:i:s', $now - 60*60 ) ),
'end' => new DateTime( date( 'Y-m-d H:i:s' ) ),
) );

remove_action( 'save_post', array( $this, 'connect_events' ), 15 );

$a = bpeo_get_activity_by_event_id( $e );

$ua = $ga0 = $ga2 = false;
foreach ( $a as $_a ) {
if ( $this->groups[0] == $_a->item_id ) {
$ga0 = $_a;
} elseif ( $this->groups[2] == $_a->item_id ) {
$ga2 = $_a;
} else {
$ua = $_a;
}
}

$this->assertNotEmpty( $ua );
$this->assertNotEmpty( $ga0 );
$this->assertNotEmpty( $ga2 );

$g0 = groups_get_group( array( 'group_id' => $this->groups[0] ) );
$g2 = groups_get_group( array( 'group_id' => $this->groups[2] ) );

$event = get_post( $e );

// User string takes the groups in alphabetical order.
$ua_expected = sprintf(
'%s created the event %s in the groups %s, %s.',
sprintf( '<a href="%s">%s</a>', esc_url( bp_core_get_user_domain( $u ) ), esc_html( bp_core_get_user_displayname( $u ) ) ),
sprintf( '<a href="%s">%s</a>', esc_url( get_permalink( $event ) ), esc_html( $event->post_title ) ),
sprintf( '<a href="%s">%s</a>', esc_url( bp_get_group_permalink( $g0 ) . 'events/' ), esc_html( $g0->name ) ),
sprintf( '<a href="%s">%s</a>', esc_url( bp_get_group_permalink( $g2 ) . 'events/' ), esc_html( $g2->name ) )
);
$this->assertSame( $ua_expected, $ua->action );

$g0_expected = sprintf(
'%s created the event %s in the groups %s, %s.',
sprintf( '<a href="%s">%s</a>', esc_url( bp_core_get_user_domain( $u ) ), esc_html( bp_core_get_user_displayname( $u ) ) ),
sprintf( '<a href="%s">%s</a>', esc_url( get_permalink( $event ) ), esc_html( $event->post_title ) ),
sprintf( '<a href="%s">%s</a>', esc_url( bp_get_group_permalink( $g0 ) . 'events/' ), esc_html( $g0->name ) ),
sprintf( '<a href="%s">%s</a>', esc_url( bp_get_group_permalink( $g2 ) . 'events/' ), esc_html( $g2->name ) )
);
$this->assertSame( $g0_expected, $ga0->action );

$g2_expected = sprintf(
'%s created the event %s in the groups %s, %s.',
sprintf( '<a href="%s">%s</a>', esc_url( bp_core_get_user_domain( $u ) ), esc_html( bp_core_get_user_displayname( $u ) ) ),
sprintf( '<a href="%s">%s</a>', esc_url( get_permalink( $event ) ), esc_html( $event->post_title ) ),
sprintf( '<a href="%s">%s</a>', esc_url( bp_get_group_permalink( $g2 ) . 'events/' ), esc_html( $g2->name ) ),
sprintf( '<a href="%s">%s</a>', esc_url( bp_get_group_permalink( $g0 ) . 'events/' ), esc_html( $g0->name ) )
);
$this->assertSame( $g2_expected, $ga2->action );
}

public function test_action_string_for_new_event_connected_to_groups_where_user_only_has_access_to_one_group() {
$creator = $this->factory->user->create();
$u = $this->factory->user->create();
$current_user = bp_loggedin_user_id();
$this->set_current_user( $u );

$this->groups = array();
$this->groups[] = $this->factory->group->create( array(
'name' => 'aaa',
'status' => 'private',
'creator_id' => $creator,
) );
$this->groups[] = $this->factory->group->create( array(
'name' => 'bbb',
'creator_id' => $creator,
) );
$this->groups[] = $this->factory->group->create( array(
'name' => 'ccc',
'status' => 'private',
'creator_id' => $creator,
) );

$this->add_user_to_group( $u, $this->groups[2] );

// Group connections happen on 'save_post'. Whee!
add_action( 'save_post', array( $this, 'connect_events' ), 15 );

$now = time();
$e = eo_insert_event( array(
'post_author' => $u,
'start' => new DateTime( date( 'Y-m-d H:i:s', $now - 60*60 ) ),
'end' => new DateTime( date( 'Y-m-d H:i:s' ) ),
) );

remove_action( 'save_post', array( $this, 'connect_events' ), 15 );

$a = bpeo_get_activity_by_event_id( $e );

$ua = $ga0 = $ga2 = false;
foreach ( $a as $_a ) {
if ( $this->groups[0] == $_a->item_id ) {
$ga0 = $_a;
} elseif ( $this->groups[2] == $_a->item_id ) {
$ga2 = $_a;
} else {
$ua = $_a;
}
}

// Ignoring $ga0 since user will never see it.
$this->assertNotEmpty( $ua );
$this->assertNotEmpty( $ga2 );

$g0 = groups_get_group( array( 'group_id' => $this->groups[0] ) );
$g2 = groups_get_group( array( 'group_id' => $this->groups[2] ) );

$event = get_post( $e );

$ua_expected = sprintf(
'%s created the event %s in the group %s.',
sprintf( '<a href="%s">%s</a>', esc_url( bp_core_get_user_domain( $u ) ), esc_html( bp_core_get_user_displayname( $u ) ) ),
sprintf( '<a href="%s">%s</a>', esc_url( get_permalink( $event ) ), esc_html( $event->post_title ) ),
sprintf( '<a href="%s">%s</a>', esc_url( bp_get_group_permalink( $g2 ) . 'events/' ), esc_html( $g2->name ) )
);
$this->assertSame( $ua_expected, $ua->action );

$g2_expected = sprintf(
'%s created the event %s in the group %s.',
sprintf( '<a href="%s">%s</a>', esc_url( bp_core_get_user_domain( $u ) ), esc_html( bp_core_get_user_displayname( $u ) ) ),
sprintf( '<a href="%s">%s</a>', esc_url( get_permalink( $event ) ), esc_html( $event->post_title ) ),
sprintf( '<a href="%s">%s</a>', esc_url( bp_get_group_permalink( $g2 ) . 'events/' ), esc_html( $g2->name ) )
);
$this->assertSame( $g2_expected, $ga2->action );

$this->set_current_user( $current_user );
}

public function connect_events( $e ) {
bpeo_connect_event_to_group( $e, $this->groups[0] );
bpeo_connect_event_to_group( $e, $this->groups[2] );
Expand Down

0 comments on commit eff5b44

Please sign in to comment.