Skip to content

Commit

Permalink
added notifications test
Browse files Browse the repository at this point in the history
  • Loading branch information
esokullu committed Jan 15, 2019
1 parent bfc834b commit 015bcb9
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 0 deletions.
43 changes: 43 additions & 0 deletions tests/Pho/Kernel/NotificationsTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<?php

/*
* This file is part of the Phở package.
*
* (c) Emre Sokullu <emre@phonetworks.org>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace Pho\Kernel;

use PhoNetworksAutogenerated\User;
use Pho\Framework\AbstractNotification;
use Pho\Framework\NotificationList;

class NotificationsTest extends TestCase
{
public function testFollowNotification() {
$this->flushDBandRestart();
$founder = $this->kernel->founder();
$this->assertInstanceOf(User::class, $founder);
$this->assertInstanceOf(NotificationList::class, $founder->notifications());
$this->assertSame(0, $founder->notifications()->count());
$user = new \PhoNetworksAutogenerated\User($this->kernel, $this->graph, "123456");
$user->follow($founder);
$this->assertSame(0, $user->notifications()->count());
$this->assertCount(1, $founder->notifications()->toArray());
$this->assertSame(1, $founder->notifications()->count());
}

public function testFollowNotificationAfterSerialize() {
$this->flushDBandRestart();
$founder = $this->kernel->founder();
$user = new \PhoNetworksAutogenerated\User($this->kernel, $this->graph, "123456");
$founder->follow($user);
$this->assertSame(1, $user->notifications()->count());
$user_deserialized = $this->kernel->gs()->node((string) $user->id());
$this->assertSame(1, $user_deserialized->notifications()->count());
}

}
3 changes: 3 additions & 0 deletions tests/assets/compiled/UserOut/Follow.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,10 @@ class FollowPredicate extends Foundation\ActorOut\SubscribePredicate
const T_PERSISTENT = true;
}
/* Notification to load if it's a subtype of write or mention. */
class FollowNotification extends Foundation\ActorOut\SubscribeNotification
{

}
}

/*****************************************************
Expand Down
4 changes: 4 additions & 0 deletions tests/assets/compiled/UserOut/Like.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,11 @@ class LikePredicate extends Foundation\ActorOut\SubscribePredicate
const T_PERSISTENT = true;
}
/* Notification to load if it's a subtype of write or mention. */
/* Notification to load if it's a subtype of write or mention. */
class LikeNotification extends Foundation\ActorOut\SubscribeNotification
{

}
}

/*****************************************************
Expand Down

0 comments on commit 015bcb9

Please sign in to comment.