3
* Copyright (C) 2019 Xibo Signage Ltd
5
* Xibo - Digital Signage - http://www.xibo.org.uk
7
* This file is part of Xibo.
9
* Xibo is free software: you can redistribute it and/or modify
10
* it under the terms of the GNU Affero General Public License as published by
11
* the Free Software Foundation, either version 3 of the License, or
14
* Xibo is distributed in the hope that it will be useful,
15
* but WITHOUT ANY WARRANTY; without even the implied warranty of
16
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17
* GNU Affero General Public License for more details.
19
* You should have received a copy of the GNU Affero General Public License
20
* along with Xibo. If not, see <http://www.gnu.org/licenses/>.
23
namespace Xibo\Tests\integration\Cache;
25
use Xibo\Entity\Display;
26
use Xibo\OAuth2\Client\Entity\XiboDisplay;
27
use Xibo\OAuth2\Client\Entity\XiboImage;
28
use Xibo\OAuth2\Client\Entity\XiboLayout;
29
use Xibo\OAuth2\Client\Entity\XiboLibrary;
30
use Xibo\OAuth2\Client\Entity\XiboPlaylist;
31
use Xibo\OAuth2\Client\Entity\XiboRegion;
32
use Xibo\OAuth2\Client\Entity\XiboSchedule;
33
use Xibo\OAuth2\Client\Entity\XiboText;
34
use Xibo\OAuth2\Client\Entity\XiboTicker;
35
use Xibo\OAuth2\Client\Entity\XiboVideo;
36
use Xibo\Tests\Helper\DisplayHelperTrait;
37
use Xibo\Tests\Helper\LayoutHelperTrait;
38
use Xibo\Tests\LocalWebTestCase;
39
use Xibo\Helper\Random;
42
* Class LayoutProofOfPlayXMLMediaOffWidgetOffTest
43
* @package Xibo\Tests\integration\Cache
45
class LayoutProofOfPlayXMLMediaOffWidgetOffTest extends LocalWebTestCase
47
use LayoutHelperTrait;
48
use DisplayHelperTrait;
50
/** @var XiboLayout */
53
/** @var XiboLayout */
56
/** @var XiboRegion */
59
/** @var XiboDisplay */
62
/** @var XiboDisplay */
65
/** @var XiboTicker */
68
/** @var XiboLibrary */
71
/** @var XiboLibrary */
77
// <editor-fold desc="Init">
78
public function setup()
82
$this->getLogger()->debug('Setup test for ' . get_class() .' Test');
84
// Set global widget enable stat set to Off
85
self::$container->configService->changeSetting('WIDGET_STATS_ENABLED_DEFAULT', 'Off');
86
$this->getStore()->commitIfNecessary();
88
// Create a Layout with enableStat Off (by default)
89
$this->layoutOff = $this->createLayout();
90
$layoutOff = $this->checkout($this->layoutOff);
92
// Upload some media - enableStat is Inherit (from global media stat setting)
93
$this->media = (new XiboLibrary($this->getEntityProvider()))->create(
94
Random::generateString(8, 'API Video'),
95
PROJECT_ROOT . '/tests/resources/HLH264.mp4'
98
// Edit the media to set enableStat On
101
$this->media->duration,
102
$this->media->retired,
104
$this->media->updateInLayouts,
108
// Assign the media we've edited to our regions playlist- widget with Inherit (from global widget stat setting)
109
$playlist = (new XiboPlaylist($this->getEntityProvider()))
110
->assign([$this->media->mediaId], 10, $layoutOff->regions[0]->regionPlaylist->playlistId);
112
// Store the widgetId
113
$this->widgetId = $playlist->widgets[0]->widgetId;
116
$this->display = $this->createDisplay();
118
// Schedule the Layout "always" onto our display
119
// deleting the layout will remove this at the end
120
$event = (new XiboSchedule($this->getEntityProvider()))->createEventLayout(
121
date('Y-m-d H:i:s', time()+3600),
122
date('Y-m-d H:i:s', time()+7200),
123
$this->layoutOff->campaignId,
124
[$this->display->displayGroupId],
134
$this->displaySetStatus($this->display, Display::$STATUS_DONE);
135
$this->displaySetLicensed($this->display);
137
// Create a layout with enableStat On
138
$this->layoutOn = (new XiboLayout($this->getEntityProvider()))->create(
139
Random::generateString(8, 'phpunit'),
140
'phpunit description',
142
$this->getResolutionId('landscape'),
145
$layoutOn = $this->checkout($this->layoutOn);
147
// Assign the media we've created to our regions playlist- widget with Inherit (from global widget stat setting)
148
$playlist2 = (new XiboPlaylist($this->getEntityProvider()))
149
->assign([$this->media->mediaId], 10, $layoutOn->regions[0]->regionPlaylist->playlistId);
151
// Store the widgetId
152
$this->widgetId2 = $playlist2->widgets[0]->widgetId;
155
$this->display2 = $this->createDisplay();
157
// Schedule the LayoutOn "always" onto our display
158
// deleting the layoutOn will remove this at the end
159
$event2 = (new XiboSchedule($this->getEntityProvider()))->createEventLayout(
160
date('Y-m-d H:i:s', time()+3600),
161
date('Y-m-d H:i:s', time()+7200),
162
$this->layoutOn->campaignId,
163
[$this->display2->displayGroupId],
173
$this->displaySetStatus($this->display2, Display::$STATUS_DONE);
174
$this->displaySetLicensed($this->display2);
176
$this->getLogger()->debug('Finished Setup');
179
public function tearDown()
181
$this->getLogger()->debug('Tear Down');
185
// Delete the LayoutOn
186
$this->deleteLayout($this->layoutOff);
188
// Delete the Display2
189
$this->deleteDisplay($this->display);
191
// Delete the LayoutOn
192
$this->deleteLayout($this->layoutOn);
194
// Delete the Display2
195
$this->deleteDisplay($this->display2);
197
// Delete the media record
198
$this->media->deleteAssigned();
200
// Set global widget enable stat set to Inherit
201
self::$container->configService->changeSetting('WIDGET_STATS_ENABLED_DEFAULT', 'Inherit');
202
$this->getStore()->commitIfNecessary();
210
// LAYOUT MEDIA WIDGET Media stats collected?
211
// ON ON ON YES Widget takes precedence // Match - 1
212
// ON OFF ON YES Widget takes precedence // Match - 1
213
// ON INHERIT ON YES Widget takes precedence // Match - 1
215
// OFF ON ON YES Widget takes precedence // Match - 1
216
// OFF OFF ON YES Widget takes precedence // Match - 1
217
// OFF INHERIT ON YES Widget takes precedence // Match - 1
219
// ON ON OFF NO Widget takes precedence // Match - 2
220
// ON OFF OFF NO Widget takes precedence // Match - 2
221
// ON INHERIT OFF NO Widget takes precedence // Match - 2
223
// OFF ON OFF NO Widget takes precedence // Match - 2
224
// OFF OFF OFF NO Widget takes precedence // Match - 2
225
// OFF INHERIT OFF NO Widget takes precedence // Match - 2
227
// ON ON INHERIT YES Media takes precedence // Match - 3
228
// ON OFF INHERIT NO Media takes precedence // Match - 4
229
// ON INHERIT INHERIT YES Media takes precedence and Inherited from Layout // Match - 5
231
// OFF ON INHERIT YES Media takes precedence // Match - 3
232
// OFF OFF INHERIT NO Media takes precedence // Match - 4
233
// OFF INHERIT INHERIT NO Media takes precedence and Inherited from Layout // Match - 6
236
public function testLayoutOff()
239
$response = $this->client->put('/layout/publish/' . $this->layoutOff->layoutId, [
241
], ['CONTENT_TYPE' => 'application/x-www-form-urlencoded']);
242
$response = json_decode($response, true);
244
$this->layoutOff = $this->constructLayoutFromResponse($response['data']);
246
// Confirm our Layout is in the Schedule
247
$schedule = $this->getXmdsWrapper()->Schedule($this->display->license);
248
$this->assertContains('file="' . $this->layoutOff->layoutId . '"', $schedule, 'Layout not scheduled');
250
// Call Required Files
251
$rf = $this->getXmdsWrapper()->RequiredFiles($this->display->license);
253
// Get XML string for player
254
$xmlString = $this->getXmdsWrapper()->GetFile($this->display->license, $this->layoutOff->layoutId, 'layout', 0, 0);
256
// Layout enable stat 0
257
$this->assertContains('<layout width="1920" height="1080" bgcolor="#000" schemaVersion="3" enableStat="0">', $xmlString );
259
// Layout Off, Media Off, Widget Off, Output => [0, 'Off', 'Off', 0],
260
$this->assertContains('<media id="'.$this->widgetId.'" type="video" render="native" duration="0" useDuration="1" fromDt="1970-01-01 01:00:00" toDt="2038-01-19 03:14:07" enableStat="0" fileId="'.$this->media->mediaId.'">', $xmlString );
264
public function testLayoutOn()
268
$response = $this->client->put('/layout/publish/' . $this->layoutOn->layoutId, [
270
], ['CONTENT_TYPE' => 'application/x-www-form-urlencoded']);
271
$response = json_decode($response, true);
273
$this->layoutOn = $this->constructLayoutFromResponse($response['data']);
275
// Confirm our Layout is in the Schedule
276
$schedule = $this->getXmdsWrapper()->Schedule($this->display2->license);
277
$this->assertContains('file="' . $this->layoutOn->layoutId . '"', $schedule, 'Layout not scheduled');
279
// Call Required Files
280
$rf = $this->getXmdsWrapper()->RequiredFiles($this->display2->license);
282
// Get XML string for player
283
$xmlString = $this->getXmdsWrapper()->GetFile($this->display2->license, $this->layoutOn->layoutId, 'layout', 0, 0);
285
// Layout enable stat 1
286
$this->assertContains('<layout width="1920" height="1080" bgcolor="#000" schemaVersion="3" enableStat="1">', $xmlString );
288
// Layout On, Media Off, Widget Off, Output => [1, 'Off', 'Off', 0],
289
$this->assertContains('<media id="'.$this->widgetId2.'" type="video" render="native" duration="0" useDuration="1" fromDt="1970-01-01 01:00:00" toDt="2038-01-19 03:14:07" enableStat="0" fileId="'.$this->media->mediaId.'">', $xmlString );
b'\\ No newline at end of file'