Commit e4d27bc1 authored by Brian Hatchet's avatar Brian Hatchet :speech_balloon:

MR review changes

1 merge request!295Feat/closed channels 602
Pipeline #78437828 passed with stages
in 9 minutes and 58 seconds
......@@ -9,12 +9,12 @@ abstract class ChannelMode
const MODERATED = 1;
const CLOSED = 2;
final public static function toArray()
final public static function toArray() : array
{
return (new ReflectionClass(static::class))->getConstants();
}
final public static function isValid($value)
final public static function isValid($value) : bool
{
return in_array($value, static::toArray());
}
......
......@@ -3,6 +3,7 @@ namespace Minds\Entities;
use Minds\Core;
use Minds\Helpers;
use Minds\Common\ChannelMode;
/**
* User Entity
......@@ -10,9 +11,6 @@ use Minds\Helpers;
*/
class User extends \ElggUser
{
public const MODE_OPEN = 0;
public const MODE_MODERATED = 1;
public const MODE_CLOSED = 2;
public $fullExport = true;
public $exportCounts = false;
......@@ -55,7 +53,7 @@ class User extends \ElggUser
$this->attributes['canary'] = 0;
$this->attributes['onchain_booster'] = null;
$this->attributes['toaster_notifications'] = 1;
$this->attributes['mode'] = User::MODE_OPEN;
$this->attributes['mode'] = ChannelMode::OPEN;
parent::initializeAttributes();
}
......
......@@ -6,6 +6,7 @@ use Minds\Entities\User;
use Minds\Core\Di\Di;
use PhpSpec\ObjectBehavior;
use Prophecy\Argument;
use Minds\Common\ChannelMode;
class UserSpec extends ObjectBehavior
{
......@@ -51,16 +52,18 @@ class UserSpec extends ObjectBehavior
}
function it_should_have_a_default_mode_of_open() {
$this->getMode()->shouldEqual(User::MODE_OPEN);
$this->getMode()->shouldEqual(ChannelMode::OPEN);
}
function it_should_assign_channel_modes() {
$this->setMode(User::MODE_CLOSED);
$this->getMode()->shouldEqual(User::MODE_CLOSED);
$this->setMode(ChannelMode::CLOSED);
$this->getMode()->shouldEqual(ChannelMode::CLOSED);
$this->setMode(ChannelMode::MODERATED);
$this->getMode()->shouldEqual(ChannelMode::MODERATED);
}
function it_should_export_values() {
$export = $this->export()->getWrappedObject();
expect($export['mode'])->shouldEqual(User::MODE_OPEN);
expect($export['mode'])->shouldEqual(ChannelMode::OPEN);
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment