1
0
mirror of https://github.com/flarum/core.git synced 2025-08-10 10:24:46 +02:00

refactoring of the extenders

This commit is contained in:
Daniël Klabbers
2020-04-01 17:02:14 +02:00
parent 23736fcfda
commit ae55cd3d20
5 changed files with 46 additions and 51 deletions

View File

@@ -9,9 +9,10 @@
namespace Flarum\Tests\integration\extenders;
use Flarum\Extend\NotificationChannel;
use Flarum\Extend\Notification;
use Flarum\Tests\integration\RetrievesAuthorizedUsers;
use Flarum\Tests\integration\TestCase;
use Flarum\User\NotificationPreference;
use Flarum\User\User;
class NotificationChannelTest extends TestCase
@@ -31,17 +32,26 @@ class NotificationChannelTest extends TestCase
private function add_channel()
{
$this->extend(new NotificationChannel('test'));
$this->extend((new Notification)->addChannel('test'));
}
/**
* @test
*/
public function can_add_notification_channel()
public function can_enable_notification_channel()
{
$this->add_channel();
/** @var User $user */
$user = User::find(2);
NotificationPreference::setNotificationPreference($user, 'test', 'newPost');
$this->assertTrue(
$user->notificationPreferences()
->where('channel', 'test')
->where('type', 'newPost')
->get('enabled')
);
}
}

View File

@@ -9,7 +9,7 @@
namespace Flarum\Tests\integration\extenders;
use Flarum\Extend\UserPreferences;
use Flarum\Extend\User as Extender;
use Flarum\Tests\integration\RetrievesAuthorizedUsers;
use Flarum\Tests\integration\TestCase;
use Flarum\User\User;
@@ -33,8 +33,8 @@ class UserPreferencesTest extends TestCase
private function add_preference()
{
$this->extend(
(new UserPreferences())
->add('test', 'boolval', false)
(new Extender())
->addPreference('test', 'boolval', false)
);
}