-
Notifications
You must be signed in to change notification settings - Fork 673
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #9680 from hypeJunction/notifications-rel-delete
fix(notifications): users are again unsubscribed when friendship and …
- Loading branch information
Showing
3 changed files
with
113 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
74 changes: 74 additions & 0 deletions
74
mod/notifications/tests/ElggNotificationsPluginUnitTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
<?php | ||
|
||
/** | ||
* Notifications plugin tests | ||
*/ | ||
class ElggNotificationsPluginUnitTest extends ElggCoreUnitTest { | ||
|
||
/** | ||
* @var ElggUser | ||
*/ | ||
private $user1; | ||
|
||
/** | ||
* @var ElggUser | ||
*/ | ||
private $user2; | ||
|
||
/** | ||
* @var ElggUser | ||
*/ | ||
private $group; | ||
|
||
public function setUp() { | ||
|
||
elgg_register_notification_method('test'); | ||
|
||
$this->user1 = new ElggUser(); | ||
$this->user1->username = 'test1'; | ||
$this->user1->save(); | ||
|
||
$this->user2 = new ElggUser(); | ||
$this->user2->username = 'test2'; | ||
$this->user2->save(); | ||
|
||
$this->group = new ElggGroup(); | ||
$this->group->save(); | ||
} | ||
|
||
public function tearDown() { | ||
|
||
elgg_unregister_notification_method('test'); | ||
|
||
$this->user1->delete(); | ||
$this->user2->delete(); | ||
$this->group->delete(); | ||
} | ||
|
||
public function testFriendSubscriptionRemovedWhenFriendRelationshipDeleted() { | ||
|
||
$this->user1->addFriend($this->user2->guid); | ||
$this->assertTrue($this->user1->isFriendsWith($this->user2->guid)); | ||
|
||
elgg_add_subscription($this->user1->guid, 'test', $this->user2->guid); | ||
$this->assertIsA(check_entity_relationship($this->user1->guid, 'notifytest', $this->user2->guid), ElggRelationship::class); | ||
|
||
$this->user1->removeFriend($this->user2->guid); | ||
$this->assertFalse($this->user1->isFriendsWith($this->user2->guid)); | ||
$this->assertFalse(check_entity_relationship($this->user1->guid, 'notifytest', $this->user2->guid)); | ||
} | ||
|
||
public function testGroupSubscriptionRemovedWhenMemberRelationshipRemoved() { | ||
|
||
$this->group->join($this->user1); | ||
$this->assertTrue($this->group->isMember($this->user1)); | ||
|
||
elgg_add_subscription($this->user1->guid, 'test', $this->group->guid); | ||
$this->assertIsA(check_entity_relationship($this->user1->guid, 'notifytest', $this->group->guid), ElggRelationship::class); | ||
|
||
$this->group->leave($this->user1); | ||
$this->assertFalse($this->group->isMember($this->user1)); | ||
$this->assertFalse(check_entity_relationship($this->user1->guid, 'notifytest', $this->user2->guid)); | ||
} | ||
|
||
} |