Files
Cloud-CMS/tests/integration/Cache/PlaylistReorderTest.php

157 lines
4.9 KiB
PHP
Raw Normal View History

2025-12-02 10:32:59 -05:00
<?php
/**
* Copyright (C) 2020 Xibo Signage Ltd
*
* Xibo - Digital Signage - http://www.xibo.org.uk
*
* This file is part of Xibo.
*
* Xibo is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* Xibo is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with Xibo. If not, see <http://www.gnu.org/licenses/>.
*/
namespace Xibo\Tests\integration\Cache;
use Carbon\Carbon;
use Xibo\Entity\Display;
use Xibo\Helper\DateFormatHelper;
use Xibo\OAuth2\Client\Entity\XiboDisplay;
use Xibo\OAuth2\Client\Entity\XiboLayout;
use Xibo\OAuth2\Client\Entity\XiboSchedule;
use Xibo\OAuth2\Client\Entity\XiboText;
use Xibo\Tests\Helper\DisplayHelperTrait;
use Xibo\Tests\Helper\LayoutHelperTrait;
use Xibo\Tests\LocalWebTestCase;
/**
* Class PlaylistReorderTest
* @package Xibo\Tests\integration\Cache
*/
class PlaylistReorderTest extends LocalWebTestCase
{
use LayoutHelperTrait;
use DisplayHelperTrait;
/** @var XiboLayout */
protected $layout;
protected $widget1;
protected $widget2;
/** @var XiboDisplay */
protected $display;
// <editor-fold desc="Init">
public function setup()
{
parent::setup();
$this->getLogger()->debug('Setup test for Cache Region Edit Test');
// Create a Layout
$this->layout = $this->createLayout();
// Checkout
$layout = $this->getDraft($this->layout);
// Add a couple of text widgets to the region
$response = $this->getEntityProvider()->post('/playlist/widget/text/' . $layout->regions[0]->regionPlaylist->playlistId);
$response = $this->getEntityProvider()->put('/playlist/widget/' . $response['widgetId'], [
'text' => 'Widget A',
'duration' => 100,
'useDuration' => 1
]);
$this->widget1 = (new XiboText($this->getEntityProvider()))->hydrate($response);
$response = $this->getEntityProvider()->post('/playlist/widget/text/' . $layout->regions[0]->regionPlaylist->playlistId);
$response = $this->getEntityProvider()->put('/playlist/widget/' . $response['widgetId'], [
'text' => 'Widget B',
'duration' => 100,
'useDuration' => 1
]);
$this->widget2 = (new XiboText($this->getEntityProvider()))->hydrate($response);
// Publish
$this->layout = $this->publish($this->layout);
// Set the Layout status
$this->setLayoutStatus($this->layout, 1);
// Create a Display
$this->display = $this->createDisplay();
// Schedule the Layout "always" onto our display
// deleting the layout will remove this at the end
$event = (new XiboSchedule($this->getEntityProvider()))->createEventLayout(
Carbon::now()->format(DateFormatHelper::getSystemFormat()),
Carbon::now()->addSeconds(7200)->format(DateFormatHelper::getSystemFormat()),
$this->layout->campaignId,
[$this->display->displayGroupId],
0,
NULL,
NULL,
NULL,
0,
0,
0
);
$this->displaySetStatus($this->display, Display::$STATUS_DONE);
}
public function tearDown()
{
parent::tearDown();
// Delete the Layout we've been working with
$this->deleteLayout($this->layout);
// Delete the Display
$this->deleteDisplay($this->display);
}
// </editor-fold>
/**
* @group cacheInvalidateTests
*/
public function testInvalidateCache()
{
// Checkout
$layout = $this->checkout($this->layout);
// Edit region
$this->sendRequest('POST','/playlist/order/' . $layout->regions[0]->regionPlaylist->playlistId, [
'widgets' => [
$this->widget1->widgetId => 2,
$this->widget2->widgetId => 1
]
]);
// This shouldn't effect the display
$this->assertTrue($this->displayStatusEquals($this->display, Display::$STATUS_DONE), 'Display Status isnt as expected');
// Publish
$this->layout = $this->publish($this->layout);
// Check the Layout Status
// Validate the layout status afterwards
$this->assertTrue($this->layoutStatusEquals($this->layout, 1), 'Layout Status isnt as expected');
// Validate the display status afterwards
$this->assertTrue($this->displayStatusEquals($this->display, Display::$STATUS_PENDING), 'Display Status isnt as expected');
}
}