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\Tests\Helper\DisplayHelperTrait;
36
use Xibo\Tests\Helper\LayoutHelperTrait;
37
use Xibo\Tests\LocalWebTestCase;
38
use Xibo\Helper\Random;
41
* Class LayoutProofOfPlayXMLWithoutMediaTest
42
* @package Xibo\Tests\integration\Cache
44
class LayoutProofOfPlayXMLWithoutMediaTest extends LocalWebTestCase
46
use LayoutHelperTrait;
47
use DisplayHelperTrait;
49
/** @var XiboLayout */
52
/** @var XiboLayout */
55
/** @var XiboRegion */
58
/** @var XiboDisplay */
61
/** @var XiboDisplay */
64
/** @var XiboTicker */
71
// <editor-fold desc="Init">
72
public function setup()
76
$this->getLogger()->debug('Setup test for ' . get_class() .' Test');
78
// Create a Layout with enableStat Off (by default)
79
$this->layoutOff = $this->createLayout();
82
$this->display = $this->createDisplay();
84
// Schedule the Layout "always" onto our display
85
// deleting the layoutOff will remove this at the end
86
$event = (new XiboSchedule($this->getEntityProvider()))->createEventLayout(
87
date('Y-m-d H:i:s', time()+3600),
88
date('Y-m-d H:i:s', time()+7200),
89
$this->layoutOff->campaignId,
90
[$this->display->displayGroupId],
100
$this->displaySetStatus($this->display, Display::$STATUS_DONE);
101
$this->displaySetLicensed($this->display);
103
// Create a layout with enableStat On
104
$this->layoutOn = (new XiboLayout($this->getEntityProvider()))->create(
105
Random::generateString(8, 'phpunit'),
106
'phpunit description',
108
$this->getResolutionId('landscape'),
113
$this->display2 = $this->createDisplay();
115
// Schedule the LayoutOn "always" onto our display
116
// deleting the layoutOn will remove this at the end
117
$event2 = (new XiboSchedule($this->getEntityProvider()))->createEventLayout(
118
date('Y-m-d H:i:s', time()+3600),
119
date('Y-m-d H:i:s', time()+7200),
120
$this->layoutOn->campaignId,
121
[$this->display2->displayGroupId],
131
$this->displaySetStatus($this->display2, Display::$STATUS_DONE);
132
$this->displaySetLicensed($this->display2);
134
$this->getLogger()->debug('Finished Setup');
137
public function tearDown()
139
$this->getLogger()->debug('Tear Down');
143
// Delete the LayoutOff
144
$this->deleteLayout($this->layoutOff);
146
// Delete the Display
147
$this->deleteDisplay($this->display);
149
// Delete the LayoutOn
150
$this->deleteLayout($this->layoutOn);
152
// Delete the Display2
153
$this->deleteDisplay($this->display2);
159
// Widget Without Media
160
// LAYOUT WIDGET Widget stats collected?
161
// ON ON YES Widget takes precedence // Match - 1
162
// ON OFF NO Widget takes precedence // Match - 2
163
// ON INHERIT YES Inherited from Layout // Match - 7
164
// OFF ON YES Widget takes precedence // Match - 1
165
// OFF OFF NO Widget takes precedence // Match - 2
166
// OFF INHERIT NO Inherited from Layout // Match - 8
170
* Each array is a test run
171
* Format (enableStat)
174
public function layoutEnableStatOffCases()
177
// Layout enableStat Off options - for layout and widget and their expected result (Widget stats collected?) in enableStat (media node attribute)
178
'Layout Off Media On' => [0, 'On', 1],
179
'Layout Off Media Off' => [0, 'Off', 0],
180
'Layout Off Media Inherit' => [0, 'Inherit', 0]
185
* Each array is a test run
186
* Format (enableStat)
189
public function layoutEnableStatOnCases()
192
// Layout enableStat On options - for layout and widget and their expected result (Widget stats collected?) in enableStat (media node attribute)
193
'Layout On Media On' => [1, 'On', 1],
194
'Layout On Media Off' => [1, 'Off', 0],
195
'Layout On Media Inherit' => [1, 'Inherit', 1]
201
* @dataProvider layoutEnableStatOffCases
203
public function testLayoutOff($layoutEnableStat, $widgetEnableStat, $outputEnableStat)
206
$layoutOff = $this->checkout($this->layoutOff);
208
$response = $this->getEntityProvider()->post('/playlist/widget/text/' . $layoutOff->regions[0]->regionPlaylist->playlistId);
209
$response = $this->getEntityProvider()->put('/playlist/widget/' . $response['widgetId'] , [
210
'text' => 'Widget A',
213
'enableStat' => $widgetEnableStat
216
$this->widget = (new XiboText($this->getEntityProvider()))->hydrate($response);
219
$response = $this->client->put('/layout/publish/' . $this->layoutOff->layoutId, [
221
], ['CONTENT_TYPE' => 'application/x-www-form-urlencoded']);
222
$response = json_decode($response, true);
224
$this->layoutOff = $this->constructLayoutFromResponse($response['data']);
225
$this->getLogger()->debug($this->layoutOff->enableStat);
227
// Confirm our Layout is in the Schedule
228
$schedule = $this->getXmdsWrapper()->Schedule($this->display->license);
229
$this->assertContains('file="' . $this->layoutOff->layoutId . '"', $schedule, 'Layout not scheduled');
231
// Call Required Files
232
$rf = $this->getXmdsWrapper()->RequiredFiles($this->display->license);
234
// Get XML string for player
235
$xmlString = $this->getXmdsWrapper()->GetFile($this->display->license, $this->layoutOff->layoutId, 'layout', 0, 0);
236
$this->assertContains('<layout width="1920" height="1080" bgcolor="#000" schemaVersion="3" enableStat="'.$layoutEnableStat.'">', $xmlString );
237
$this->assertContains('<media id="'.$this->widget->widgetId.'" type="text" render="native" duration="100" useDuration="1" fromDt="1970-01-01 01:00:00" toDt="2038-01-19 03:14:07" enableStat="'.$outputEnableStat.'">', $xmlString );
242
* @dataProvider layoutEnableStatOnCases
244
public function testLayoutOn($layoutEnableStat, $widgetEnableStat, $outputEnableStat)
247
$layoutOn = $this->checkout($this->layoutOn);
249
$response = $this->getEntityProvider()->post('/playlist/widget/text/' . $layoutOn->regions[0]->regionPlaylist->playlistId);
250
$response = $this->getEntityProvider()->put('/playlist/widget/' . $response['widgetId'] , [
251
'text' => 'Widget A',
254
'enableStat' => $widgetEnableStat
257
$this->widget = (new XiboText($this->getEntityProvider()))->hydrate($response);
260
$response = $this->client->put('/layout/publish/' . $this->layoutOn->layoutId, [
262
], ['CONTENT_TYPE' => 'application/x-www-form-urlencoded']);
263
$response = json_decode($response, true);
265
$this->layoutOn = $this->constructLayoutFromResponse($response['data']);
266
$this->getLogger()->debug($this->layoutOn->enableStat);
268
// Confirm our Layout is in the Schedule
269
$schedule = $this->getXmdsWrapper()->Schedule($this->display2->license);
270
$this->assertContains('file="' . $this->layoutOn->layoutId . '"', $schedule, 'Layout not scheduled');
272
// Call Required Files
273
$rf = $this->getXmdsWrapper()->RequiredFiles($this->display2->license);
275
// Get XML string for player
276
$xmlString = $this->getXmdsWrapper()->GetFile($this->display2->license, $this->layoutOn->layoutId, 'layout', 0, 0);
277
$this->assertContains('<layout width="1920" height="1080" bgcolor="#000" schemaVersion="3" enableStat="'.$layoutEnableStat.'">', $xmlString );
278
$this->assertContains('<media id="'.$this->widget->widgetId.'" type="text" render="native" duration="100" useDuration="1" fromDt="1970-01-01 01:00:00" toDt="2038-01-19 03:14:07" enableStat="'.$outputEnableStat.'">', $xmlString );
b'\\ No newline at end of file'