mirror of
https://github.com/humhub/humhub.git
synced 2025-01-29 12:28:06 +01:00
Added test to WallEntryOptionsTest
This commit is contained in:
parent
6424e64ffd
commit
5cceb8575b
@ -5,12 +5,14 @@ namespace humhub\modules\content\tests\codeception\unit\widgets;
|
||||
|
||||
|
||||
use humhub\modules\content\helpers\ContentContainerHelper;
|
||||
use humhub\modules\content\widgets\DeleteLink;
|
||||
use humhub\modules\content\widgets\stream\StreamEntryOptions;
|
||||
use humhub\modules\content\widgets\stream\StreamEntryWidget;
|
||||
use humhub\modules\content\widgets\stream\WallStreamEntryOptions;
|
||||
use humhub\modules\content\widgets\WallEntryControls;
|
||||
use humhub\modules\post\models\Post;
|
||||
use humhub\modules\post\widgets\WallEntry;
|
||||
use humhub\modules\ui\menu\WidgetMenuEntry;
|
||||
use tests\codeception\_support\HumHubDbTestCase;
|
||||
|
||||
class WallEntryOptionsTest extends HumHubDbTestCase
|
||||
@ -25,6 +27,7 @@ class WallEntryOptionsTest extends HumHubDbTestCase
|
||||
$this->assertEquals(WallEntry::class, $wallStreamEntryOptions->getStreamEntryWidgetClass());
|
||||
}
|
||||
|
||||
|
||||
public function testDisableControlsEdit()
|
||||
{
|
||||
$this->testDisableControlsItem('Edit',
|
||||
@ -135,6 +138,33 @@ class WallEntryOptionsTest extends HumHubDbTestCase
|
||||
]));
|
||||
}
|
||||
|
||||
public function testWallEntryIsUsingOwnOptionInstance()
|
||||
{
|
||||
$this->becomeUser('admin');
|
||||
|
||||
$model = Post::findOne(['id' => 1]);
|
||||
|
||||
$renderOptions = new WallStreamEntryOptions();
|
||||
$renderOptions->viewContext(StreamEntryOptions::VIEW_CONTEXT_MODAL);
|
||||
$renderOptions->disableControlsEntryEdit();
|
||||
|
||||
$wallEntryA = new WallEntry(['model' => $model, 'renderOptions' => $renderOptions]);
|
||||
$wallEntryB = new WallEntry(['model' => $model, 'renderOptions' => $renderOptions]);
|
||||
|
||||
$wallEntryA->renderOptions->disableControlsEntryDelete();
|
||||
|
||||
static::assertEquals(StreamEntryOptions::VIEW_CONTEXT_MODAL, $wallEntryA->renderOptions->getViewContext());
|
||||
static::assertEquals(StreamEntryOptions::VIEW_CONTEXT_MODAL, $wallEntryB->renderOptions->getViewContext());
|
||||
|
||||
static::assertTrue($wallEntryA->renderOptions->isContextMenuEntryDisabled(new WidgetMenuEntry(['widgetClass' => DeleteLink::class])));
|
||||
static::assertFalse($wallEntryB->renderOptions->isContextMenuEntryDisabled(new WidgetMenuEntry(['widgetClass' => DeleteLink::class])));
|
||||
|
||||
$wallEntryB->renderOptions->viewContext(StreamEntryOptions::VIEW_CONTEXT_DASHBOARD);
|
||||
|
||||
static::assertEquals(StreamEntryOptions::VIEW_CONTEXT_MODAL, $wallEntryA->renderOptions->getViewContext());
|
||||
static::assertEquals(StreamEntryOptions::VIEW_CONTEXT_DASHBOARD, $wallEntryB->renderOptions->getViewContext());
|
||||
}
|
||||
|
||||
private function assertWallEntryControlsContains($searchStr, $renderOptions)
|
||||
{
|
||||
$this->becomeUser('admin');
|
||||
|
Loading…
x
Reference in New Issue
Block a user