Initial Upload

This commit is contained in:
Matt Batchelder
2025-12-02 10:32:59 -05:00
commit 05ce0da296
2240 changed files with 467811 additions and 0 deletions

View File

@@ -0,0 +1,147 @@
<?php
/*
* Copyright (C) 2025 Xibo Signage Ltd
*
* Xibo - Digital Signage - https://xibosignage.com
*
* 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\Helper\Random;
use Xibo\OAuth2\Client\Entity\XiboCampaign;
use Xibo\OAuth2\Client\Entity\XiboDisplay;
use Xibo\OAuth2\Client\Entity\XiboLayout;
use Xibo\OAuth2\Client\Entity\XiboSchedule;
use Xibo\Tests\Helper\DisplayHelperTrait;
use Xibo\Tests\Helper\LayoutHelperTrait;
use Xibo\Tests\LocalWebTestCase;
/**
* Class CampaignDeleteTest
* @package Xibo\Tests\integration\Cache
*/
class CampaignDeleteTest extends LocalWebTestCase
{
use LayoutHelperTrait;
use DisplayHelperTrait;
/** @var XiboCampaign */
protected $campaign;
/** @var XiboLayout */
protected $layout;
/** @var XiboDisplay */
protected $display;
/** @var XiboSchedule */
protected $event;
// <editor-fold desc="Init">
public function setup()
{
parent::setup();
$this->getLogger()->debug('Setup test for Cache ' . get_class($this) .' Test');
// Create a Layout
$this->layout = $this->createLayout();
// Checkout
$layout = $this->getDraft($this->layout);
// Add a simple widget
$this->addSimpleWidget($layout);
// Check us in again
$this->layout = $this->publish($this->layout);
// Build the layout
$this->buildLayout($this->layout);
// Create a Campaign
$this->campaign = (new XiboCampaign($this->getEntityProvider()))->create(Random::generateString());
// Assign the Layout to the Campaign
$this->getEntityProvider()->post('/campaign/layout/assign/' . $this->campaign->campaignId, [
'layoutId' => $this->layout->layoutId
]);
// Create a Display
$this->display = $this->createDisplay();
// Date
$date = Carbon::now();
// Schedule the Campaign "always" onto our display
// deleting the layout will remove this at the end
$this->event = (new XiboSchedule($this->getEntityProvider()))->createEventLayout(
$date->format(DateFormatHelper::getSystemFormat()),
$date->addHours(3)->format(DateFormatHelper::getSystemFormat()),
$this->campaign->campaignId,
[$this->display->displayGroupId],
0,
NULL,
NULL,
NULL,
0,
0,
0
);
$this->displaySetStatus($this->display, Display::$STATUS_DONE);
$this->displaySetLicensed($this->display);
$this->getLogger()->debug('Finished Setup');
}
public function tearDown()
{
$this->getLogger()->debug('Tear Down');
// Delete the Layout we've been working with
$this->deleteLayout($this->layout);
// Delete the Display
$this->deleteDisplay($this->display);
parent::tearDown();
}
// </editor-fold>
/**
* @group cacheInvalidateTests
*/
public function testInvalidateCache()
{
// Make sure our Display is already DONE
$this->assertTrue($this->displayStatusEquals($this->display, Display::$STATUS_DONE), 'Display Status isnt as expected');
// Delete the Campaign
$this->sendRequest('DELETE', '/campaign/' . $this->campaign->campaignId);
// Validate the display status afterwards
$this->assertTrue($this->displayStatusEquals($this->display, Display::$STATUS_PENDING), 'Display Status isnt as expected');
// Validate that XMR has been called.
$this->assertTrue(in_array($this->display->displayId, $this->getPlayerActionQueue()), 'Player action not present');
}
}

View File

@@ -0,0 +1,146 @@
<?php
/**
* Copyright (C) 2021 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\Helper\Random;
use Xibo\OAuth2\Client\Entity\XiboCampaign;
use Xibo\OAuth2\Client\Entity\XiboDisplay;
use Xibo\OAuth2\Client\Entity\XiboLayout;
use Xibo\OAuth2\Client\Entity\XiboSchedule;
use Xibo\Tests\Helper\DisplayHelperTrait;
use Xibo\Tests\Helper\LayoutHelperTrait;
use Xibo\Tests\LocalWebTestCase;
/**
* Class CampaignLayoutAssignTest
* @package Xibo\Tests\integration\Cache
*/
class CampaignLayoutAssignTest extends LocalWebTestCase
{
use LayoutHelperTrait;
use DisplayHelperTrait;
/** @var XiboCampaign */
protected $campaign;
/** @var XiboLayout */
protected $layout;
/** @var XiboDisplay */
protected $display;
/** @var XiboSchedule */
protected $event;
// <editor-fold desc="Init">
public function setup()
{
parent::setup();
$this->getLogger()->debug('Setup test for Cache Campaign Layout Unassign Test');
// Create a Layout
$this->layout = $this->createLayout();
// Checkout
$layout = $this->getDraft($this->layout);
// Add a simple widget
$this->addSimpleWidget($layout);
// Check us in again
$this->layout = $this->publish($this->layout);
// Build the layout
$this->buildLayout($this->layout);
// Create a Campaign
$this->campaign = (new XiboCampaign($this->getEntityProvider()))->create(Random::generateString());
// Create a Display
$this->display = $this->createDisplay();
// Date
$date = Carbon::now();
// Schedule the Campaign "always" onto our display
// deleting the layout will remove this at the end
$this->event = (new XiboSchedule($this->getEntityProvider()))->createEventLayout(
$date->format(DateFormatHelper::getSystemFormat()),
$date->addHours(3)->format(DateFormatHelper::getSystemFormat()),
$this->campaign->campaignId,
[$this->display->displayGroupId],
0,
NULL,
NULL,
NULL,
0,
0,
0
);
$this->displaySetStatus($this->display, Display::$STATUS_DONE);
$this->displaySetLicensed($this->display);
$this->getLogger()->debug('Finished Setup');
}
public function tearDown()
{
$this->getLogger()->debug('Tear Down');
// Delete the Layout we've been working with
$this->deleteLayout($this->layout);
// Delete the Display
$this->deleteDisplay($this->display);
// Delete the Campaign
$this->campaign->delete();
parent::tearDown();
}
// </editor-fold>
/**
* @group cacheInvalidateTests
*/
public function testInvalidateCache()
{
// Make sure our Display is already DONE
$this->assertTrue($this->displayStatusEquals($this->display, Display::$STATUS_DONE), 'Display Status isnt Done as expected');
// Add the Layout we have prepared to the existing Campaign
$this->sendRequest('POST', '/campaign/layout/assign/' . $this->campaign->campaignId, [
'layoutId' => $this->layout->layoutId
]);
// Validate the display status afterwards
$this->assertTrue($this->displayStatusEquals($this->display, Display::$STATUS_PENDING), 'Display Status isnt Pending as expected');
// Validate that XMR has been called.
$this->assertTrue(in_array($this->display->displayId, $this->getPlayerActionQueue()), 'Player action not present');
}
}

View File

@@ -0,0 +1,155 @@
<?php
/*
* Copyright (C) 2025 Xibo Signage Ltd
*
* Xibo - Digital Signage - https://xibosignage.com
*
* 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\Helper\Random;
use Xibo\OAuth2\Client\Entity\XiboCampaign;
use Xibo\OAuth2\Client\Entity\XiboDisplay;
use Xibo\OAuth2\Client\Entity\XiboLayout;
use Xibo\OAuth2\Client\Entity\XiboSchedule;
use Xibo\Tests\Helper\DisplayHelperTrait;
use Xibo\Tests\Helper\LayoutHelperTrait;
use Xibo\Tests\LocalWebTestCase;
/**
* Class CampaignLayoutUnassignTest
* @package Xibo\Tests\integration\Cache
*/
class CampaignLayoutUnassignTest extends LocalWebTestCase
{
use LayoutHelperTrait;
use DisplayHelperTrait;
/** @var XiboCampaign */
protected $campaign;
/** @var XiboLayout */
protected $layout;
/** @var XiboDisplay */
protected $display;
/** @var XiboSchedule */
protected $event;
// <editor-fold desc="Init">
public function setup()
{
parent::setup();
$this->getLogger()->debug('Setup test for Cache ' . get_class($this) .' Test');
// Create a Layout
$this->layout = $this->createLayout();
// Checkout
$layout = $this->getDraft($this->layout);
// Add a simple widget
$this->addSimpleWidget($layout);
// Check us in again
$this->layout = $this->publish($this->layout);
// Build the layout
$this->buildLayout($this->layout);
// Create a Campaign
$this->campaign = (new XiboCampaign($this->getEntityProvider()))->create(Random::generateString());
// Assign the Layout to the Campaign
$this->getEntityProvider()->post('/campaign/layout/assign/' . $this->campaign->campaignId, [
'layoutId' => $this->layout->layoutId
]);
// Create a Display
$this->display = $this->createDisplay();
// Date
$date = Carbon::now();
// Schedule the Campaign "always" onto our display
// deleting the layout will remove this at the end
$this->event = (new XiboSchedule($this->getEntityProvider()))->createEventLayout(
$date->format(DateFormatHelper::getSystemFormat()),
$date->addHours(3)->format(DateFormatHelper::getSystemFormat()),
$this->campaign->campaignId,
[$this->display->displayGroupId],
0,
NULL,
NULL,
NULL,
0,
0,
0
);
$this->displaySetStatus($this->display, Display::$STATUS_DONE);
$this->displaySetLicensed($this->display);
$this->getLogger()->debug('Finished Setup');
}
public function tearDown()
{
$this->getLogger()->debug('Tear Down');
parent::tearDown();
// Delete the Layout we've been working with
$this->deleteLayout($this->layout);
// Delete the Display
$this->deleteDisplay($this->display);
// Delete the Campaign
$this->campaign->delete();
}
// </editor-fold>
/**
* @group cacheInvalidateTests
*/
public function testInvalidateCache()
{
// Make sure our Display is already DONE
$this->assertTrue($this->displayStatusEquals($this->display, Display::$STATUS_DONE), 'Display Status isnt as expected');
// Unassign requires edit
$this->sendRequest('PUT', '/campaign/' . $this->campaign->campaignId, [
'name' => $this->campaign->campaign,
'manageLayouts' => 1,
'layoutIds' => [] // empty list
]);
// Validate the display status afterwards
$this->assertTrue($this->displayStatusEquals($this->display, Display::$STATUS_PENDING), 'Display Status isnt as expected');
// Validate that XMR has been called.
$this->assertTrue(in_array($this->display->displayId, $this->getPlayerActionQueue()), 'Player action not present');
}
}

View File

@@ -0,0 +1,159 @@
<?php
/*
* Copyright (C) 2025 Xibo Signage Ltd
*
* Xibo - Digital Signage - https://xibosignage.com
*
* 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\DataSetColumn;
use Xibo\Entity\Display;
use Xibo\Helper\DateFormatHelper;
use Xibo\Helper\Random;
use Xibo\OAuth2\Client\Entity\XiboDataSet;
use Xibo\OAuth2\Client\Entity\XiboDataSetColumn;
use Xibo\OAuth2\Client\Entity\XiboDataSetView;
use Xibo\OAuth2\Client\Entity\XiboDisplay;
use Xibo\OAuth2\Client\Entity\XiboLayout;
use Xibo\OAuth2\Client\Entity\XiboSchedule;
use Xibo\OAuth2\Client\Entity\XiboWidget;
use Xibo\Tests\Helper\DisplayHelperTrait;
use Xibo\Tests\Helper\LayoutHelperTrait;
use Xibo\Tests\LocalWebTestCase;
/**
* Class DataSetDataEditTest
* @package Xibo\Tests\integration\Cache
*/
class DataSetDataEditTest extends LocalWebTestCase
{
use LayoutHelperTrait;
use DisplayHelperTrait;
/** @var XiboDataSet */
protected $dataSet;
/** @var DataSetColumn */
protected $dataSetColumn;
/** @var XiboLayout */
protected $layout;
/** @var XiboWidget */
protected $widget;
/** @var XiboDisplay */
protected $display;
// <editor-fold desc="Init">
public function setup()
{
parent::setup();
$this->getLogger()->debug('Setup test for Cache ' . get_class($this) .' Test');
// Add a DataSet
$this->dataSet = (new XiboDataSet($this->getEntityProvider()))->create(Random::generateString(), 'Test');
// Add a Column
$this->dataSetColumn = (new XiboDataSetColumn($this->getEntityProvider()))->create($this->dataSet->dataSetId,
Random::generateString(),
'',
1,
1,
1,
'');
// 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/datasetview/' . $layout->regions[0]->regionPlaylist->playlistId);
$response = $this->getEntityProvider()->put('/playlist/widget/' . $response['widgetId'], [
'step' => 1,
'dataSetId' => $this->dataSet->dataSetId
]);
$this->widget = (new XiboDataSetView($this->getEntityProvider()))->hydrate($response);
// Check in
$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 DataSet
$this->dataSet->deleteWData();
// Delete the Display
$this->deleteDisplay($this->display);
}
// </editor-fold>
/**
* @group cacheInvalidateTests
*/
public function testInvalidateCache()
{
// Add Data to the DataSet
$this->sendRequest('POST','/dataset/data/'. $this->dataSet->dataSetId, [
'dataSetColumnId_' . $this->dataSetColumn->dataSetColumnId => '1'
]);
// Validate the display status afterwards
$this->assertTrue($this->displayStatusEquals($this->display, Display::$STATUS_PENDING), 'Display Status isnt as expected');
// Somehow test that we have issued an XMR request
$this->assertTrue(in_array($this->display->displayId, $this->getPlayerActionQueue()), 'Player action not present');
}
}

View File

@@ -0,0 +1,145 @@
<?php
/*
* Copyright (C) 2025 Xibo Signage Ltd
*
* Xibo - Digital Signage - https://xibosignage.com
*
* 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\Helper\Random;
use Xibo\OAuth2\Client\Entity\XiboDisplay;
use Xibo\OAuth2\Client\Entity\XiboDisplayGroup;
use Xibo\OAuth2\Client\Entity\XiboLayout;
use Xibo\OAuth2\Client\Entity\XiboSchedule;
use Xibo\Tests\Helper\DisplayHelperTrait;
use Xibo\Tests\Helper\LayoutHelperTrait;
use Xibo\Tests\LocalWebTestCase;
/**
* Class DisplayGroupDisplayAssignTest
* @package Xibo\Tests\integration\Cache
*/
class DisplayGroupDisplayAssignTest extends LocalWebTestCase
{
use LayoutHelperTrait;
use DisplayHelperTrait;
/** @var XiboLayout */
protected $layout;
/** @var XiboDisplay */
protected $display;
/** @var XiboDisplayGroup */
protected $displayGroup;
// <editor-fold desc="Init">
public function setup()
{
parent::setup();
$this->getLogger()->debug('Setup test for Cache ' . get_class($this) .' Test');
// Create a Layout
$this->layout = $this->createLayout();
// Checkout
$layout = $this->getDraft($this->layout);
// Add a simple widget
$this->addSimpleWidget($layout);
// Check us in again
$this->layout = $this->publish($this->layout);
// Build the layout
$this->buildLayout($this->layout);
// Create a Display Group
$this->displayGroup = (new XiboDisplayGroup($this->getEntityProvider()))->create(Random::generateString(), 'Cache Test', 0, null);
// Schedule the Layout "always" onto our display group
// deleting the layout will remove this at the end
$this->event = (new XiboSchedule($this->getEntityProvider()))->createEventLayout(
Carbon::now()->format(DateFormatHelper::getSystemFormat()),
Carbon::now()->addSeconds(7200)->format(DateFormatHelper::getSystemFormat()),
$this->layout->campaignId,
[$this->displayGroup->displayGroupId],
0,
NULL,
NULL,
NULL,
0,
0,
0
);
// Create a Display
$this->display = $this->createDisplay();
$this->displaySetStatus($this->display, Display::$STATUS_DONE);
$this->displaySetLicensed($this->display);
$this->getLogger()->debug('Finished Setup');
}
public function tearDown()
{
$this->getLogger()->debug('Tear Down');
parent::tearDown();
// Delete the Layout we've been working with
$this->deleteLayout($this->layout);
// Delete the Display
$this->deleteDisplay($this->display);
// Delete the Display Group
$this->displayGroup->delete();
}
// </editor-fold>
/**
* @group cacheInvalidateTests
*/
public function testInvalidateCache()
{
// Make sure our Display is already DONE
$this->assertTrue($this->displayStatusEquals($this->display, Display::$STATUS_DONE), 'Display Status isnt as expected');
// Add the Layout we have prepared to the Display Group
$response = $this->sendRequest('POST','/displaygroup/' . $this->displayGroup->displayGroupId . '/display/assign', [
'displayId' => [$this->display->displayId]
]);
$object = json_decode($response->getBody());
$this->assertSame(204, $object->status);
// Validate the display status afterwards
$this->assertTrue($this->displayStatusEquals($this->display, Display::$STATUS_PENDING), 'Display Status isnt as expected');
// Validate that XMR has been called.
$this->assertTrue(in_array($this->display->displayId, $this->getPlayerActionQueue()), 'Player action not present');
}
}

View File

@@ -0,0 +1,147 @@
<?php
/*
* Copyright (C) 2025 Xibo Signage Ltd
*
* Xibo - Digital Signage - https://xibosignage.com
*
* 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\Helper\Random;
use Xibo\OAuth2\Client\Entity\XiboDisplay;
use Xibo\OAuth2\Client\Entity\XiboDisplayGroup;
use Xibo\OAuth2\Client\Entity\XiboLayout;
use Xibo\OAuth2\Client\Entity\XiboSchedule;
use Xibo\Tests\Helper\DisplayHelperTrait;
use Xibo\Tests\Helper\LayoutHelperTrait;
use Xibo\Tests\LocalWebTestCase;
/**
* Class DisplayGroupDisplayUnassignTest
* @package Xibo\Tests\integration\Cache
*/
class DisplayGroupDisplayUnassignTest extends LocalWebTestCase
{
use LayoutHelperTrait;
use DisplayHelperTrait;
/** @var XiboLayout */
protected $layout;
/** @var XiboDisplay */
protected $display;
/** @var XiboDisplayGroup */
protected $displayGroup;
// <editor-fold desc="Init">
public function setup()
{
parent::setup();
$this->getLogger()->debug('Setup test for Cache ' . get_class($this) .' Test');
// Create a Layout
$this->layout = $this->createLayout();
// Checkout
$layout = $this->getDraft($this->layout);
// Add a simple widget
$this->addSimpleWidget($layout);
// Check us in again
$this->layout = $this->publish($this->layout);
// Build the layout
$this->buildLayout($this->layout);
// Create a Display Group
$this->displayGroup = (new XiboDisplayGroup($this->getEntityProvider()))->create(Random::generateString(), 'Cache Test', 0, null);
// Schedule the Layout "always" onto our display group
// deleting the layout will remove this at the end
$this->event = (new XiboSchedule($this->getEntityProvider()))->createEventLayout(
Carbon::now()->format(DateFormatHelper::getSystemFormat()),
Carbon::now()->addSeconds(7200)->format(DateFormatHelper::getSystemFormat()),
$this->layout->campaignId,
[$this->displayGroup->displayGroupId],
0,
NULL,
NULL,
NULL,
0,
0,
0
);
// Create a Display
$this->display = $this->createDisplay();
// Assign my Display to the Group
$this->getEntityProvider()->post('/displaygroup/' . $this->displayGroup->displayGroupId . '/display/assign', [
'displayId' => [$this->display->displayId]
]);
$this->displaySetStatus($this->display, Display::$STATUS_DONE);
$this->displaySetLicensed($this->display);
$this->getLogger()->debug('Finished Setup');
}
public function tearDown()
{
$this->getLogger()->debug('Tear Down');
parent::tearDown();
// Delete the Layout we've been working with
$this->deleteLayout($this->layout);
// Delete the Display
$this->deleteDisplay($this->display);
// Delete the Display Group
$this->displayGroup->delete();
}
// </editor-fold>
/**
* @group cacheInvalidateTests
*/
public function testInvalidateCache()
{
// Make sure our Display is already DONE
$this->assertTrue($this->displayStatusEquals($this->display, Display::$STATUS_DONE), 'Display Status isnt as expected');
// Unassign
$this->sendRequest('POST','/displaygroup/' . $this->displayGroup->displayGroupId . '/display/unassign', [
'displayId' => [$this->display->displayId]
]);
// Validate the display status afterwards
$this->assertTrue($this->displayStatusEquals($this->display, Display::$STATUS_PENDING), 'Display Status isnt as expected');
// Validate that XMR has been called.
$this->assertTrue(in_array($this->display->displayId, $this->getPlayerActionQueue()), 'Player action not present');
}
}

View File

@@ -0,0 +1,181 @@
<?php
/*
* Copyright (C) 2025 Xibo Signage Ltd
*
* Xibo - Digital Signage - https://xibosignage.com
*
* 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\Helper\Random;
use Xibo\OAuth2\Client\Entity\XiboDisplay;
use Xibo\OAuth2\Client\Entity\XiboDisplayGroup;
use Xibo\OAuth2\Client\Entity\XiboLayout;
use Xibo\OAuth2\Client\Entity\XiboSchedule;
use Xibo\Tests\Helper\DisplayHelperTrait;
use Xibo\Tests\Helper\LayoutHelperTrait;
use Xibo\Tests\LocalWebTestCase;
/**
* Class DisplayGroupDynamicDisplayTest
* @package Xibo\Tests\integration\Cache
*/
class DisplayGroupDynamicDisplayTest extends LocalWebTestCase
{
use LayoutHelperTrait;
use DisplayHelperTrait;
/** @var XiboLayout */
protected $layout;
/** @var XiboDisplay */
protected $display;
/** @var XiboDisplayGroup */
protected $displayGroup;
// <editor-fold desc="Init">
public function setup()
{
parent::setup();
$this->getLogger()->debug('Setup test for Cache ' . get_class($this) .' Test');
// Create a Layout
$this->layout = $this->createLayout();
// Checkout
$layout = $this->getDraft($this->layout);
// Add a simple widget
$this->addSimpleWidget($layout);
// Check us in again
$this->layout = $this->publish($this->layout);
// Create a Display Group
// this matches all displays created by the test suite
$this->displayGroup = (new XiboDisplayGroup($this->getEntityProvider()))->create(
Random::generateString(),
'Cache Test',
1,
'phpunit');
$this->getLogger()->debug('DisplayGroup created with ID ' . $this->displayGroup->displayGroupId);
// Schedule the Layout "always" onto our display group
// 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->displayGroup->displayGroupId],
0,
NULL,
NULL,
NULL,
0,
0,
0
);
$this->getLogger()->debug('Schedule created with ID ' . $event->eventId);
// Create a Display
$this->display = $this->createDisplay();
// Run regular maintenance to add the new display to our group.
$this->runRegularMaintenance();
$this->getLogger()->debug('Display created with ID ' . $this->display->displayId);
$this->displaySetStatus($this->display, Display::$STATUS_DONE);
$this->displaySetLicensed($this->display);
$this->getLogger()->debug('Finished Setup');
}
public function tearDown()
{
$this->getLogger()->debug('Tear Down');
parent::tearDown();
// Delete the Layout we've been working with
$this->deleteLayout($this->layout);
// Delete the Display Group
$this->displayGroup->delete();
// Delete the Display
$this->deleteDisplay($this->display);
}
// </editor-fold>
/**
* @group cacheInvalidateTests
*/
public function testInvalidateCache()
{
// Make sure our Display is already DONE
$this->assertTrue($this->displayStatusEquals($this->display, Display::$STATUS_DONE), 'Display Status isnt as expected');
$this->getLogger()->debug('Renaming display');
// Rename the display
$response = $this->sendRequest('PUT','/display/' . $this->display->displayId, [
'display' => Random::generateString(10, 'testedited'),
'defaultLayoutId' => $this->display->defaultLayoutId,
'auditingUntil' => null,
'licensed' => $this->display->licensed,
'license' => $this->display->license,
'incSchedule' => $this->display->incSchedule,
'emailAlert' => $this->display->emailAlert,
'wakeOnLanEnabled' => $this->display->wakeOnLanEnabled,
], ['CONTENT_TYPE' => 'application/x-www-form-urlencoded']);
// There isn't anything directly on the display - so that will NOT trigger anything. The schedule is on the Display Group.
$this->getLogger()->debug('Finished renaming display');
$this->assertLessThan(300, $response->getStatusCode(), 'Non-success status code, body =' . $response->getBody()->getContents());
// Initially we're expecting no change.
$this->assertTrue($this->displayStatusEquals($this->display, Display::$STATUS_DONE), 'Display Status isnt as expected');
// Run regular maintenance
$this->runRegularMaintenance();
// Validate the display status afterwards
$this->assertTrue($this->displayStatusEquals($this->display, Display::$STATUS_PENDING), 'Display Status isnt as expected');
// Our player action would have been sent by regular maintenance, not by the edit.
// Make sure we don't have one here.
$this->assertFalse(in_array($this->display->displayId, $this->getPlayerActionQueue()), 'Player action not present');
}
private function runRegularMaintenance()
{
$this->getLogger()->debug('Running Regular Maintenance');
exec('cd /var/www/cms; php bin/run.php 2');
$this->getLogger()->debug('Finished Regular Maintenance');
}
}

View File

@@ -0,0 +1,115 @@
<?php
/*
* Copyright (C) 2025 Xibo Signage Ltd
*
* Xibo - Digital Signage - https://xibosignage.com
*
* 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 Xibo\Entity\Display;
use Xibo\OAuth2\Client\Entity\XiboDisplay;
use Xibo\OAuth2\Client\Entity\XiboLayout;
use Xibo\Tests\Helper\DisplayHelperTrait;
use Xibo\Tests\Helper\LayoutHelperTrait;
use Xibo\Tests\LocalWebTestCase;
/**
* Class DisplayGroupLayoutAssignTest
* @package Xibo\Tests\integration\Cache
*/
class DisplayGroupLayoutAssignTest extends LocalWebTestCase
{
use LayoutHelperTrait;
use DisplayHelperTrait;
/** @var XiboLayout */
protected $layout;
/** @var XiboDisplay */
protected $display;
// <editor-fold desc="Init">
public function setup()
{
parent::setup();
$this->getLogger()->debug('Setup test for Cache ' . get_class($this) .' Test');
// Create a Layout
$this->layout = $this->createLayout();
// Checkout
$layout = $this->getDraft($this->layout);
// Add a simple widget
$this->addSimpleWidget($layout);
// Check us in again
$this->layout = $this->publish($this->layout);
// Build the layout
$this->buildLayout($this->layout);
// Create a Display
$this->display = $this->createDisplay();
$this->displaySetStatus($this->display, Display::$STATUS_DONE);
$this->displaySetLicensed($this->display);
$this->getLogger()->debug('Finished Setup');
}
public function tearDown()
{
$this->getLogger()->debug('Tear Down');
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()
{
// Make sure our Display is already DONE
$this->assertTrue($this->displayStatusEquals($this->display, Display::$STATUS_DONE), 'Display Status isnt as expected');
// Add the Layout we have prepared to the Display Group
$response = $this->sendRequest('POST','/displaygroup/' . $this->display->displayGroupId . '/layout/assign', [
'layoutId' => [$this->layout->layoutId]
]);
$object = json_decode($response->getBody());
$this->assertSame(204, $object->status);
// Validate the display status afterwards
$this->assertTrue($this->displayStatusEquals($this->display, Display::$STATUS_PENDING), 'Display Status isnt as expected');
// Validate that XMR has been called.
$this->assertFalse(in_array($this->display->displayId, $this->getPlayerActionQueue()), 'Player action not present');
}
}

View File

@@ -0,0 +1,120 @@
<?php
/*
* Copyright (C) 2025 Xibo Signage Ltd
*
* Xibo - Digital Signage - https://xibosignage.com
*
* 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 Xibo\Entity\Display;
use Xibo\OAuth2\Client\Entity\XiboDisplay;
use Xibo\OAuth2\Client\Entity\XiboLayout;
use Xibo\Tests\Helper\DisplayHelperTrait;
use Xibo\Tests\Helper\LayoutHelperTrait;
use Xibo\Tests\LocalWebTestCase;
/**
* Class DisplayGroupLayoutUnssignTest
* @package Xibo\Tests\integration\Cache
*/
class DisplayGroupLayoutUnssignTest extends LocalWebTestCase
{
use LayoutHelperTrait;
use DisplayHelperTrait;
/** @var XiboLayout */
protected $layout;
/** @var XiboDisplay */
protected $display;
// <editor-fold desc="Init">
public function setup()
{
parent::setup();
$this->getLogger()->debug('Setup test for Cache ' . get_class($this) .' Test');
// Create a Layout
$this->layout = $this->createLayout();
// Checkout
$layout = $this->getDraft($this->layout);
// Add a simple widget
$this->addSimpleWidget($layout);
// Check us in again
$this->layout = $this->publish($this->layout);
// Build the layout
$this->buildLayout($this->layout);
// Create a Display
$this->display = $this->createDisplay();
// Assign the Layout to the Display
$this->getEntityProvider()->post('/displaygroup/' . $this->display->displayGroupId . '/layout/assign', [
'layoutId' => [$this->layout->layoutId]
]);
$this->displaySetStatus($this->display, Display::$STATUS_DONE);
$this->displaySetLicensed($this->display);
$this->getLogger()->debug('Finished Setup');
}
public function tearDown()
{
$this->getLogger()->debug('Tear Down');
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()
{
// Make sure our Display is already DONE
$this->assertTrue($this->displayStatusEquals($this->display, Display::$STATUS_DONE), 'Display Status isnt as expected');
// Add the Layout we have prepared to the Display Group
$response = $this->sendRequest('POST','/displaygroup/' . $this->display->displayGroupId . '/layout/unassign', [
'layoutId' => [$this->layout->layoutId]
]);
$object = json_decode($response->getBody());
$this->assertSame(204, $object->status);
// Validate the display status afterwards
$this->assertTrue($this->displayStatusEquals($this->display, Display::$STATUS_PENDING), 'Display Status isnt as expected');
// Validate that XMR has been called.
$this->assertFalse(in_array($this->display->displayId, $this->getPlayerActionQueue()), 'Player action not present');
}
}

View File

@@ -0,0 +1,102 @@
<?php
/*
* Copyright (C) 2025 Xibo Signage Ltd
*
* Xibo - Digital Signage - https://xibosignage.com
*
* 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 Xibo\Entity\Display;
use Xibo\Helper\Random;
use Xibo\OAuth2\Client\Entity\XiboDisplay;
use Xibo\OAuth2\Client\Entity\XiboLibrary;
use Xibo\Tests\Helper\DisplayHelperTrait;
use Xibo\Tests\Helper\LayoutHelperTrait;
use Xibo\Tests\LocalWebTestCase;
/**
* Class DisplayGroupMediaAssignTest
* @package Xibo\Tests\integration\Cache
*/
class DisplayGroupMediaAssignTest extends LocalWebTestCase
{
use LayoutHelperTrait;
use DisplayHelperTrait;
/** @var XiboLibrary */
protected $media;
/** @var XiboDisplay */
protected $display;
// <editor-fold desc="Init">
public function setup()
{
parent::setup();
$this->getLogger()->debug('Setup test for Cache ' . get_class($this) .' Test');
// Add a media item
$this->media = (new XiboLibrary($this->getEntityProvider()))
->create(Random::generateString(), PROJECT_ROOT . '/tests/resources/HLH264.mp4');
// Create a Display
$this->display = $this->createDisplay();
$this->displaySetStatus($this->display, Display::$STATUS_DONE);
$this->displaySetLicensed($this->display);
$this->getLogger()->debug('Finished Setup');
}
public function tearDown()
{
$this->getLogger()->debug('Tear Down');
parent::tearDown();
// Delete the Layout we've been working with
$this->media->deleteAssigned();
// Delete the Display
$this->deleteDisplay($this->display);
}
// </editor-fold>
/**
* @group cacheInvalidateTests
*/
public function testInvalidateCache()
{
// Make sure our Display is already DONE
$this->assertTrue($this->displayStatusEquals($this->display, Display::$STATUS_DONE), 'Display Status isnt as expected');
// Add the Layout we have prepared to the Display Group
$this->sendRequest('POST','/displaygroup/' . $this->display->displayGroupId . '/media/assign', [
'mediaId' => [$this->media->mediaId]
]);
// Validate the display status afterwards
$this->assertTrue($this->displayStatusEquals($this->display, Display::$STATUS_PENDING), 'Display Status isnt as expected');
// Validate that XMR has been called.
$this->assertFalse(in_array($this->display->displayId, $this->getPlayerActionQueue()), 'Player action not present');
}
}

View File

@@ -0,0 +1,107 @@
<?php
/*
* Copyright (C) 2025 Xibo Signage Ltd
*
* Xibo - Digital Signage - https://xibosignage.com
*
* 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 Xibo\Entity\Display;
use Xibo\Helper\Random;
use Xibo\OAuth2\Client\Entity\XiboDisplay;
use Xibo\OAuth2\Client\Entity\XiboLibrary;
use Xibo\Tests\Helper\DisplayHelperTrait;
use Xibo\Tests\Helper\LayoutHelperTrait;
use Xibo\Tests\LocalWebTestCase;
/**
* Class DisplayGroupMediaUnassignTest
* @package Xibo\Tests\integration\Cache
*/
class DisplayGroupMediaUnassignTest extends LocalWebTestCase
{
use LayoutHelperTrait;
use DisplayHelperTrait;
/** @var XiboLibrary */
protected $media;
/** @var XiboDisplay */
protected $display;
// <editor-fold desc="Init">
public function setup()
{
parent::setup();
$this->getLogger()->debug('Setup test for Cache ' . get_class($this) .' Test');
// Add a media item
$this->media = (new XiboLibrary($this->getEntityProvider()))
->create(Random::generateString(), PROJECT_ROOT . '/tests/resources/HLH264.mp4');
// Create a Display
$this->display = $this->createDisplay();
// Assign the mediaId to the display
$this->getEntityProvider()->post('/displaygroup/' . $this->display->displayGroupId . '/media/assign', [
'mediaId' => [$this->media->mediaId]
]);
$this->displaySetStatus($this->display, Display::$STATUS_DONE);
$this->displaySetLicensed($this->display);
$this->getLogger()->debug('Finished Setup');
}
public function tearDown()
{
$this->getLogger()->debug('Tear Down');
parent::tearDown();
// Delete the Layout we've been working with
$this->media->deleteAssigned();
// Delete the Display
$this->deleteDisplay($this->display);
}
// </editor-fold>
/**
* @group cacheInvalidateTests
*/
public function testInvalidateCache()
{
// Make sure our Display is already DONE
$this->assertTrue($this->displayStatusEquals($this->display, Display::$STATUS_DONE), 'Display Status isnt as expected');
// Add the Layout we have prepared to the Display Group
$this->sendRequest('POST','/displaygroup/' . $this->display->displayGroupId . '/media/unassign', [
'mediaId' => [$this->media->mediaId]
]);
// Validate the display status afterwards
$this->assertTrue($this->displayStatusEquals($this->display, Display::$STATUS_PENDING), 'Display Status isnt as expected');
// Validate that XMR has been called.
$this->assertFalse(in_array($this->display->displayId, $this->getPlayerActionQueue()), 'Player action not present');
}
}

View File

@@ -0,0 +1,167 @@
<?php
/*
* Copyright (C) 2025 Xibo Signage Ltd
*
* Xibo - Digital Signage - https://xibosignage.com
*
* 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\XiboRegion;
use Xibo\OAuth2\Client\Entity\XiboSchedule;
use Xibo\OAuth2\Client\Entity\XiboTicker;
use Xibo\Tests\Helper\DisplayHelperTrait;
use Xibo\Tests\Helper\LayoutHelperTrait;
use Xibo\Tests\LocalWebTestCase;
/**
* Class GetResourceTest
* @package Xibo\Tests\integration\Cache
*/
class GetResourceTest extends LocalWebTestCase
{
use LayoutHelperTrait;
use DisplayHelperTrait;
/** @var XiboLayout */
protected $layout;
/** @var XiboRegion */
protected $region;
/** @var XiboDisplay */
protected $display;
/** @var XiboTicker */
protected $widget;
// <editor-fold desc="Init">
public function setup()
{
parent::setup();
$this->getLogger()->debug('Setup test for Cache ' . get_class($this) .' Test');
// Create a Layout
$this->layout = $this->createLayout();
// Checkout
$layout = $this->getDraft($this->layout);
// Add a resource heavy module to the Layout (one that will download images)
$response = $this->getEntityProvider()->post('/playlist/widget/ticker/' . $layout->regions[0]->regionPlaylist->playlistId);
$response = $this->getEntityProvider()->put('/playlist/widget/' . $response['widgetId'], [
'uri' => 'http://ceu.xibo.co.uk/mediarss/feed.xml',
'duration' => 100,
'useDuration' => 1,
'sourceId' => 1,
'templateId' => 'media-rss-with-title'
]);
// Edit the Ticker to add the template
$this->widget = (new XiboTicker($this->getEntityProvider()))->hydrate($response);
// Checkin
$this->layout = $this->publish($this->layout);
// Set the Layout status
$this->setLayoutStatus($this->layout, 3);
// Build the Layout
$this->buildLayout($this->layout);
// 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);
$this->displaySetLicensed($this->display);
$this->getLogger()->debug('Finished Setup');
}
public function tearDown()
{
$this->getLogger()->debug('Tear Down');
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()
{
// Make sure our Layout is already status 1
$this->assertTrue($this->layoutStatusEquals($this->layout, 1), 'Layout Status isnt as expected');
// Make sure our Display is already DONE
$this->assertTrue($this->displayStatusEquals($this->display, Display::$STATUS_DONE), 'Display Status isnt as expected');
// Confirm our Layout is in the Schedule
$schedule = $this->getXmdsWrapper()->Schedule($this->display->license);
$this->assertContains('file="' . $this->layout->layoutId . '"', $schedule, 'Layout not scheduled');
// Call Required Files
$rf = $this->getXmdsWrapper()->RequiredFiles($this->display->license);
$this->assertContains('layoutid="' . $this->layout->layoutId . '"', $rf, 'Layout not in Required Files');
// Call Get Resource
$this->getLogger()->debug('Calling GetResource - for ' . $this->layout->layoutId . ' - ' . $this->layout->regions[0]->regionId . ' - ' . $this->widget->widgetId);
$this->getXmdsWrapper()->GetResource($this->display->license, $this->layout->layoutId, $this->layout->regions[0]->regionId, $this->widget->widgetId);
// 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');
}
}

View File

@@ -0,0 +1,151 @@
<?php
/*
* Copyright (C) 2025 Xibo Signage Ltd
*
* Xibo - Digital Signage - https://xibosignage.com
*
* 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\XiboRegion;
use Xibo\OAuth2\Client\Entity\XiboSchedule;
use Xibo\OAuth2\Client\Entity\XiboText;
use Xibo\OAuth2\Client\Entity\XiboTicker;
use Xibo\Tests\Helper\DisplayHelperTrait;
use Xibo\Tests\Helper\LayoutHelperTrait;
use Xibo\Tests\LocalWebTestCase;
/**
* Class LayoutBuildTest
* @package Xibo\Tests\integration\Cache
*/
class LayoutBuildTest extends LocalWebTestCase
{
use LayoutHelperTrait;
use DisplayHelperTrait;
/** @var XiboLayout */
protected $layout;
/** @var XiboRegion */
protected $region;
/** @var XiboDisplay */
protected $display;
/** @var XiboTicker */
protected $widget;
// <editor-fold desc="Init">
public function setup()
{
parent::setup();
$this->getLogger()->debug('Setup test for Cache ' . get_class($this) .' Test');
// Create a Layout
$this->layout = $this->createLayout();
// Checkout
$layout = $this->getDraft($this->layout);
$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->widget = (new XiboText($this->getEntityProvider()))->hydrate($response);
// 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);
$this->displaySetLicensed($this->display);
$this->getLogger()->debug('Finished Setup');
}
public function tearDown()
{
$this->getLogger()->debug('Tear Down');
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()
{
// Make sure our Layout is already status 1
$this->assertTrue($this->layoutStatusEquals($this->layout, 3), 'Pre-Layout Status isnt as expected');
// Make sure our Display is already DONE
$this->assertTrue($this->displayStatusEquals($this->display, Display::$STATUS_DONE), 'Pre-Display Status isnt as expected');
// Publish (which builds)
$response = $this->sendRequest('PUT','/layout/publish/' . $this->layout->layoutId, [
'publishNow' => 1
], ['CONTENT_TYPE' => 'application/x-www-form-urlencoded']);
$object = json_decode($response->getBody(), true);
$this->layout = $this->constructLayoutFromResponse($object['data']);
// 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');
// Validate that XMR has been called.
$this->assertTrue(in_array($this->display->displayId, $this->getPlayerActionQueue()), 'Player action not present');
}
}

View File

@@ -0,0 +1,99 @@
<?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 Xibo\Entity\Display;
use Xibo\OAuth2\Client\Entity\XiboDisplay;
use Xibo\OAuth2\Client\Entity\XiboLayout;
use Xibo\Tests\Helper\DisplayHelperTrait;
use Xibo\Tests\Helper\LayoutHelperTrait;
use Xibo\Tests\LocalWebTestCase;
/**
* Class LayoutChangeActionTest
*
* Tests whether a Layout Edit updates the Cache Appropriately
*
* @package integration\Cache
*/
class LayoutChangeActionTest extends LocalWebTestCase
{
use LayoutHelperTrait;
use DisplayHelperTrait;
/** @var XiboLayout */
protected $layout;
/** @var XiboDisplay */
protected $display;
// <editor-fold desc="Init">
public function setup()
{
parent::setup();
$this->getLogger()->debug('Setup test for Cache Layout Edit Test');
// Create a Layout
$this->layout = $this->createLayout(1);
// Create a Display
$this->display = $this->createDisplay();
$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()
{
// Make sure we're in good condition to start
$this->assertTrue($this->displayStatusEquals($this->display, Display::$STATUS_DONE), 'Display Status isnt as expected');
// Edit the Layout
$this->sendRequest('POST','/displaygroup/' . $this->display->displayGroupId . '/action/changeLayout', [
'layoutId' => $this->layout->layoutId
]);
// Validate the display status afterwards
$this->assertTrue($this->displayStatusEquals($this->display, Display::$STATUS_PENDING), 'Display Status isnt as expected');
// Somehow test that we have issued an XMR request
$this->assertTrue(in_array($this->display->displayId, $this->getPlayerActionQueue()), 'Player action not present');
}
}

View File

@@ -0,0 +1,121 @@
<?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\Exception\XiboApiException;
use Xibo\Tests\Helper\DisplayHelperTrait;
use Xibo\Tests\Helper\LayoutHelperTrait;
use Xibo\Tests\LocalWebTestCase;
/**
* Class LayoutDeleteTest
* @package Xibo\Tests\integration\Cache
*/
class LayoutDeleteTest extends LocalWebTestCase
{
use LayoutHelperTrait;
use DisplayHelperTrait;
/** @var XiboLayout */
protected $layout;
/** @var XiboDisplay */
protected $display;
// <editor-fold desc="Init">
public function setup()
{
parent::setup();
$this->getLogger()->debug('Setup test for Cache Layout Edit Test');
// Create a Layout
$this->layout = $this->createLayout(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
if ($this->layout !== null)
$this->deleteLayout($this->layout);
// Delete the Display
$this->deleteDisplay($this->display);
}
// </editor-fold>
/**
* @group cacheInvalidateTests
*/
public function testInvalidateCache()
{
// Delete the Layout we've got created for us.
$this->sendRequest('DELETE','/layout/' . $this->layout->layoutId);
// Check its deleted
try {
$this->layoutStatusEquals($this->layout, 0);
} catch (XiboApiException $xiboApiException) {
$this->assertEquals(404, $xiboApiException->getCode(), 'Expecting a 404, got ' . $xiboApiException->getCode());
}
$this->layout = null;
// Validate the display status afterwards
$this->assertTrue($this->displayStatusEquals($this->display, Display::$STATUS_PENDING), 'Display Status isnt as expected');
// Somehow test that we have issued an XMR request
$this->assertTrue(in_array($this->display->displayId, $this->getPlayerActionQueue()), 'Player action not present');
}
}

View File

@@ -0,0 +1,145 @@
<?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\Tests\Helper\DisplayHelperTrait;
use Xibo\Tests\Helper\LayoutHelperTrait;
use Xibo\Tests\LocalWebTestCase;
/**
* Class LayoutEditTest
*
* Tests whether a Layout Edit updates the Cache Appropriately
*
* @package integration\Cache
*/
class LayoutEditTest extends LocalWebTestCase
{
use LayoutHelperTrait;
use DisplayHelperTrait;
/** @var XiboLayout */
protected $layout;
/** @var XiboDisplay */
protected $display;
// <editor-fold desc="Init">
public function setup()
{
parent::setup();
$this->getLogger()->debug('Setup test for Cache Layout Edit Test');
// Create a Layout
$this->layout = $this->createLayout(1);
// We need to add a widget to it, so that the Layout tests out as valid
$layout = $this->getDraft($this->layout);
$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->layout = $this->publish($this->layout);
// 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()
{
// Make sure we're in good condition to start
$this->assertTrue($this->displayStatusEquals($this->display, Display::$STATUS_DONE), 'Display Status isnt as expected');
// Checkout this Layout
$layout = $this->checkout($this->layout);
// Validate the display status after we've checked out
$this->assertTrue($this->displayStatusEquals($this->display, Display::$STATUS_DONE), 'Display Status isnt as expected after checkout');
// Edit the Layout
$response = $this->sendRequest('PUT','/layout/background/' . $layout->layoutId, [
'backgroundColor' => $layout->backgroundColor,
'backgroundzIndex' => $layout->backgroundzIndex
], ['CONTENT_TYPE' => 'application/x-www-form-urlencoded']);
$this->assertEquals(200, $response->getStatusCode(), 'Transaction Status Incorrect');
// Check in the Layout
$this->layout = $this->publish($this->layout);
// Validate the layout status afterwards (publish builds the layout)
$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 after publish');
// Somehow test that we have issued an XMR request
$this->assertFalse(in_array($this->display->displayId, $this->getPlayerActionQueue()), 'Player action not present');
}
}

View File

@@ -0,0 +1,168 @@
<?php
/*
* Copyright (C) 2025 Xibo Signage Ltd
*
* Xibo - Digital Signage - https://xibosignage.com
*
* 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\Helper\Random;
use Xibo\OAuth2\Client\Entity\XiboCampaign;
use Xibo\OAuth2\Client\Entity\XiboDisplay;
use Xibo\OAuth2\Client\Entity\XiboLayout;
use Xibo\OAuth2\Client\Entity\XiboRegion;
use Xibo\OAuth2\Client\Entity\XiboSchedule;
use Xibo\OAuth2\Client\Entity\XiboText;
use Xibo\OAuth2\Client\Entity\XiboTicker;
use Xibo\Tests\Helper\DisplayHelperTrait;
use Xibo\Tests\Helper\LayoutHelperTrait;
use Xibo\Tests\LocalWebTestCase;
/**
* Class LayoutInCampaignStatusTest
* @package Xibo\Tests\integration\Cache
*/
class LayoutInCampaignStatusTest extends LocalWebTestCase
{
use LayoutHelperTrait;
use DisplayHelperTrait;
/** @var XiboCampaign */
protected $campaign;
/** @var XiboLayout */
protected $layout;
/** @var XiboRegion */
protected $region;
/** @var XiboDisplay */
protected $display;
/** @var XiboTicker */
protected $widget;
// <editor-fold desc="Init">
public function setup()
{
parent::setup();
$this->getLogger()->debug('Setup test for Cache ' . get_class($this) .' Test');
// Create a Campaign
$this->campaign = (new XiboCampaign($this->getEntityProvider()))->create(Random::generateString());
// Create a Layout
$this->layout = $this->createLayout();
// Checkout
$layout = $this->getDraft($this->layout);
$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->widget = (new XiboText($this->getEntityProvider()))->hydrate($response);
// Assign the layout to our campaign
$this->getEntityProvider()->post('/campaign/layout/assign/' . $this->campaign->campaignId, [
'layoutId' => $this->layout->layoutId
]);
// Create a Display
$this->display = $this->createDisplay();
// Schedule the Campaign "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->campaign->campaignId,
[$this->display->displayGroupId],
0,
NULL,
NULL,
NULL,
0,
0,
0
);
$this->displaySetStatus($this->display, Display::$STATUS_DONE);
$this->displaySetLicensed($this->display);
$this->getLogger()->debug('Finished Setup');
}
public function tearDown()
{
$this->getLogger()->debug('Tear Down');
parent::tearDown();
// Delete the Layout we've been working with
$this->deleteLayout($this->layout);
// Delete the Display
$this->deleteDisplay($this->display);
// Delete the Campaign
$this->campaign->delete();
}
// </editor-fold>
/**
* @group cacheInvalidateTests
*/
public function testInvalidateCache()
{
// Make sure our Layout is already status 1
$this->assertTrue($this->layoutStatusEquals($this->layout, 3), 'Pre-Layout Status isnt as expected');
// Make sure our Display is already DONE
$this->assertTrue($this->displayStatusEquals($this->display, Display::$STATUS_DONE), 'Pre-Display Status isnt as expected');
// Publish (which builds)
$response = $this->sendRequest('PUT','/layout/publish/' . $this->layout->layoutId, [
'publishNow' => 1
], ['CONTENT_TYPE' => 'application/x-www-form-urlencoded']);
$this->assertSame(200, $response->getStatusCode(), "Not successful: " . $response->getStatusCode() . $response->getBody()->getContents());
$response = json_decode($response->getBody(), true);
$this->layout = $this->constructLayoutFromResponse($response['data']);
// 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');
// Validate that XMR has been called.
$this->assertTrue(in_array($this->display->displayId, $this->getPlayerActionQueue()), 'Player action not present');
}
}

View File

@@ -0,0 +1,99 @@
<?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 Xibo\Entity\Display;
use Xibo\OAuth2\Client\Entity\XiboDisplay;
use Xibo\OAuth2\Client\Entity\XiboLayout;
use Xibo\Tests\Helper\DisplayHelperTrait;
use Xibo\Tests\Helper\LayoutHelperTrait;
use Xibo\Tests\LocalWebTestCase;
/**
* Class LayoutOverlayActionTest
*
* Tests whether a Layout Edit updates the Cache Appropriately
*
* @package integration\Cache
*/
class LayoutOverlayActionTest extends LocalWebTestCase
{
use LayoutHelperTrait;
use DisplayHelperTrait;
/** @var XiboLayout */
protected $layout;
/** @var XiboDisplay */
protected $display;
// <editor-fold desc="Init">
public function setup()
{
parent::setup();
$this->getLogger()->debug('Setup test for Cache Layout Edit Test');
// Create a Layout
$this->layout = $this->createLayout(1);
// Create a Display
$this->display = $this->createDisplay();
$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()
{
// Make sure we're in good condition to start
$this->assertTrue($this->displayStatusEquals($this->display, Display::$STATUS_DONE), 'Display Status isnt as expected');
// Edit the Layout
$this->sendRequest('POST','/displaygroup/' . $this->display->displayGroupId . '/action/overlayLayout', [
'layoutId' => $this->layout->layoutId
]);
// Validate the display status afterwards
$this->assertTrue($this->displayStatusEquals($this->display, Display::$STATUS_PENDING), 'Display Status isnt as expected');
// Somehow test that we have issued an XMR request
$this->assertTrue(in_array($this->display->displayId, $this->getPlayerActionQueue()), 'Player action not present');
}
}

View File

@@ -0,0 +1,272 @@
<?php
/*
* Copyright (C) 2025 Xibo Signage Ltd
*
* Xibo - Digital Signage - https://xibosignage.com
*
* 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\Helper\Random;
use Xibo\OAuth2\Client\Entity\XiboDisplay;
use Xibo\OAuth2\Client\Entity\XiboLayout;
use Xibo\OAuth2\Client\Entity\XiboLibrary;
use Xibo\OAuth2\Client\Entity\XiboPlaylist;
use Xibo\OAuth2\Client\Entity\XiboRegion;
use Xibo\OAuth2\Client\Entity\XiboSchedule;
use Xibo\OAuth2\Client\Entity\XiboTicker;
use Xibo\Tests\Helper\DisplayHelperTrait;
use Xibo\Tests\Helper\LayoutHelperTrait;
use Xibo\Tests\LocalWebTestCase;
/**
* Class LayoutProofOfPlayXMLMediaInheritWidgetInheritTest
* @package Xibo\Tests\integration\Cache
*/
class LayoutProofOfPlayXMLMediaInheritWidgetInheritTest extends LocalWebTestCase
{
use LayoutHelperTrait;
use DisplayHelperTrait;
/** @var XiboLayout */
protected $layoutOff;
/** @var XiboLayout */
protected $layoutOn;
/** @var XiboRegion */
protected $region;
/** @var XiboDisplay */
protected $display;
/** @var XiboDisplay */
protected $display2;
/** @var XiboTicker */
protected $widget;
/** @var XiboLibrary */
protected $media;
protected $widgetId;
protected $widgetId2;
// <editor-fold desc="Init">
public function setup()
{
parent::setup();
$this->getLogger()->debug('Setup test for ' . get_class($this) .' Test');
// Create a Layout with enableStat Off (by default)
$this->layoutOff = $this->createLayout();
$layoutOff = $this->getDraft($this->layoutOff);
// Upload some media - enableStat is Inherit (from global media stat setting)
$this->media = (new XiboLibrary($this->getEntityProvider()))->create(
Random::generateString(8, 'API Video'),
PROJECT_ROOT . '/tests/resources/HLH264.mp4'
);
// Assign the media we've created to our regions playlist- widget with Inherit (from global widget stat setting)
$playlist = (new XiboPlaylist($this->getEntityProvider()))
->assign([$this->media->mediaId], 10, $layoutOff->regions[0]->regionPlaylist->playlistId);
// Store the widgetId
$this->widgetId = $playlist->widgets[0]->widgetId;
// 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()->addSeconds(3600)->format(DateFormatHelper::getSystemFormat()),
Carbon::now()->addSeconds(7200)->format(DateFormatHelper::getSystemFormat()),
$this->layoutOff->campaignId,
[$this->display->displayGroupId],
0,
NULL,
NULL,
NULL,
0,
0,
0
);
$this->displaySetStatus($this->display, Display::$STATUS_DONE);
$this->displaySetLicensed($this->display);
// Create a layout with enableStat On
$this->layoutOn = (new XiboLayout($this->getEntityProvider()))->create(
Random::generateString(8, 'phpunit'),
'phpunit description',
'',
$this->getResolutionId('landscape'),
1
);
$layoutOn = $this->getDraft($this->layoutOn);
// Assign the media we've created to our regions playlist- widget with Inherit (from global widget stat setting)
$playlist2 = (new XiboPlaylist($this->getEntityProvider()))
->assign([$this->media->mediaId], 10, $layoutOn->regions[0]->regionPlaylist->playlistId);
// Store the widgetId
$this->widgetId2 = $playlist2->widgets[0]->widgetId;
// Create a Display2
$this->display2 = $this->createDisplay();
// Schedule the LayoutOn "always" onto our display
// deleting the layoutOn will remove this at the end
$event2 = (new XiboSchedule($this->getEntityProvider()))->createEventLayout(
Carbon::now()->addSeconds(3600)->format(DateFormatHelper::getSystemFormat()),
Carbon::now()->addSeconds(7200)->format(DateFormatHelper::getSystemFormat()),
$this->layoutOn->campaignId,
[$this->display2->displayGroupId],
0,
NULL,
NULL,
NULL,
0,
0,
0
);
$this->displaySetStatus($this->display2, Display::$STATUS_DONE);
$this->displaySetLicensed($this->display2);
$this->getLogger()->debug('Finished Setup');
}
public function tearDown()
{
$this->getLogger()->debug('Tear Down');
// Delete the LayoutOff
$this->deleteLayout($this->layoutOff);
// Delete the Display
$this->deleteDisplay($this->display);
// Delete the LayoutOn
$this->deleteLayout($this->layoutOn);
// Delete the Display2
$this->deleteDisplay($this->display2);
// Delete the media record
$this->media->deleteAssigned();
parent::tearDown();
}
// </editor-fold>
// Logic Table
//
// Widget With Media
// LAYOUT MEDIA WIDGET Media stats collected?
// ON ON ON YES Widget takes precedence // Match - 1
// ON OFF ON YES Widget takes precedence // Match - 1
// ON INHERIT ON YES Widget takes precedence // Match - 1
//
// OFF ON ON YES Widget takes precedence // Match - 1
// OFF OFF ON YES Widget takes precedence // Match - 1
// OFF INHERIT ON YES Widget takes precedence // Match - 1
//
// ON ON OFF NO Widget takes precedence // Match - 2
// ON OFF OFF NO Widget takes precedence // Match - 2
// ON INHERIT OFF NO Widget takes precedence // Match - 2
//
// OFF ON OFF NO Widget takes precedence // Match - 2
// OFF OFF OFF NO Widget takes precedence // Match - 2
// OFF INHERIT OFF NO Widget takes precedence // Match - 2
//
// ON ON INHERIT YES Media takes precedence // Match - 3
// ON OFF INHERIT NO Media takes precedence // Match - 4
// ON INHERIT INHERIT YES Media takes precedence and Inherited from Layout // Match - 5
//
// OFF ON INHERIT YES Media takes precedence // Match - 3
// OFF OFF INHERIT NO Media takes precedence // Match - 4
// OFF INHERIT INHERIT NO Media takes precedence and Inherited from Layout // Match - 6
////
public function testLayoutOff()
{
// Publish layout
$response = $this->sendRequest('PUT','/layout/publish/' . $this->layoutOff->layoutId, [
'publishNow' => 1
], ['CONTENT_TYPE' => 'application/x-www-form-urlencoded']);
$response = json_decode($response->getBody(), true);
$this->layoutOff = $this->constructLayoutFromResponse($response['data']);
// Confirm our Layout is in the Schedule
$schedule = $this->getXmdsWrapper()->Schedule($this->display->license);
$this->assertContains('file="' . $this->layoutOff->layoutId . '"', $schedule, 'Layout not scheduled');
// Call Required Files
$rf = $this->getXmdsWrapper()->RequiredFiles($this->display->license);
// Get XML string for player
$xmlString = $this->getXmdsWrapper()->GetFile($this->display->license, $this->layoutOff->layoutId, 'layout', 0, 0);
// Layout enable stat 0
$this->assertContains('<layout width="1920" height="1080" bgcolor="#000" schemaVersion="3" enableStat="0">', $xmlString );
// Layout Off, Media Inherit, Widget Inherit, Output => [0, 'Inherit', 'Inherit', 0]
$this->assertContains('<media id="'.$this->widgetId.'" type="video" render="native" duration="10" useDuration="1" fromDt="1970-01-01 01:00:00" toDt="2038-01-19 03:14:07" enableStat="0" fileId="'.$this->media->mediaId.'">', $xmlString );
}
public function testLayoutOn()
{
// Publish layout
$response = $this->sendRequest('PUT','/layout/publish/' . $this->layoutOn->layoutId, [
'publishNow' => 1
], ['CONTENT_TYPE' => 'application/x-www-form-urlencoded']);
$response = json_decode($response->getBody(), true);
$this->layoutOn = $this->constructLayoutFromResponse($response['data']);
// Confirm our Layout is in the Schedule
$schedule = $this->getXmdsWrapper()->Schedule($this->display2->license);
$this->assertContains('file="' . $this->layoutOn->layoutId . '"', $schedule, 'Layout not scheduled');
// Call Required Files
$rf = $this->getXmdsWrapper()->RequiredFiles($this->display2->license);
// Get XML string for player
$xmlString = $this->getXmdsWrapper()->GetFile($this->display2->license, $this->layoutOn->layoutId, 'layout', 0, 0);
// Layout enable stat 1
$this->assertContains('<layout width="1920" height="1080" bgcolor="#000" schemaVersion="3" enableStat="1">', $xmlString );
// Layout On, Media Inherit, Widget Inherit, Output => [1, 'Inherit', 'Inherit', 1]
$this->assertContains('<media id="'.$this->widgetId2.'" type="video" render="native" duration="10" useDuration="1" fromDt="1970-01-01 01:00:00" toDt="2038-01-19 03:14:07" enableStat="1" fileId="'.$this->media->mediaId.'">', $xmlString );
}
}

View File

@@ -0,0 +1,282 @@
<?php
/*
* Copyright (C) 2025 Xibo Signage Ltd
*
* Xibo - Digital Signage - https://xibosignage.com
*
* 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\Helper\Random;
use Xibo\OAuth2\Client\Entity\XiboDisplay;
use Xibo\OAuth2\Client\Entity\XiboLayout;
use Xibo\OAuth2\Client\Entity\XiboLibrary;
use Xibo\OAuth2\Client\Entity\XiboPlaylist;
use Xibo\OAuth2\Client\Entity\XiboRegion;
use Xibo\OAuth2\Client\Entity\XiboSchedule;
use Xibo\OAuth2\Client\Entity\XiboTicker;
use Xibo\Tests\Helper\DisplayHelperTrait;
use Xibo\Tests\Helper\LayoutHelperTrait;
use Xibo\Tests\LocalWebTestCase;
/**
* Class LayoutProofOfPlayXMLMediaInheritWidgetOffTest
* @package Xibo\Tests\integration\Cache
*/
class LayoutProofOfPlayXMLMediaInheritWidgetOffTest extends LocalWebTestCase
{
use LayoutHelperTrait;
use DisplayHelperTrait;
/** @var XiboLayout */
protected $layoutOff;
/** @var XiboLayout */
protected $layoutOn;
/** @var XiboRegion */
protected $region;
/** @var XiboDisplay */
protected $display;
/** @var XiboDisplay */
protected $display2;
/** @var XiboTicker */
protected $widget;
/** @var XiboLibrary */
protected $media;
/** @var XiboLibrary */
protected $mediaOn;
protected $widgetId;
protected $widgetId2;
// <editor-fold desc="Init">
public function setup()
{
parent::setup();
$this->getLogger()->debug('Setup test for ' . get_class($this) .' Test');
// Set global widget enable stat set to Off
self::$container->get('configService')->changeSetting('WIDGET_STATS_ENABLED_DEFAULT', 'Off');
$this->getStore()->commitIfNecessary();
// Create a Layout with enableStat Off (by default)
$this->layoutOff = $this->createLayout();
$layoutOff = $this->getDraft($this->layoutOff);
// Upload some media - enableStat is Inherit (from global media stat setting)
$this->media = (new XiboLibrary($this->getEntityProvider()))->create(
Random::generateString(8, 'API Video'),
PROJECT_ROOT . '/tests/resources/HLH264.mp4'
);
// Assign the media we've edited to our regions playlist- widget with Inherit (from global widget stat setting)
$playlist = (new XiboPlaylist($this->getEntityProvider()))
->assign([$this->media->mediaId], 10, $layoutOff->regions[0]->regionPlaylist->playlistId);
// Store the widgetId
$this->widgetId = $playlist->widgets[0]->widgetId;
// 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()->addSeconds(3600)->format(DateFormatHelper::getSystemFormat()),
Carbon::now()->addSeconds(7200)->format(DateFormatHelper::getSystemFormat()),
$this->layoutOff->campaignId,
[$this->display->displayGroupId],
0,
NULL,
NULL,
NULL,
0,
0,
0
);
$this->displaySetStatus($this->display, Display::$STATUS_DONE);
$this->displaySetLicensed($this->display);
// Create a layout with enableStat On
$this->layoutOn = (new XiboLayout($this->getEntityProvider()))->create(
Random::generateString(8, 'phpunit'),
'phpunit description',
'',
$this->getResolutionId('landscape'),
1
);
$layoutOn = $this->getDraft($this->layoutOn);
// Assign the media we've created to our regions playlist- widget with Inherit (from global widget stat setting)
$playlist2 = (new XiboPlaylist($this->getEntityProvider()))
->assign([$this->media->mediaId], 10, $layoutOn->regions[0]->regionPlaylist->playlistId);
// Store the widgetId
$this->widgetId2 = $playlist2->widgets[0]->widgetId;
// Create a Display2
$this->display2 = $this->createDisplay();
// Schedule the LayoutOn "always" onto our display
// deleting the layoutOn will remove this at the end
$event2 = (new XiboSchedule($this->getEntityProvider()))->createEventLayout(
Carbon::now()->addSeconds(3600)->format(DateFormatHelper::getSystemFormat()),
Carbon::now()->addSeconds(7200)->format(DateFormatHelper::getSystemFormat()),
$this->layoutOn->campaignId,
[$this->display2->displayGroupId],
0,
NULL,
NULL,
NULL,
0,
0,
0
);
$this->displaySetStatus($this->display2, Display::$STATUS_DONE);
$this->displaySetLicensed($this->display2);
$this->getLogger()->debug('Finished Setup');
}
public function tearDown()
{
$this->getLogger()->debug('Tear Down');
// Delete the LayoutOn
$this->deleteLayout($this->layoutOff);
// Delete the Display2
$this->deleteDisplay($this->display);
// Delete the LayoutOn
$this->deleteLayout($this->layoutOn);
// Delete the Display2
$this->deleteDisplay($this->display2);
// Delete the media record
$this->media->deleteAssigned();
// Set global widget enable stat set to Inherit
self::$container->get('configService')->changeSetting('WIDGET_STATS_ENABLED_DEFAULT', 'Inherit');
$this->getStore()->commitIfNecessary();
parent::tearDown();
}
// </editor-fold>
// Logic Table
//
// Widget With Media
// LAYOUT MEDIA WIDGET Media stats collected?
// ON ON ON YES Widget takes precedence // Match - 1
// ON OFF ON YES Widget takes precedence // Match - 1
// ON INHERIT ON YES Widget takes precedence // Match - 1
//
// OFF ON ON YES Widget takes precedence // Match - 1
// OFF OFF ON YES Widget takes precedence // Match - 1
// OFF INHERIT ON YES Widget takes precedence // Match - 1
//
// ON ON OFF NO Widget takes precedence // Match - 2
// ON OFF OFF NO Widget takes precedence // Match - 2
// ON INHERIT OFF NO Widget takes precedence // Match - 2
//
// OFF ON OFF NO Widget takes precedence // Match - 2
// OFF OFF OFF NO Widget takes precedence // Match - 2
// OFF INHERIT OFF NO Widget takes precedence // Match - 2
//
// ON ON INHERIT YES Media takes precedence // Match - 3
// ON OFF INHERIT NO Media takes precedence // Match - 4
// ON INHERIT INHERIT YES Media takes precedence and Inherited from Layout // Match - 5
//
// OFF ON INHERIT YES Media takes precedence // Match - 3
// OFF OFF INHERIT NO Media takes precedence // Match - 4
// OFF INHERIT INHERIT NO Media takes precedence and Inherited from Layout // Match - 6
////
public function testLayoutOff()
{
// Publish layout
$response = $this->sendRequest('PUT','/layout/publish/' . $this->layoutOff->layoutId, [
'publishNow' => 1
], ['CONTENT_TYPE' => 'application/x-www-form-urlencoded']);
$response = json_decode($response->getBody(), true);
$this->layoutOff = $this->constructLayoutFromResponse($response['data']);
// Confirm our Layout is in the Schedule
$schedule = $this->getXmdsWrapper()->Schedule($this->display->license);
$this->assertContains('file="' . $this->layoutOff->layoutId . '"', $schedule, 'Layout not scheduled');
// Call Required Files
$rf = $this->getXmdsWrapper()->RequiredFiles($this->display->license);
// Get XML string for player
$xmlString = $this->getXmdsWrapper()->GetFile($this->display->license, $this->layoutOff->layoutId, 'layout', 0, 0);
// Layout enable stat 0
$this->assertContains('<layout width="1920" height="1080" bgcolor="#000" schemaVersion="3" enableStat="0">', $xmlString );
// Layout Off, Media Inherit, Widget Off, Output => [0, 'Inherit', 'Off', 0],
$this->assertContains('<media id="'.$this->widgetId.'" type="video" render="native" duration="10" useDuration="1" fromDt="1970-01-01 01:00:00" toDt="2038-01-19 03:14:07" enableStat="0" fileId="'.$this->media->mediaId.'">', $xmlString );
}
public function testLayoutOn()
{
// Publish layout
$response = $this->sendRequest('PUT','/layout/publish/' . $this->layoutOn->layoutId, [
'publishNow' => 1
], ['CONTENT_TYPE' => 'application/x-www-form-urlencoded']);
$response = json_decode($response->getBody(), true);
$this->layoutOn = $this->constructLayoutFromResponse($response['data']);
// Confirm our Layout is in the Schedule
$schedule = $this->getXmdsWrapper()->Schedule($this->display2->license);
$this->assertContains('file="' . $this->layoutOn->layoutId . '"', $schedule, 'Layout not scheduled');
// Call Required Files
$rf = $this->getXmdsWrapper()->RequiredFiles($this->display2->license);
// Get XML string for player
$xmlString = $this->getXmdsWrapper()->GetFile($this->display2->license, $this->layoutOn->layoutId, 'layout', 0, 0);
// Layout enable stat 1
$this->assertContains('<layout width="1920" height="1080" bgcolor="#000" schemaVersion="3" enableStat="1">', $xmlString );
// Layout On, Media Inherit, Widget Off, Output => [1, 'Off', 'Off', 0],
$this->assertContains('<media id="'.$this->widgetId2.'" type="video" render="native" duration="10" useDuration="1" fromDt="1970-01-01 01:00:00" toDt="2038-01-19 03:14:07" enableStat="0" fileId="'.$this->media->mediaId.'">', $xmlString );
}
}

View File

@@ -0,0 +1,280 @@
<?php
/*
* Copyright (C) 2025 Xibo Signage Ltd
*
* Xibo - Digital Signage - https://xibosignage.com
*
* 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\Helper\Random;
use Xibo\OAuth2\Client\Entity\XiboDisplay;
use Xibo\OAuth2\Client\Entity\XiboLayout;
use Xibo\OAuth2\Client\Entity\XiboLibrary;
use Xibo\OAuth2\Client\Entity\XiboPlaylist;
use Xibo\OAuth2\Client\Entity\XiboRegion;
use Xibo\OAuth2\Client\Entity\XiboSchedule;
use Xibo\OAuth2\Client\Entity\XiboTicker;
use Xibo\Tests\Helper\DisplayHelperTrait;
use Xibo\Tests\Helper\LayoutHelperTrait;
use Xibo\Tests\LocalWebTestCase;
/**
* Class LayoutProofOfPlayXMLMediaInheritWidgetOnTest
* @package Xibo\Tests\integration\Cache
*/
class LayoutProofOfPlayXMLMediaInheritWidgetOnTest extends LocalWebTestCase
{
use LayoutHelperTrait;
use DisplayHelperTrait;
/** @var XiboLayout */
protected $layoutOff;
/** @var XiboLayout */
protected $layoutOn;
/** @var XiboRegion */
protected $region;
/** @var XiboDisplay */
protected $display;
/** @var XiboDisplay */
protected $display2;
/** @var XiboTicker */
protected $widget;
/** @var XiboLibrary */
protected $media;
/** @var XiboLibrary */
protected $mediaOn;
protected $widgetId;
protected $widgetId2;
// <editor-fold desc="Init">
public function setup()
{
parent::setup();
$this->getLogger()->debug('Setup test for ' . get_class($this) .' Test');
// Set global widget enable stat set to On
self::$container->get('configService')->changeSetting('WIDGET_STATS_ENABLED_DEFAULT', 'On');
$this->getStore()->commitIfNecessary();
// Create a Layout with enableStat Off (by default)
$this->layoutOff = $this->createLayout();
$layoutOff = $this->getDraft($this->layoutOff);
// Upload some media - enableStat is Inherit (from global media stat setting)
$this->media = (new XiboLibrary($this->getEntityProvider()))->create(
Random::generateString(8, 'API Video'),
PROJECT_ROOT . '/tests/resources/HLH264.mp4'
);
// Assign the media we've edited to our regions playlist- widget with Inherit (from global widget stat setting)
$playlist = (new XiboPlaylist($this->getEntityProvider()))
->assign([$this->media->mediaId], 10, $layoutOff->regions[0]->regionPlaylist->playlistId);
// Store the widgetId
$this->widgetId = $playlist->widgets[0]->widgetId;
// 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()->addSeconds(3600)->format(DateFormatHelper::getSystemFormat()),
Carbon::now()->addSeconds(7200)->format(DateFormatHelper::getSystemFormat()),
$this->layoutOff->campaignId,
[$this->display->displayGroupId],
0,
NULL,
NULL,
NULL,
0,
0,
0
);
$this->displaySetStatus($this->display, Display::$STATUS_DONE);
$this->displaySetLicensed($this->display);
// Create a layout with enableStat On
$this->layoutOn = (new XiboLayout($this->getEntityProvider()))->create(
Random::generateString(8, 'phpunit'),
'phpunit description',
'',
$this->getResolutionId('landscape'),
1
);
$layoutOn = $this->getDraft($this->layoutOn);
// Assign the media we've created to our regions playlist- widget with Inherit (from global widget stat setting)
$playlist2 = (new XiboPlaylist($this->getEntityProvider()))
->assign([$this->media->mediaId], 10, $layoutOn->regions[0]->regionPlaylist->playlistId);
// Store the widgetId
$this->widgetId2 = $playlist2->widgets[0]->widgetId;
// Create a Display2
$this->display2 = $this->createDisplay();
// Schedule the LayoutOn "always" onto our display
// deleting the layoutOn will remove this at the end
$event2 = (new XiboSchedule($this->getEntityProvider()))->createEventLayout(
Carbon::now()->addSeconds(3600)->format(DateFormatHelper::getSystemFormat()),
Carbon::now()->addSeconds(7200)->format(DateFormatHelper::getSystemFormat()),
$this->layoutOn->campaignId,
[$this->display2->displayGroupId],
0,
NULL,
NULL,
NULL,
0,
0,
0
);
$this->displaySetStatus($this->display2, Display::$STATUS_DONE);
$this->displaySetLicensed($this->display2);
$this->getLogger()->debug('Finished Setup');
}
public function tearDown()
{
$this->getLogger()->debug('Tear Down');
// Delete the LayoutOn
$this->deleteLayout($this->layoutOff);
// Delete the Display2
$this->deleteDisplay($this->display);
// Delete the LayoutOn
$this->deleteLayout($this->layoutOn);
// Delete the Display2
$this->deleteDisplay($this->display2);
// Delete the media record
$this->media->deleteAssigned();
// Set global widget enable stat set to Inherit
self::$container->get('configService')->changeSetting('WIDGET_STATS_ENABLED_DEFAULT', 'Inherit');
$this->getStore()->commitIfNecessary();
parent::tearDown();
}
// </editor-fold>
// Logic Table
//
// Widget With Media
// LAYOUT MEDIA WIDGET Media stats collected?
// ON ON ON YES Widget takes precedence // Match - 1
// ON OFF ON YES Widget takes precedence // Match - 1
// ON INHERIT ON YES Widget takes precedence // Match - 1
//
// OFF ON ON YES Widget takes precedence // Match - 1
// OFF OFF ON YES Widget takes precedence // Match - 1
// OFF INHERIT ON YES Widget takes precedence // Match - 1
//
// ON ON OFF NO Widget takes precedence // Match - 2
// ON OFF OFF NO Widget takes precedence // Match - 2
// ON INHERIT OFF NO Widget takes precedence // Match - 2
//
// OFF ON OFF NO Widget takes precedence // Match - 2
// OFF OFF OFF NO Widget takes precedence // Match - 2
// OFF INHERIT OFF NO Widget takes precedence // Match - 2
//
// ON ON INHERIT YES Media takes precedence // Match - 3
// ON OFF INHERIT NO Media takes precedence // Match - 4
// ON INHERIT INHERIT YES Media takes precedence and Inherited from Layout // Match - 5
//
// OFF ON INHERIT YES Media takes precedence // Match - 3
// OFF OFF INHERIT NO Media takes precedence // Match - 4
// OFF INHERIT INHERIT NO Media takes precedence and Inherited from Layout // Match - 6
////
public function testLayoutOff()
{
// Publish layout
$response = $this->sendRequest('PUT','/layout/publish/' . $this->layoutOff->layoutId, [
'publishNow' => 1
], ['CONTENT_TYPE' => 'application/x-www-form-urlencoded']);
$response = json_decode($response->getBody(), true);
$this->layoutOff = $this->constructLayoutFromResponse($response['data']);
// Confirm our Layout is in the Schedule
$schedule = $this->getXmdsWrapper()->Schedule($this->display->license);
$this->assertContains('file="' . $this->layoutOff->layoutId . '"', $schedule, 'Layout not scheduled');
// Call Required Files
$rf = $this->getXmdsWrapper()->RequiredFiles($this->display->license);
// Get XML string for player
$xmlString = $this->getXmdsWrapper()->GetFile($this->display->license, $this->layoutOff->layoutId, 'layout', 0, 0);
// Layout enable stat 0
$this->assertContains('<layout width="1920" height="1080" bgcolor="#000" schemaVersion="3" enableStat="0">', $xmlString );
// Layout Off, Media Inherit, Widget On, Output => [0, 'Inherit', 'On', 1],
$this->assertContains('<media id="'.$this->widgetId.'" type="video" render="native" duration="10" useDuration="1" fromDt="1970-01-01 01:00:00" toDt="2038-01-19 03:14:07" enableStat="1" fileId="'.$this->media->mediaId.'">', $xmlString );
}
public function testLayoutOn()
{
// Publish layout
$response = $this->sendRequest('PUT','/layout/publish/' . $this->layoutOn->layoutId, [
'publishNow' => 1
], ['CONTENT_TYPE' => 'application/x-www-form-urlencoded']);
$response = json_decode($response->getBody(), true);
$this->layoutOn = $this->constructLayoutFromResponse($response['data']);
// Confirm our Layout is in the Schedule
$schedule = $this->getXmdsWrapper()->Schedule($this->display2->license);
$this->assertContains('file="' . $this->layoutOn->layoutId . '"', $schedule, 'Layout not scheduled');
// Call Required Files
$rf = $this->getXmdsWrapper()->RequiredFiles($this->display2->license);
// Get XML string for player
$xmlString = $this->getXmdsWrapper()->GetFile($this->display2->license, $this->layoutOn->layoutId, 'layout', 0, 0);
// Layout enable stat 1
$this->assertContains('<layout width="1920" height="1080" bgcolor="#000" schemaVersion="3" enableStat="1">', $xmlString );
// Layout On, Media Inherit, Widget On, Output => [1, 'Inherit', 'On', 1],
$this->assertContains('<media id="'.$this->widgetId2.'" type="video" render="native" duration="10" useDuration="1" fromDt="1970-01-01 01:00:00" toDt="2038-01-19 03:14:07" enableStat="1" fileId="'.$this->media->mediaId.'">', $xmlString );
}
}

View File

@@ -0,0 +1,285 @@
<?php
/*
* Copyright (C) 2025 Xibo Signage Ltd
*
* Xibo - Digital Signage - https://xibosignage.com
*
* 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\Helper\Random;
use Xibo\OAuth2\Client\Entity\XiboDisplay;
use Xibo\OAuth2\Client\Entity\XiboLayout;
use Xibo\OAuth2\Client\Entity\XiboLibrary;
use Xibo\OAuth2\Client\Entity\XiboPlaylist;
use Xibo\OAuth2\Client\Entity\XiboRegion;
use Xibo\OAuth2\Client\Entity\XiboSchedule;
use Xibo\OAuth2\Client\Entity\XiboTicker;
use Xibo\Tests\Helper\DisplayHelperTrait;
use Xibo\Tests\Helper\LayoutHelperTrait;
use Xibo\Tests\LocalWebTestCase;
/**
* Class LayoutProofOfPlayXMLMediaOffWidgetInheritTest
* @package Xibo\Tests\integration\Cache
*/
class LayoutProofOfPlayXMLMediaOffWidgetInheritTest extends LocalWebTestCase
{
use LayoutHelperTrait;
use DisplayHelperTrait;
/** @var XiboLayout */
protected $layoutOff;
/** @var XiboLayout */
protected $layoutOn;
/** @var XiboRegion */
protected $region;
/** @var XiboDisplay */
protected $display;
/** @var XiboDisplay */
protected $display2;
/** @var XiboTicker */
protected $widget;
/** @var XiboLibrary */
protected $media;
/** @var XiboLibrary */
protected $mediaOn;
protected $widgetId;
protected $widgetId2;
// <editor-fold desc="Init">
public function setup()
{
parent::setup();
$this->getLogger()->debug('Setup test for ' . get_class($this) .' Test');
// Create a Layout with enableStat Off (by default)
$this->layoutOff = $this->createLayout();
$layoutOff = $this->getDraft($this->layoutOff);
// Upload some media - enableStat is Inherit (from global media stat setting)
$this->media = (new XiboLibrary($this->getEntityProvider()))->create(
Random::generateString(8, 'API Video'),
PROJECT_ROOT . '/tests/resources/HLH264.mp4'
);
// Edit the media to set enableStat On
$this->media->edit(
$this->media->name,
$this->media->duration,
$this->media->retired,
$this->media->tags,
$this->media->updateInLayouts,
'Off'
);
// Assign the media we've edited to our regions playlist- widget with Inherit (from global widget stat setting)
$playlist = (new XiboPlaylist($this->getEntityProvider()))
->assign([$this->media->mediaId], 10, $layoutOff->regions[0]->regionPlaylist->playlistId);
// Store the widgetId
$this->widgetId = $playlist->widgets[0]->widgetId;
// 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()->addSeconds(3600)->format(DateFormatHelper::getSystemFormat()),
Carbon::now()->addSeconds(7200)->format(DateFormatHelper::getSystemFormat()),
$this->layoutOff->campaignId,
[$this->display->displayGroupId],
0,
NULL,
NULL,
NULL,
0,
0,
0
);
$this->displaySetStatus($this->display, Display::$STATUS_DONE);
$this->displaySetLicensed($this->display);
// Create a layout with enableStat On
$this->layoutOn = (new XiboLayout($this->getEntityProvider()))->create(
Random::generateString(8, 'phpunit'),
'phpunit description',
'',
$this->getResolutionId('landscape'),
1
);
$layoutOn = $this->getDraft($this->layoutOn);
// Assign the media we've created to our regions playlist- widget with Inherit (from global widget stat setting)
$playlist2 = (new XiboPlaylist($this->getEntityProvider()))
->assign([$this->media->mediaId], 10, $layoutOn->regions[0]->regionPlaylist->playlistId);
// Store the widgetId
$this->widgetId2 = $playlist2->widgets[0]->widgetId;
// Create a Display2
$this->display2 = $this->createDisplay();
// Schedule the LayoutOn "always" onto our display
// deleting the layoutOn will remove this at the end
$event2 = (new XiboSchedule($this->getEntityProvider()))->createEventLayout(
Carbon::now()->addSeconds(3600)->format(DateFormatHelper::getSystemFormat()),
Carbon::now()->addSeconds(7200)->format(DateFormatHelper::getSystemFormat()),
$this->layoutOn->campaignId,
[$this->display2->displayGroupId],
0,
NULL,
NULL,
NULL,
0,
0,
0
);
$this->displaySetStatus($this->display2, Display::$STATUS_DONE);
$this->displaySetLicensed($this->display2);
$this->getLogger()->debug('Finished Setup');
}
public function tearDown()
{
$this->getLogger()->debug('Tear Down');
// Delete the LayoutOff
$this->deleteLayout($this->layoutOff);
// Delete the Display
$this->deleteDisplay($this->display);
// Delete the LayoutOn
$this->deleteLayout($this->layoutOn);
// Delete the Display2
$this->deleteDisplay($this->display2);
// Delete the media record
$this->media->deleteAssigned();
parent::tearDown();
}
// </editor-fold>
// Logic Table
//
// Widget With Media
// LAYOUT MEDIA WIDGET Media stats collected?
// ON ON ON YES Widget takes precedence // Match - 1
// ON OFF ON YES Widget takes precedence // Match - 1
// ON INHERIT ON YES Widget takes precedence // Match - 1
//
// OFF ON ON YES Widget takes precedence // Match - 1
// OFF OFF ON YES Widget takes precedence // Match - 1
// OFF INHERIT ON YES Widget takes precedence // Match - 1
//
// ON ON OFF NO Widget takes precedence // Match - 2
// ON OFF OFF NO Widget takes precedence // Match - 2
// ON INHERIT OFF NO Widget takes precedence // Match - 2
//
// OFF ON OFF NO Widget takes precedence // Match - 2
// OFF OFF OFF NO Widget takes precedence // Match - 2
// OFF INHERIT OFF NO Widget takes precedence // Match - 2
//
// ON ON INHERIT YES Media takes precedence // Match - 3
// ON OFF INHERIT NO Media takes precedence // Match - 4
// ON INHERIT INHERIT YES Media takes precedence and Inherited from Layout // Match - 5
//
// OFF ON INHERIT YES Media takes precedence // Match - 3
// OFF OFF INHERIT NO Media takes precedence // Match - 4
// OFF INHERIT INHERIT NO Media takes precedence and Inherited from Layout // Match - 6
////
public function testLayoutOff()
{
// Publish layout
$response = $this->sendRequest('PUT','/layout/publish/' . $this->layoutOff->layoutId, [
'publishNow' => 1
], ['CONTENT_TYPE' => 'application/x-www-form-urlencoded']);
$response = json_decode($response->getBody(), true);
$this->layoutOff = $this->constructLayoutFromResponse($response['data']);
// Confirm our Layout is in the Schedule
$schedule = $this->getXmdsWrapper()->Schedule($this->display->license);
$this->assertContains('file="' . $this->layoutOff->layoutId . '"', $schedule, 'Layout not scheduled');
// Call Required Files
$rf = $this->getXmdsWrapper()->RequiredFiles($this->display->license);
// Get XML string for player
$xmlString = $this->getXmdsWrapper()->GetFile($this->display->license, $this->layoutOff->layoutId, 'layout', 0, 0);
// Layout enable stat 0
$this->assertContains('<layout width="1920" height="1080" bgcolor="#000" schemaVersion="3" enableStat="0">', $xmlString );
// Layout Off, Media Off, Widget Inherit, Output => [0, 'Off', 'Inherit', 0],
$this->assertContains('<media id="'.$this->widgetId.'" type="video" render="native" duration="10" useDuration="1" fromDt="1970-01-01 01:00:00" toDt="2038-01-19 03:14:07" enableStat="0" fileId="'.$this->media->mediaId.'">', $xmlString );
}
public function testLayoutOn()
{
// Publish layout
$response = $this->sendRequest('PUT','/layout/publish/' . $this->layoutOn->layoutId, [
'publishNow' => 1
], ['CONTENT_TYPE' => 'application/x-www-form-urlencoded']);
$response = json_decode($response->getBody(), true);
$this->layoutOn = $this->constructLayoutFromResponse($response['data']);
// Confirm our Layout is in the Schedule
$schedule = $this->getXmdsWrapper()->Schedule($this->display2->license);
$this->assertContains('file="' . $this->layoutOn->layoutId . '"', $schedule, 'Layout not scheduled');
// Call Required Files
$rf = $this->getXmdsWrapper()->RequiredFiles($this->display2->license);
// Get XML string for player
$xmlString = $this->getXmdsWrapper()->GetFile($this->display2->license, $this->layoutOn->layoutId, 'layout', 0, 0);
// Layout enable stat 1
$this->assertContains('<layout width="1920" height="1080" bgcolor="#000" schemaVersion="3" enableStat="1">', $xmlString );
// Layout On, Media Off, Widget Inherit, Output => [1, 'Off', 'Inherit', 0],
$this->assertContains('<media id="'.$this->widgetId2.'" type="video" render="native" duration="10" useDuration="1" fromDt="1970-01-01 01:00:00" toDt="2038-01-19 03:14:07" enableStat="0" fileId="'.$this->media->mediaId.'">', $xmlString );
}
}

View File

@@ -0,0 +1,292 @@
<?php
/*
* Copyright (C) 2025 Xibo Signage Ltd
*
* Xibo - Digital Signage - https://xibosignage.com
*
* 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\Helper\Random;
use Xibo\OAuth2\Client\Entity\XiboDisplay;
use Xibo\OAuth2\Client\Entity\XiboLayout;
use Xibo\OAuth2\Client\Entity\XiboLibrary;
use Xibo\OAuth2\Client\Entity\XiboPlaylist;
use Xibo\OAuth2\Client\Entity\XiboRegion;
use Xibo\OAuth2\Client\Entity\XiboSchedule;
use Xibo\OAuth2\Client\Entity\XiboTicker;
use Xibo\Tests\Helper\DisplayHelperTrait;
use Xibo\Tests\Helper\LayoutHelperTrait;
use Xibo\Tests\LocalWebTestCase;
/**
* Class LayoutProofOfPlayXMLMediaOffWidgetOffTest
* @package Xibo\Tests\integration\Cache
*/
class LayoutProofOfPlayXMLMediaOffWidgetOffTest extends LocalWebTestCase
{
use LayoutHelperTrait;
use DisplayHelperTrait;
/** @var XiboLayout */
protected $layoutOff;
/** @var XiboLayout */
protected $layoutOn;
/** @var XiboRegion */
protected $region;
/** @var XiboDisplay */
protected $display;
/** @var XiboDisplay */
protected $display2;
/** @var XiboTicker */
protected $widget;
/** @var XiboLibrary */
protected $media;
/** @var XiboLibrary */
protected $mediaOn;
protected $widgetId;
protected $widgetId2;
// <editor-fold desc="Init">
public function setup()
{
parent::setup();
$this->getLogger()->debug('Setup test for ' . get_class($this) .' Test');
// Set global widget enable stat set to Off
self::$container->get('configService')->changeSetting('WIDGET_STATS_ENABLED_DEFAULT', 'Off');
$this->getStore()->commitIfNecessary();
// Create a Layout with enableStat Off (by default)
$this->layoutOff = $this->createLayout();
$layoutOff = $this->getDraft($this->layoutOff);
// Upload some media - enableStat is Inherit (from global media stat setting)
$this->media = (new XiboLibrary($this->getEntityProvider()))->create(
Random::generateString(8, 'API Video'),
PROJECT_ROOT . '/tests/resources/HLH264.mp4'
);
// Edit the media to set enableStat On
$this->media->edit(
$this->media->name,
$this->media->duration,
$this->media->retired,
$this->media->tags,
$this->media->updateInLayouts,
'Off'
);
// Assign the media we've edited to our regions playlist- widget with Inherit (from global widget stat setting)
$playlist = (new XiboPlaylist($this->getEntityProvider()))
->assign([$this->media->mediaId], 10, $layoutOff->regions[0]->regionPlaylist->playlistId);
// Store the widgetId
$this->widgetId = $playlist->widgets[0]->widgetId;
// 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()->addSeconds(3600)->format(DateFormatHelper::getSystemFormat()),
Carbon::now()->addSeconds(7200)->format(DateFormatHelper::getSystemFormat()),
$this->layoutOff->campaignId,
[$this->display->displayGroupId],
0,
NULL,
NULL,
NULL,
0,
0,
0
);
$this->displaySetStatus($this->display, Display::$STATUS_DONE);
$this->displaySetLicensed($this->display);
// Create a layout with enableStat On
$this->layoutOn = (new XiboLayout($this->getEntityProvider()))->create(
Random::generateString(8, 'phpunit'),
'phpunit description',
'',
$this->getResolutionId('landscape'),
1
);
$layoutOn = $this->getDraft($this->layoutOn);
// Assign the media we've created to our regions playlist- widget with Inherit (from global widget stat setting)
$playlist2 = (new XiboPlaylist($this->getEntityProvider()))
->assign([$this->media->mediaId], 10, $layoutOn->regions[0]->regionPlaylist->playlistId);
// Store the widgetId
$this->widgetId2 = $playlist2->widgets[0]->widgetId;
// Create a Display2
$this->display2 = $this->createDisplay();
// Schedule the LayoutOn "always" onto our display
// deleting the layoutOn will remove this at the end
$event2 = (new XiboSchedule($this->getEntityProvider()))->createEventLayout(
Carbon::now()->addSeconds(3600)->format(DateFormatHelper::getSystemFormat()),
Carbon::now()->addSeconds(7200)->format(DateFormatHelper::getSystemFormat()),
$this->layoutOn->campaignId,
[$this->display2->displayGroupId],
0,
NULL,
NULL,
NULL,
0,
0,
0
);
$this->displaySetStatus($this->display2, Display::$STATUS_DONE);
$this->displaySetLicensed($this->display2);
$this->getLogger()->debug('Finished Setup');
}
public function tearDown()
{
$this->getLogger()->debug('Tear Down');
// Delete the LayoutOn
$this->deleteLayout($this->layoutOff);
// Delete the Display2
$this->deleteDisplay($this->display);
// Delete the LayoutOn
$this->deleteLayout($this->layoutOn);
// Delete the Display2
$this->deleteDisplay($this->display2);
// Delete the media record
$this->media->deleteAssigned();
// Set global widget enable stat set to Inherit
self::$container->get('configService')->changeSetting('WIDGET_STATS_ENABLED_DEFAULT', 'Inherit');
$this->getStore()->commitIfNecessary();
parent::tearDown();
}
// </editor-fold>
// Logic Table
//
// Widget With Media
// LAYOUT MEDIA WIDGET Media stats collected?
// ON ON ON YES Widget takes precedence // Match - 1
// ON OFF ON YES Widget takes precedence // Match - 1
// ON INHERIT ON YES Widget takes precedence // Match - 1
//
// OFF ON ON YES Widget takes precedence // Match - 1
// OFF OFF ON YES Widget takes precedence // Match - 1
// OFF INHERIT ON YES Widget takes precedence // Match - 1
//
// ON ON OFF NO Widget takes precedence // Match - 2
// ON OFF OFF NO Widget takes precedence // Match - 2
// ON INHERIT OFF NO Widget takes precedence // Match - 2
//
// OFF ON OFF NO Widget takes precedence // Match - 2
// OFF OFF OFF NO Widget takes precedence // Match - 2
// OFF INHERIT OFF NO Widget takes precedence // Match - 2
//
// ON ON INHERIT YES Media takes precedence // Match - 3
// ON OFF INHERIT NO Media takes precedence // Match - 4
// ON INHERIT INHERIT YES Media takes precedence and Inherited from Layout // Match - 5
//
// OFF ON INHERIT YES Media takes precedence // Match - 3
// OFF OFF INHERIT NO Media takes precedence // Match - 4
// OFF INHERIT INHERIT NO Media takes precedence and Inherited from Layout // Match - 6
////
public function testLayoutOff()
{
// Publish layout
$response = $this->sendRequest('PUT','/layout/publish/' . $this->layoutOff->layoutId, [
'publishNow' => 1
], ['CONTENT_TYPE' => 'application/x-www-form-urlencoded']);
$response = json_decode($response->getBody(), true);
$this->layoutOff = $this->constructLayoutFromResponse($response['data']);
// Confirm our Layout is in the Schedule
$schedule = $this->getXmdsWrapper()->Schedule($this->display->license);
$this->assertContains('file="' . $this->layoutOff->layoutId . '"', $schedule, 'Layout not scheduled');
// Call Required Files
$rf = $this->getXmdsWrapper()->RequiredFiles($this->display->license);
// Get XML string for player
$xmlString = $this->getXmdsWrapper()->GetFile($this->display->license, $this->layoutOff->layoutId, 'layout', 0, 0);
// Layout enable stat 0
$this->assertContains('<layout width="1920" height="1080" bgcolor="#000" schemaVersion="3" enableStat="0">', $xmlString );
// Layout Off, Media Off, Widget Off, Output => [0, 'Off', 'Off', 0],
$this->assertContains('<media id="'.$this->widgetId.'" type="video" render="native" duration="10" useDuration="1" fromDt="1970-01-01 01:00:00" toDt="2038-01-19 03:14:07" enableStat="0" fileId="'.$this->media->mediaId.'">', $xmlString );
}
public function testLayoutOn()
{
// Publish layout
$response = $this->sendRequest('PUT','/layout/publish/' . $this->layoutOn->layoutId, [
'publishNow' => 1
], ['CONTENT_TYPE' => 'application/x-www-form-urlencoded']);
$response = json_decode($response->getBody(), true);
$this->layoutOn = $this->constructLayoutFromResponse($response['data']);
// Confirm our Layout is in the Schedule
$schedule = $this->getXmdsWrapper()->Schedule($this->display2->license);
$this->assertContains('file="' . $this->layoutOn->layoutId . '"', $schedule, 'Layout not scheduled');
// Call Required Files
$rf = $this->getXmdsWrapper()->RequiredFiles($this->display2->license);
// Get XML string for player
$xmlString = $this->getXmdsWrapper()->GetFile($this->display2->license, $this->layoutOn->layoutId, 'layout', 0, 0);
// Layout enable stat 1
$this->assertContains('<layout width="1920" height="1080" bgcolor="#000" schemaVersion="3" enableStat="1">', $xmlString );
// Layout On, Media Off, Widget Off, Output => [1, 'Off', 'Off', 0],
$this->assertContains('<media id="'.$this->widgetId2.'" type="video" render="native" duration="10" useDuration="1" fromDt="1970-01-01 01:00:00" toDt="2038-01-19 03:14:07" enableStat="0" fileId="'.$this->media->mediaId.'">', $xmlString );
}
}

View File

@@ -0,0 +1,292 @@
<?php
/*
* Copyright (C) 2025 Xibo Signage Ltd
*
* Xibo - Digital Signage - https://xibosignage.com
*
* 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\Helper\Random;
use Xibo\OAuth2\Client\Entity\XiboDisplay;
use Xibo\OAuth2\Client\Entity\XiboLayout;
use Xibo\OAuth2\Client\Entity\XiboLibrary;
use Xibo\OAuth2\Client\Entity\XiboPlaylist;
use Xibo\OAuth2\Client\Entity\XiboRegion;
use Xibo\OAuth2\Client\Entity\XiboSchedule;
use Xibo\OAuth2\Client\Entity\XiboTicker;
use Xibo\Tests\Helper\DisplayHelperTrait;
use Xibo\Tests\Helper\LayoutHelperTrait;
use Xibo\Tests\LocalWebTestCase;
/**
* Class LayoutProofOfPlayXMLMediaOffWidgetOnTest
* @package Xibo\Tests\integration\Cache
*/
class LayoutProofOfPlayXMLMediaOffWidgetOnTest extends LocalWebTestCase
{
use LayoutHelperTrait;
use DisplayHelperTrait;
/** @var XiboLayout */
protected $layoutOff;
/** @var XiboLayout */
protected $layoutOn;
/** @var XiboRegion */
protected $region;
/** @var XiboDisplay */
protected $display;
/** @var XiboDisplay */
protected $display2;
/** @var XiboTicker */
protected $widget;
/** @var XiboLibrary */
protected $media;
/** @var XiboLibrary */
protected $mediaOn;
protected $widgetId;
protected $widgetId2;
// <editor-fold desc="Init">
public function setup()
{
parent::setup();
$this->getLogger()->debug('Setup test for ' . get_class($this) .' Test');
// Set global widget enable stat set to On
self::$container->get('configService')->changeSetting('WIDGET_STATS_ENABLED_DEFAULT', 'On');
$this->getStore()->commitIfNecessary();
// Create a Layout with enableStat Off (by default)
$this->layoutOff = $this->createLayout();
$layoutOff = $this->getDraft($this->layoutOff);
// Upload some media - enableStat is Inherit (from global media stat setting)
$this->media = (new XiboLibrary($this->getEntityProvider()))->create(
Random::generateString(8, 'API Video'),
PROJECT_ROOT . '/tests/resources/HLH264.mp4'
);
// Edit the media to set enableStat On
$this->media->edit(
$this->media->name,
$this->media->duration,
$this->media->retired,
$this->media->tags,
$this->media->updateInLayouts,
'Off'
);
// Assign the media we've edited to our regions playlist- widget with Inherit (from global widget stat setting)
$playlist = (new XiboPlaylist($this->getEntityProvider()))
->assign([$this->media->mediaId], 10, $layoutOff->regions[0]->regionPlaylist->playlistId);
// Store the widgetId
$this->widgetId = $playlist->widgets[0]->widgetId;
// 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()->addSeconds(3600)->format(DateFormatHelper::getSystemFormat()),
Carbon::now()->addSeconds(7200)->format(DateFormatHelper::getSystemFormat()),
$this->layoutOff->campaignId,
[$this->display->displayGroupId],
0,
NULL,
NULL,
NULL,
0,
0,
0
);
$this->displaySetStatus($this->display, Display::$STATUS_DONE);
$this->displaySetLicensed($this->display);
// Create a layout with enableStat On
$this->layoutOn = (new XiboLayout($this->getEntityProvider()))->create(
Random::generateString(8, 'phpunit'),
'phpunit description',
'',
$this->getResolutionId('landscape'),
1
);
$layoutOn = $this->getDraft($this->layoutOn);
// Assign the media we've created to our regions playlist- widget with Inherit (from global widget stat setting)
$playlist2 = (new XiboPlaylist($this->getEntityProvider()))
->assign([$this->media->mediaId], 10, $layoutOn->regions[0]->regionPlaylist->playlistId);
// Store the widgetId
$this->widgetId2 = $playlist2->widgets[0]->widgetId;
// Create a Display2
$this->display2 = $this->createDisplay();
// Schedule the LayoutOn "always" onto our display
// deleting the layoutOn will remove this at the end
$event2 = (new XiboSchedule($this->getEntityProvider()))->createEventLayout(
Carbon::now()->addSeconds(3600)->format(DateFormatHelper::getSystemFormat()),
Carbon::now()->addSeconds(7200)->format(DateFormatHelper::getSystemFormat()),
$this->layoutOn->campaignId,
[$this->display2->displayGroupId],
0,
NULL,
NULL,
NULL,
0,
0,
0
);
$this->displaySetStatus($this->display2, Display::$STATUS_DONE);
$this->displaySetLicensed($this->display2);
$this->getLogger()->debug('Finished Setup');
}
public function tearDown()
{
$this->getLogger()->debug('Tear Down');
// Delete the LayoutOn
$this->deleteLayout($this->layoutOff);
// Delete the Display2
$this->deleteDisplay($this->display);
// Delete the LayoutOn
$this->deleteLayout($this->layoutOn);
// Delete the Display2
$this->deleteDisplay($this->display2);
// Delete the media record
$this->media->deleteAssigned();
// Set global widget enable stat set to Inherit
self::$container->get('configService')->changeSetting('WIDGET_STATS_ENABLED_DEFAULT', 'Inherit');
$this->getStore()->commitIfNecessary();
parent::tearDown();
}
// </editor-fold>
// Logic Table
//
// Widget With Media
// LAYOUT MEDIA WIDGET Media stats collected?
// ON ON ON YES Widget takes precedence // Match - 1
// ON OFF ON YES Widget takes precedence // Match - 1
// ON INHERIT ON YES Widget takes precedence // Match - 1
//
// OFF ON ON YES Widget takes precedence // Match - 1
// OFF OFF ON YES Widget takes precedence // Match - 1
// OFF INHERIT ON YES Widget takes precedence // Match - 1
//
// ON ON OFF NO Widget takes precedence // Match - 2
// ON OFF OFF NO Widget takes precedence // Match - 2
// ON INHERIT OFF NO Widget takes precedence // Match - 2
//
// OFF ON OFF NO Widget takes precedence // Match - 2
// OFF OFF OFF NO Widget takes precedence // Match - 2
// OFF INHERIT OFF NO Widget takes precedence // Match - 2
//
// ON ON INHERIT YES Media takes precedence // Match - 3
// ON OFF INHERIT NO Media takes precedence // Match - 4
// ON INHERIT INHERIT YES Media takes precedence and Inherited from Layout // Match - 5
//
// OFF ON INHERIT YES Media takes precedence // Match - 3
// OFF OFF INHERIT NO Media takes precedence // Match - 4
// OFF INHERIT INHERIT NO Media takes precedence and Inherited from Layout // Match - 6
////
public function testLayoutOff()
{
// Publish layout
$response = $this->sendRequest('PUT','/layout/publish/' . $this->layoutOff->layoutId, [
'publishNow' => 1
], ['CONTENT_TYPE' => 'application/x-www-form-urlencoded']);
$response = json_decode($response->getBody(), true);
$this->layoutOff = $this->constructLayoutFromResponse($response['data']);
// Confirm our Layout is in the Schedule
$schedule = $this->getXmdsWrapper()->Schedule($this->display->license);
$this->assertContains('file="' . $this->layoutOff->layoutId . '"', $schedule, 'Layout not scheduled');
// Call Required Files
$rf = $this->getXmdsWrapper()->RequiredFiles($this->display->license);
// Get XML string for player
$xmlString = $this->getXmdsWrapper()->GetFile($this->display->license, $this->layoutOff->layoutId, 'layout', 0, 0);
// Layout enable stat 0
$this->assertContains('<layout width="1920" height="1080" bgcolor="#000" schemaVersion="3" enableStat="0">', $xmlString );
// Layout Off, Media Off, Widget On, Output => [0, 'Off', 'On', 1],
$this->assertContains('<media id="'.$this->widgetId.'" type="video" render="native" duration="10" useDuration="1" fromDt="1970-01-01 01:00:00" toDt="2038-01-19 03:14:07" enableStat="1" fileId="'.$this->media->mediaId.'">', $xmlString );
}
public function testLayoutOn()
{
// Publish layout
$response = $this->sendRequest('PUT','/layout/publish/' . $this->layoutOn->layoutId, [
'publishNow' => 1
], ['CONTENT_TYPE' => 'application/x-www-form-urlencoded']);
$response = json_decode($response->getBody(), true);
$this->layoutOn = $this->constructLayoutFromResponse($response['data']);
// Confirm our Layout is in the Schedule
$schedule = $this->getXmdsWrapper()->Schedule($this->display2->license);
$this->assertContains('file="' . $this->layoutOn->layoutId . '"', $schedule, 'Layout not scheduled');
// Call Required Files
$rf = $this->getXmdsWrapper()->RequiredFiles($this->display2->license);
// Get XML string for player
$xmlString = $this->getXmdsWrapper()->GetFile($this->display2->license, $this->layoutOn->layoutId, 'layout', 0, 0);
// Layout enable stat 1
$this->assertContains('<layout width="1920" height="1080" bgcolor="#000" schemaVersion="3" enableStat="1">', $xmlString );
// Layout On, Media Off, Widget On, Output => [1, 'Off', 'On', 1],
$this->assertContains('<media id="'.$this->widgetId2.'" type="video" render="native" duration="10" useDuration="1" fromDt="1970-01-01 01:00:00" toDt="2038-01-19 03:14:07" enableStat="1" fileId="'.$this->media->mediaId.'">', $xmlString );
}
}

View File

@@ -0,0 +1,283 @@
<?php
/*
* Copyright (C) 2025 Xibo Signage Ltd
*
* Xibo - Digital Signage - https://xibosignage.com
*
* 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\Helper\Random;
use Xibo\OAuth2\Client\Entity\XiboDisplay;
use Xibo\OAuth2\Client\Entity\XiboLayout;
use Xibo\OAuth2\Client\Entity\XiboLibrary;
use Xibo\OAuth2\Client\Entity\XiboPlaylist;
use Xibo\OAuth2\Client\Entity\XiboRegion;
use Xibo\OAuth2\Client\Entity\XiboSchedule;
use Xibo\OAuth2\Client\Entity\XiboTicker;
use Xibo\Tests\Helper\DisplayHelperTrait;
use Xibo\Tests\Helper\LayoutHelperTrait;
use Xibo\Tests\LocalWebTestCase;
/**
* Class LayoutProofOfPlayXMLMediaOnWidgetInheritTest
* @package Xibo\Tests\integration\Cache
*/
class LayoutProofOfPlayXMLMediaOnWidgetInheritTest extends LocalWebTestCase
{
use LayoutHelperTrait;
use DisplayHelperTrait;
/** @var XiboLayout */
protected $layoutOff;
/** @var XiboLayout */
protected $layoutOn;
/** @var XiboRegion */
protected $region;
/** @var XiboDisplay */
protected $display;
/** @var XiboDisplay */
protected $display2;
/** @var XiboTicker */
protected $widget;
/** @var XiboLibrary */
protected $media;
/** @var XiboLibrary */
protected $mediaOn;
protected $widgetId;
protected $widgetId2;
// <editor-fold desc="Init">
public function setup()
{
parent::setup();
$this->getLogger()->debug('Setup test for ' . get_class($this) .' Test');
// Create a Layout with enableStat Off (by default)
$this->layoutOff = $this->createLayout();
$layoutOff = $this->getDraft($this->layoutOff);
// Upload some media - enableStat is Inherit (from global media stat setting)
$this->media = (new XiboLibrary($this->getEntityProvider()))->create(
Random::generateString(8, 'API Video'),
PROJECT_ROOT . '/tests/resources/HLH264.mp4'
);
// Edit the media to set enableStat On
$this->media->edit(
$this->media->name,
$this->media->duration,
$this->media->retired,
$this->media->tags,
$this->media->updateInLayouts,
'On'
);
// Assign the media we've edited to our regions playlist- widget with Inherit (from global widget stat setting)
$playlist = (new XiboPlaylist($this->getEntityProvider()))
->assign([$this->media->mediaId], 10, $layoutOff->regions[0]->regionPlaylist->playlistId);
// Store the widgetId
$this->widgetId = $playlist->widgets[0]->widgetId;
// 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()->addSeconds(3600)->format(DateFormatHelper::getSystemFormat()),
Carbon::now()->addSeconds(7200)->format(DateFormatHelper::getSystemFormat()),
$this->layoutOff->campaignId,
[$this->display->displayGroupId],
0,
NULL,
NULL,
NULL,
0,
0,
0
);
$this->displaySetStatus($this->display, Display::$STATUS_DONE);
$this->displaySetLicensed($this->display);
// Create a layout with enableStat On
$this->layoutOn = (new XiboLayout($this->getEntityProvider()))->create(
Random::generateString(8, 'phpunit'),
'phpunit description',
'',
$this->getResolutionId('landscape'),
1
);
$layoutOn = $this->getDraft($this->layoutOn);
// Assign the media we've created to our regions playlist- widget with Inherit (from global widget stat setting)
$playlist2 = (new XiboPlaylist($this->getEntityProvider()))
->assign([$this->media->mediaId], 10, $layoutOn->regions[0]->regionPlaylist->playlistId);
// Store the widgetId
$this->widgetId2 = $playlist2->widgets[0]->widgetId;
// Create a Display2
$this->display2 = $this->createDisplay();
// Schedule the LayoutOn "always" onto our display
// deleting the layoutOn will remove this at the end
$event2 = (new XiboSchedule($this->getEntityProvider()))->createEventLayout(
Carbon::now()->addSeconds(3600)->format(DateFormatHelper::getSystemFormat()),
Carbon::now()->addSeconds(7200)->format(DateFormatHelper::getSystemFormat()),
$this->layoutOn->campaignId,
[$this->display2->displayGroupId],
0,
NULL,
NULL,
NULL,
0,
0,
0
);
$this->displaySetStatus($this->display2, Display::$STATUS_DONE);
$this->displaySetLicensed($this->display2);
$this->getLogger()->debug('Finished Setup');
}
public function tearDown()
{
$this->getLogger()->debug('Tear Down');
// Delete the LayoutOff
$this->deleteLayout($this->layoutOff);
// Delete the Display
$this->deleteDisplay($this->display);
// Delete the LayoutOn
$this->deleteLayout($this->layoutOn);
// Delete the Display2
$this->deleteDisplay($this->display2);
// Delete the media record
$this->media->deleteAssigned();
parent::tearDown();
}
// </editor-fold>
// Logic Table
//
// Widget With Media
// LAYOUT MEDIA WIDGET Media stats collected?
// ON ON ON YES Widget takes precedence // Match - 1
// ON OFF ON YES Widget takes precedence // Match - 1
// ON INHERIT ON YES Widget takes precedence // Match - 1
//
// OFF ON ON YES Widget takes precedence // Match - 1
// OFF OFF ON YES Widget takes precedence // Match - 1
// OFF INHERIT ON YES Widget takes precedence // Match - 1
//
// ON ON OFF NO Widget takes precedence // Match - 2
// ON OFF OFF NO Widget takes precedence // Match - 2
// ON INHERIT OFF NO Widget takes precedence // Match - 2
//
// OFF ON OFF NO Widget takes precedence // Match - 2
// OFF OFF OFF NO Widget takes precedence // Match - 2
// OFF INHERIT OFF NO Widget takes precedence // Match - 2
//
// ON ON INHERIT YES Media takes precedence // Match - 3
// ON OFF INHERIT NO Media takes precedence // Match - 4
// ON INHERIT INHERIT YES Media takes precedence and Inherited from Layout // Match - 5
//
// OFF ON INHERIT YES Media takes precedence // Match - 3
// OFF OFF INHERIT NO Media takes precedence // Match - 4
// OFF INHERIT INHERIT NO Media takes precedence and Inherited from Layout // Match - 6
////
public function testLayoutOff()
{
// Publish layout
$response = $this->sendRequest('PUT','/layout/publish/' . $this->layoutOff->layoutId, [
'publishNow' => 1
], ['CONTENT_TYPE' => 'application/x-www-form-urlencoded']);
$response = json_decode($response->getBody(), true);
$this->layoutOff = $this->constructLayoutFromResponse($response['data']);
// Confirm our Layout is in the Schedule
$schedule = $this->getXmdsWrapper()->Schedule($this->display->license);
$this->assertContains('file="' . $this->layoutOff->layoutId . '"', $schedule, 'Layout not scheduled');
// Call Required Files
$rf = $this->getXmdsWrapper()->RequiredFiles($this->display->license);
// Get XML string for player
$xmlString = $this->getXmdsWrapper()->GetFile($this->display->license, $this->layoutOff->layoutId, 'layout', 0, 0);
// Layout enable stat 0
$this->assertContains('<layout width="1920" height="1080" bgcolor="#000" schemaVersion="3" enableStat="0">', $xmlString );
// Layout Off, Media On, Widget Inherit, Output => [0, 'On', 'Inherit', 1],
$this->assertContains('<media id="'.$this->widgetId.'" type="video" render="native" duration="10" useDuration="1" fromDt="1970-01-01 01:00:00" toDt="2038-01-19 03:14:07" enableStat="1" fileId="'.$this->media->mediaId.'">', $xmlString );
}
public function testLayoutOn()
{
// Publish layout
$response = $this->sendRequest('PUT','/layout/publish/' . $this->layoutOn->layoutId, [
'publishNow' => 1
], ['CONTENT_TYPE' => 'application/x-www-form-urlencoded']);
$response = json_decode($response->getBody(), true);
$this->layoutOn = $this->constructLayoutFromResponse($response['data']);
// Confirm our Layout is in the Schedule
$schedule = $this->getXmdsWrapper()->Schedule($this->display2->license);
$this->assertContains('file="' . $this->layoutOn->layoutId . '"', $schedule, 'Layout not scheduled');
// Call Required Files
$rf = $this->getXmdsWrapper()->RequiredFiles($this->display2->license);
// Get XML string for player
$xmlString = $this->getXmdsWrapper()->GetFile($this->display2->license, $this->layoutOn->layoutId, 'layout', 0, 0);
// Layout enable stat 1
$this->assertContains('<layout width="1920" height="1080" bgcolor="#000" schemaVersion="3" enableStat="1">', $xmlString );
// Layout On, Media On, Widget Inherit, Output => [1, 'On', 'Inherit', 1],
$this->assertContains('<media id="'.$this->widgetId2.'" type="video" render="native" duration="10" useDuration="1" fromDt="1970-01-01 01:00:00" toDt="2038-01-19 03:14:07" enableStat="1" fileId="'.$this->media->mediaId.'">', $xmlString );
}
}

View File

@@ -0,0 +1,294 @@
<?php
/*
* Copyright (C) 2025 Xibo Signage Ltd
*
* Xibo - Digital Signage - https://xibosignage.com
*
* 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\Helper\Random;
use Xibo\OAuth2\Client\Entity\XiboDisplay;
use Xibo\OAuth2\Client\Entity\XiboLayout;
use Xibo\OAuth2\Client\Entity\XiboLibrary;
use Xibo\OAuth2\Client\Entity\XiboPlaylist;
use Xibo\OAuth2\Client\Entity\XiboRegion;
use Xibo\OAuth2\Client\Entity\XiboSchedule;
use Xibo\OAuth2\Client\Entity\XiboTicker;
use Xibo\Tests\Helper\DisplayHelperTrait;
use Xibo\Tests\Helper\LayoutHelperTrait;
use Xibo\Tests\LocalWebTestCase;
/**
* Class LayoutProofOfPlayXMLMediaOnWidgetOffTest
* @package Xibo\Tests\integration\Cache
*/
class LayoutProofOfPlayXMLMediaOnWidgetOffTest extends LocalWebTestCase
{
use LayoutHelperTrait;
use DisplayHelperTrait;
/** @var XiboLayout */
protected $layoutOff;
/** @var XiboLayout */
protected $layoutOn;
/** @var XiboRegion */
protected $region;
/** @var XiboDisplay */
protected $display;
/** @var XiboDisplay */
protected $display2;
/** @var XiboTicker */
protected $widget;
/** @var XiboLibrary */
protected $media;
/** @var XiboLibrary */
protected $mediaOn;
protected $widgetId;
protected $widgetId2;
// <editor-fold desc="Init">
public function setup()
{
parent::setup();
$this->getLogger()->debug('Setup test for ' . get_class($this) .' Test');
// Set global widget enable stat set to Off
self::$container->get('configService')->changeSetting('WIDGET_STATS_ENABLED_DEFAULT', 'Off');
$this->getStore()->commitIfNecessary();
// Create a Layout with enableStat Off (by default)
$this->layoutOff = $this->createLayout();
$layoutOff = $this->getDraft($this->layoutOff);
// Upload some media - enableStat is Inherit (from global media stat setting)
$this->media = (new XiboLibrary($this->getEntityProvider()))->create(
Random::generateString(8, 'API Video'),
PROJECT_ROOT . '/tests/resources/HLH264.mp4'
);
// Edit the media to set enableStat On
$this->media->edit(
$this->media->name,
$this->media->duration,
$this->media->retired,
$this->media->tags,
$this->media->updateInLayouts,
'On'
);
// Assign the media we've edited to our regions playlist- widget with Inherit (from global widget stat setting)
$playlist = (new XiboPlaylist($this->getEntityProvider()))
->assign([$this->media->mediaId], 10, $layoutOff->regions[0]->regionPlaylist->playlistId);
// Store the widgetId
$this->widgetId = $playlist->widgets[0]->widgetId;
// 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()->addSeconds(3600)->format(DateFormatHelper::getSystemFormat()),
Carbon::now()->addSeconds(7200)->format(DateFormatHelper::getSystemFormat()),
$this->layoutOff->campaignId,
[$this->display->displayGroupId],
0,
NULL,
NULL,
NULL,
0,
0,
0
);
$this->displaySetStatus($this->display, Display::$STATUS_DONE);
$this->displaySetLicensed($this->display);
// Create a layout with enableStat On
$this->layoutOn = (new XiboLayout($this->getEntityProvider()))->create(
Random::generateString(8, 'phpunit'),
'phpunit description',
'',
$this->getResolutionId('landscape'),
1
);
$layoutOn = $this->getDraft($this->layoutOn);
// Assign the media we've created to our regions playlist- widget with Inherit (from global widget stat setting)
$playlist2 = (new XiboPlaylist($this->getEntityProvider()))
->assign([$this->media->mediaId], 10, $layoutOn->regions[0]->regionPlaylist->playlistId);
// Store the widgetId
$this->widgetId2 = $playlist2->widgets[0]->widgetId;
// Create a Display2
$this->display2 = $this->createDisplay();
// Schedule the LayoutOn "always" onto our display
// deleting the layoutOn will remove this at the end
$event2 = (new XiboSchedule($this->getEntityProvider()))->createEventLayout(
Carbon::now()->addSeconds(3600)->format(DateFormatHelper::getSystemFormat()),
Carbon::now()->addSeconds(7200)->format(DateFormatHelper::getSystemFormat()),
$this->layoutOn->campaignId,
[$this->display2->displayGroupId],
0,
NULL,
NULL,
NULL,
0,
0,
0
);
$this->displaySetStatus($this->display2, Display::$STATUS_DONE);
$this->displaySetLicensed($this->display2);
$this->getLogger()->debug('Finished Setup');
}
public function tearDown()
{
$this->getLogger()->debug('Tear Down');
// Delete the LayoutOn
$this->deleteLayout($this->layoutOff);
// Delete the Display2
$this->deleteDisplay($this->display);
// Delete the LayoutOn
$this->deleteLayout($this->layoutOn);
// Delete the Display2
$this->deleteDisplay($this->display2);
// Delete the media record
$this->media->deleteAssigned();
// Set global widget enable stat set to Inherit
self::$container->get('configService')->changeSetting('WIDGET_STATS_ENABLED_DEFAULT', 'Inherit');
$this->getStore()->commitIfNecessary();
parent::tearDown();
}
// </editor-fold>
// Logic Table
//
// Widget With Media
// LAYOUT MEDIA WIDGET Media stats collected?
// ON ON ON YES Widget takes precedence // Match - 1
// ON OFF ON YES Widget takes precedence // Match - 1
// ON INHERIT ON YES Widget takes precedence // Match - 1
//
// OFF ON ON YES Widget takes precedence // Match - 1
// OFF OFF ON YES Widget takes precedence // Match - 1
// OFF INHERIT ON YES Widget takes precedence // Match - 1
//
// ON ON OFF NO Widget takes precedence // Match - 2
// ON OFF OFF NO Widget takes precedence // Match - 2
// ON INHERIT OFF NO Widget takes precedence // Match - 2
//
// OFF ON OFF NO Widget takes precedence // Match - 2
// OFF OFF OFF NO Widget takes precedence // Match - 2
// OFF INHERIT OFF NO Widget takes precedence // Match - 2
//
// ON ON INHERIT YES Media takes precedence // Match - 3
// ON OFF INHERIT NO Media takes precedence // Match - 4
// ON INHERIT INHERIT YES Media takes precedence and Inherited from Layout // Match - 5
//
// OFF ON INHERIT YES Media takes precedence // Match - 3
// OFF OFF INHERIT NO Media takes precedence // Match - 4
// OFF INHERIT INHERIT NO Media takes precedence and Inherited from Layout // Match - 6
////
public function testLayoutOff()
{
// Publish layout
$response = $this->sendRequest('PUT','/layout/publish/' . $this->layoutOff->layoutId, [
'publishNow' => 1
], ['CONTENT_TYPE' => 'application/x-www-form-urlencoded']);
$response = json_decode($response->getBody(), true);
$this->layoutOff = $this->constructLayoutFromResponse($response['data']);
// Confirm our Layout is in the Schedule
$schedule = $this->getXmdsWrapper()->Schedule($this->display->license);
$this->assertContains('file="' . $this->layoutOff->layoutId . '"', $schedule, 'Layout not scheduled');
// Call Required Files
$rf = $this->getXmdsWrapper()->RequiredFiles($this->display->license);
// Get XML string for player
$xmlString = $this->getXmdsWrapper()->GetFile($this->display->license, $this->layoutOff->layoutId, 'layout', 0, 0);
// Layout enable stat 0
$this->assertContains('<layout width="1920" height="1080" bgcolor="#000" schemaVersion="3" enableStat="0">', $xmlString );
// Layout Off, Media On, Widget Off, Output => [0, 'On', 'Off', 0],
$this->assertContains('<media id="'.$this->widgetId.'" type="video" render="native" duration="10" useDuration="1" fromDt="1970-01-01 01:00:00" toDt="2038-01-19 03:14:07" enableStat="0" fileId="'.$this->media->mediaId.'">', $xmlString );
}
public function testLayoutOn()
{
// Publish layout
$response = $this->sendRequest('PUT','/layout/publish/' . $this->layoutOn->layoutId, [
'publishNow' => 1
], ['CONTENT_TYPE' => 'application/x-www-form-urlencoded']);
$response = json_decode($response->getBody(), true);
$this->layoutOn = $this->constructLayoutFromResponse($response['data']);
// Confirm our Layout is in the Schedule
$schedule = $this->getXmdsWrapper()->Schedule($this->display2->license);
$this->assertContains('file="' . $this->layoutOn->layoutId . '"', $schedule, 'Layout not scheduled');
// Call Required Files
$rf = $this->getXmdsWrapper()->RequiredFiles($this->display2->license);
// Get XML string for player
$xmlString = $this->getXmdsWrapper()->GetFile($this->display2->license, $this->layoutOn->layoutId, 'layout', 0, 0);
// Layout enable stat 1
$this->assertContains('<layout width="1920" height="1080" bgcolor="#000" schemaVersion="3" enableStat="1">', $xmlString );
// Layout On, Media On, Widget Off, Output => [1, 'On', 'Off', 0],
$this->assertContains('<media id="'.$this->widgetId2.'" type="video" render="native" duration="10" useDuration="1" fromDt="1970-01-01 01:00:00" toDt="2038-01-19 03:14:07" enableStat="0" fileId="'.$this->media->mediaId.'">', $xmlString );
}
}

View File

@@ -0,0 +1,294 @@
<?php
/*
* Copyright (C) 2025 Xibo Signage Ltd
*
* Xibo - Digital Signage - https://xibosignage.com
*
* 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\Helper\Random;
use Xibo\OAuth2\Client\Entity\XiboDisplay;
use Xibo\OAuth2\Client\Entity\XiboLayout;
use Xibo\OAuth2\Client\Entity\XiboLibrary;
use Xibo\OAuth2\Client\Entity\XiboPlaylist;
use Xibo\OAuth2\Client\Entity\XiboRegion;
use Xibo\OAuth2\Client\Entity\XiboSchedule;
use Xibo\OAuth2\Client\Entity\XiboTicker;
use Xibo\Tests\Helper\DisplayHelperTrait;
use Xibo\Tests\Helper\LayoutHelperTrait;
use Xibo\Tests\LocalWebTestCase;
/**
* Class LayoutProofOfPlayXMLMediaOnWidgetOnTest
* @package Xibo\Tests\integration\Cache
*/
class LayoutProofOfPlayXMLMediaOnWidgetOnTest extends LocalWebTestCase
{
use LayoutHelperTrait;
use DisplayHelperTrait;
/** @var XiboLayout */
protected $layoutOff;
/** @var XiboLayout */
protected $layoutOn;
/** @var XiboRegion */
protected $region;
/** @var XiboDisplay */
protected $display;
/** @var XiboDisplay */
protected $display2;
/** @var XiboTicker */
protected $widget;
/** @var XiboLibrary */
protected $media;
/** @var XiboLibrary */
protected $mediaOn;
protected $widgetId;
protected $widgetId2;
// <editor-fold desc="Init">
public function setup()
{
parent::setup();
$this->getLogger()->debug('Setup test for ' . get_class($this) .' Test');
// Set global widget enable stat set to On
self::$container->get('configService')->changeSetting('WIDGET_STATS_ENABLED_DEFAULT', 'On');
$this->getStore()->commitIfNecessary();
// Create a Layout with enableStat Off (by default)
$this->layoutOff = $this->createLayout();
$layoutOff = $this->getDraft($this->layoutOff);
// Upload some media - enableStat is Inherit (from global media stat setting)
$this->media = (new XiboLibrary($this->getEntityProvider()))->create(
Random::generateString(8, 'API Video'),
PROJECT_ROOT . '/tests/resources/HLH264.mp4'
);
// Edit the media to set enableStat On
$this->media->edit(
$this->media->name,
$this->media->duration,
$this->media->retired,
$this->media->tags,
$this->media->updateInLayouts,
'On'
);
// Assign the media we've edited to our regions playlist- widget with Inherit (from global widget stat setting)
$playlist = (new XiboPlaylist($this->getEntityProvider()))
->assign([$this->media->mediaId], 10, $layoutOff->regions[0]->regionPlaylist->playlistId);
// Store the widgetId
$this->widgetId = $playlist->widgets[0]->widgetId;
// 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()->addSeconds(3600)->format(DateFormatHelper::getSystemFormat()),
Carbon::now()->addSeconds(7200)->format(DateFormatHelper::getSystemFormat()),
$this->layoutOff->campaignId,
[$this->display->displayGroupId],
0,
NULL,
NULL,
NULL,
0,
0,
0
);
$this->displaySetStatus($this->display, Display::$STATUS_DONE);
$this->displaySetLicensed($this->display);
// Create a layout with enableStat On
$this->layoutOn = (new XiboLayout($this->getEntityProvider()))->create(
Random::generateString(8, 'phpunit'),
'phpunit description',
'',
$this->getResolutionId('landscape'),
1
);
$layoutOn = $this->getDraft($this->layoutOn);
// Assign the media we've created to our regions playlist- widget with Inherit (from global widget stat setting)
$playlist2 = (new XiboPlaylist($this->getEntityProvider()))
->assign([$this->media->mediaId], 10, $layoutOn->regions[0]->regionPlaylist->playlistId);
// Store the widgetId
$this->widgetId2 = $playlist2->widgets[0]->widgetId;
// Create a Display2
$this->display2 = $this->createDisplay();
// Schedule the LayoutOn "always" onto our display
// deleting the layoutOn will remove this at the end
$event2 = (new XiboSchedule($this->getEntityProvider()))->createEventLayout(
Carbon::now()->addSeconds(3600)->format(DateFormatHelper::getSystemFormat()),
Carbon::now()->addSeconds(7200)->format(DateFormatHelper::getSystemFormat()),
$this->layoutOn->campaignId,
[$this->display2->displayGroupId],
0,
NULL,
NULL,
NULL,
0,
0,
0
);
$this->displaySetStatus($this->display2, Display::$STATUS_DONE);
$this->displaySetLicensed($this->display2);
$this->getLogger()->debug('Finished Setup');
}
public function tearDown()
{
$this->getLogger()->debug('Tear Down');
// Delete the LayoutOn
$this->deleteLayout($this->layoutOff);
// Delete the Display2
$this->deleteDisplay($this->display);
// Delete the LayoutOn
$this->deleteLayout($this->layoutOn);
// Delete the Display2
$this->deleteDisplay($this->display2);
// Delete the media record
$this->media->deleteAssigned();
// Set global widget enable stat set to Inherit
self::$container->get('configService')->changeSetting('WIDGET_STATS_ENABLED_DEFAULT', 'Inherit');
$this->getStore()->commitIfNecessary();
parent::tearDown();
}
// </editor-fold>
// Logic Table
//
// Widget With Media
// LAYOUT MEDIA WIDGET Media stats collected?
// ON ON ON YES Widget takes precedence // Match - 1
// ON OFF ON YES Widget takes precedence // Match - 1
// ON INHERIT ON YES Widget takes precedence // Match - 1
//
// OFF ON ON YES Widget takes precedence // Match - 1
// OFF OFF ON YES Widget takes precedence // Match - 1
// OFF INHERIT ON YES Widget takes precedence // Match - 1
//
// ON ON OFF NO Widget takes precedence // Match - 2
// ON OFF OFF NO Widget takes precedence // Match - 2
// ON INHERIT OFF NO Widget takes precedence // Match - 2
//
// OFF ON OFF NO Widget takes precedence // Match - 2
// OFF OFF OFF NO Widget takes precedence // Match - 2
// OFF INHERIT OFF NO Widget takes precedence // Match - 2
//
// ON ON INHERIT YES Media takes precedence // Match - 3
// ON OFF INHERIT NO Media takes precedence // Match - 4
// ON INHERIT INHERIT YES Media takes precedence and Inherited from Layout // Match - 5
//
// OFF ON INHERIT YES Media takes precedence // Match - 3
// OFF OFF INHERIT NO Media takes precedence // Match - 4
// OFF INHERIT INHERIT NO Media takes precedence and Inherited from Layout // Match - 6
////
public function testLayoutOff()
{
// Publish layout
$response = $this->sendRequest('PUT','/layout/publish/' . $this->layoutOff->layoutId, [
'publishNow' => 1
], ['CONTENT_TYPE' => 'application/x-www-form-urlencoded']);
$response = json_decode($response->getBody(), true);
$this->layoutOff = $this->constructLayoutFromResponse($response['data']);
// Confirm our Layout is in the Schedule
$schedule = $this->getXmdsWrapper()->Schedule($this->display->license);
$this->assertContains('file="' . $this->layoutOff->layoutId . '"', $schedule, 'Layout not scheduled');
// Call Required Files
$rf = $this->getXmdsWrapper()->RequiredFiles($this->display->license);
// Get XML string for player
$xmlString = $this->getXmdsWrapper()->GetFile($this->display->license, $this->layoutOff->layoutId, 'layout', 0, 0);
// Layout enable stat 0
$this->assertContains('<layout width="1920" height="1080" bgcolor="#000" schemaVersion="3" enableStat="0">', $xmlString );
// Layout Off, Media On, Widget On, Output => [0, 'On', 'On', 1],
$this->assertContains('<media id="'.$this->widgetId.'" type="video" render="native" duration="10" useDuration="1" fromDt="1970-01-01 01:00:00" toDt="2038-01-19 03:14:07" enableStat="1" fileId="'.$this->media->mediaId.'">', $xmlString );
}
public function testLayoutOn()
{
// Publish layout
$response = $this->sendRequest('PUT','/layout/publish/' . $this->layoutOn->layoutId, [
'publishNow' => 1
], ['CONTENT_TYPE' => 'application/x-www-form-urlencoded']);
$response = json_decode($response->getBody(), true);
$this->layoutOn = $this->constructLayoutFromResponse($response['data']);
// Confirm our Layout is in the Schedule
$schedule = $this->getXmdsWrapper()->Schedule($this->display2->license);
$this->assertContains('file="' . $this->layoutOn->layoutId . '"', $schedule, 'Layout not scheduled');
// Call Required Files
$rf = $this->getXmdsWrapper()->RequiredFiles($this->display2->license);
// Get XML string for player
$xmlString = $this->getXmdsWrapper()->GetFile($this->display2->license, $this->layoutOn->layoutId, 'layout', 0, 0);
// Layout enable stat 1
$this->assertContains('<layout width="1920" height="1080" bgcolor="#000" schemaVersion="3" enableStat="1">', $xmlString );
// Layout On, Media On, Widget On, Output => [1, 'On', 'On', 1],
$this->assertContains('<media id="'.$this->widgetId2.'" type="video" render="native" duration="10" useDuration="1" fromDt="1970-01-01 01:00:00" toDt="2038-01-19 03:14:07" enableStat="1" fileId="'.$this->media->mediaId.'">', $xmlString );
}
}

View File

@@ -0,0 +1,280 @@
<?php
/*
* Copyright (C) 2025 Xibo Signage Ltd
*
* Xibo - Digital Signage - https://xibosignage.com
*
* 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\Helper\Random;
use Xibo\OAuth2\Client\Entity\XiboDisplay;
use Xibo\OAuth2\Client\Entity\XiboLayout;
use Xibo\OAuth2\Client\Entity\XiboRegion;
use Xibo\OAuth2\Client\Entity\XiboSchedule;
use Xibo\OAuth2\Client\Entity\XiboText;
use Xibo\OAuth2\Client\Entity\XiboTicker;
use Xibo\Tests\Helper\DisplayHelperTrait;
use Xibo\Tests\Helper\LayoutHelperTrait;
use Xibo\Tests\LocalWebTestCase;
/**
* Class LayoutProofOfPlayXMLWithoutMediaTest
* @package Xibo\Tests\integration\Cache
*/
class LayoutProofOfPlayXMLWithoutMediaTest extends LocalWebTestCase
{
use LayoutHelperTrait;
use DisplayHelperTrait;
/** @var XiboLayout */
protected $layoutOff;
/** @var XiboLayout */
protected $layoutOn;
/** @var XiboRegion */
protected $region;
/** @var XiboDisplay */
protected $display;
/** @var XiboDisplay */
protected $display2;
/** @var XiboTicker */
protected $widget;
protected $media;
protected $widgetId2;
// <editor-fold desc="Init">
public function setup()
{
parent::setup();
$this->getLogger()->debug('Setup test for ' . get_class($this) .' Test');
// Create a Layout with enableStat Off (by default)
$this->layoutOff = $this->createLayout();
// Create a Display
$this->display = $this->createDisplay();
// Schedule the Layout "always" onto our display
// deleting the layoutOff will remove this at the end
$event = (new XiboSchedule($this->getEntityProvider()))->createEventLayout(
Carbon::now()->addSeconds(3600)->format(DateFormatHelper::getSystemFormat()),
Carbon::now()->addSeconds(7200)->format(DateFormatHelper::getSystemFormat()),
$this->layoutOff->campaignId,
[$this->display->displayGroupId],
0,
NULL,
NULL,
NULL,
0,
0,
0
);
$this->displaySetStatus($this->display, Display::$STATUS_DONE);
$this->displaySetLicensed($this->display);
// Create a layout with enableStat On
$this->layoutOn = (new XiboLayout($this->getEntityProvider()))->create(
Random::generateString(8, 'phpunit'),
'phpunit description',
'',
$this->getResolutionId('landscape'),
1
);
// Create a Display2
$this->display2 = $this->createDisplay();
// Schedule the LayoutOn "always" onto our display
// deleting the layoutOn will remove this at the end
$event2 = (new XiboSchedule($this->getEntityProvider()))->createEventLayout(
Carbon::now()->addSeconds(3600)->format(DateFormatHelper::getSystemFormat()),
Carbon::now()->addSeconds(7200)->format(DateFormatHelper::getSystemFormat()),
$this->layoutOn->campaignId,
[$this->display2->displayGroupId],
0,
NULL,
NULL,
NULL,
0,
0,
0
);
$this->displaySetStatus($this->display2, Display::$STATUS_DONE);
$this->displaySetLicensed($this->display2);
$this->getLogger()->debug('Finished Setup');
}
public function tearDown()
{
$this->getLogger()->debug('Tear Down');
// Delete the LayoutOff
$this->deleteLayout($this->layoutOff);
// Delete the Display
$this->deleteDisplay($this->display);
// Delete the LayoutOn
$this->deleteLayout($this->layoutOn);
// Delete the Display2
$this->deleteDisplay($this->display2);
parent::tearDown();
}
// </editor-fold>
// Logic Table
//
// Widget Without Media
// LAYOUT WIDGET Widget stats collected?
// ON ON YES Widget takes precedence // Match - 1
// ON OFF NO Widget takes precedence // Match - 2
// ON INHERIT YES Inherited from Layout // Match - 7
// OFF ON YES Widget takes precedence // Match - 1
// OFF OFF NO Widget takes precedence // Match - 2
// OFF INHERIT NO Inherited from Layout // Match - 8
/**
* Each array is a test run
* Format (enableStat)
* @return array
*/
public function layoutEnableStatOffCases()
{
return [
// Layout enableStat Off options - for layout and widget and their expected result (Widget stats collected?) in enableStat (media node attribute)
'Layout Off Media On' => [0, 'On', 1],
'Layout Off Media Off' => [0, 'Off', 0],
'Layout Off Media Inherit' => [0, 'Inherit', 0]
];
}
/**
* Each array is a test run
* Format (enableStat)
* @return array
*/
public function layoutEnableStatOnCases()
{
return [
// Layout enableStat On options - for layout and widget and their expected result (Widget stats collected?) in enableStat (media node attribute)
'Layout On Media On' => [1, 'On', 1],
'Layout On Media Off' => [1, 'Off', 0],
'Layout On Media Inherit' => [1, 'Inherit', 1]
];
}
/**
* Edit
* @dataProvider layoutEnableStatOffCases
*/
public function testLayoutOff($layoutEnableStat, $widgetEnableStat, $outputEnableStat)
{
// Checkout
$layoutOff = $this->getDraft($this->layoutOff);
$response = $this->getEntityProvider()->post('/playlist/widget/text/' . $layoutOff->regions[0]->regionPlaylist->playlistId);
$response = $this->getEntityProvider()->put('/playlist/widget/' . $response['widgetId'] , [
'text' => 'Widget A',
'duration' => 100,
'useDuration' => 1,
'enableStat' => $widgetEnableStat
]);
$this->widget = (new XiboText($this->getEntityProvider()))->hydrate($response);
// Publish layout
$response = $this->sendRequest('PUT','/layout/publish/' . $this->layoutOff->layoutId, [
'publishNow' => 1
], ['CONTENT_TYPE' => 'application/x-www-form-urlencoded']);
$response = json_decode($response->getBody(), true);
$this->layoutOff = $this->constructLayoutFromResponse($response['data']);
$this->getLogger()->debug($this->layoutOff->enableStat);
// Confirm our Layout is in the Schedule
$schedule = $this->getXmdsWrapper()->Schedule($this->display->license);
$this->assertContains('file="' . $this->layoutOff->layoutId . '"', $schedule, 'Layout not scheduled');
// Call Required Files
$rf = $this->getXmdsWrapper()->RequiredFiles($this->display->license);
// Get XML string for player
$xmlString = $this->getXmdsWrapper()->GetFile($this->display->license, $this->layoutOff->layoutId, 'layout', 0, 0);
$this->assertContains('<layout width="1920" height="1080" bgcolor="#000" schemaVersion="3" enableStat="'.$layoutEnableStat.'">', $xmlString );
$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 );
}
/**
* Edit
* @dataProvider layoutEnableStatOnCases
*/
public function testLayoutOn($layoutEnableStat, $widgetEnableStat, $outputEnableStat)
{
// Checkout
$layoutOn = $this->getDraft($this->layoutOn);
$response = $this->getEntityProvider()->post('/playlist/widget/text/' . $layoutOn->regions[0]->regionPlaylist->playlistId);
$response = $this->getEntityProvider()->put('/playlist/widget/' . $response['widgetId'] , [
'text' => 'Widget A',
'duration' => 100,
'useDuration' => 1,
'enableStat' => $widgetEnableStat
]);
$this->widget = (new XiboText($this->getEntityProvider()))->hydrate($response);
// Publish layout
$response = $this->sendRequest('PUT','/layout/publish/' . $this->layoutOn->layoutId, [
'publishNow' => 1
], ['CONTENT_TYPE' => 'application/x-www-form-urlencoded']);
$response = json_decode($response->getBody(), true);
$this->layoutOn = $this->constructLayoutFromResponse($response['data']);
$this->getLogger()->debug($this->layoutOn->enableStat);
// Confirm our Layout is in the Schedule
$schedule = $this->getXmdsWrapper()->Schedule($this->display2->license);
$this->assertContains('file="' . $this->layoutOn->layoutId . '"', $schedule, 'Layout not scheduled');
// Call Required Files
$rf = $this->getXmdsWrapper()->RequiredFiles($this->display2->license);
// Get XML string for player
$xmlString = $this->getXmdsWrapper()->GetFile($this->display2->license, $this->layoutOn->layoutId, 'layout', 0, 0);
$this->assertContains('<layout width="1920" height="1080" bgcolor="#000" schemaVersion="3" enableStat="'.$layoutEnableStat.'">', $xmlString );
$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 );
}
}

View File

@@ -0,0 +1,109 @@
<?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\Tests\Helper\DisplayHelperTrait;
use Xibo\Tests\Helper\LayoutHelperTrait;
use Xibo\Tests\LocalWebTestCase;
class LayoutRetireTest extends LocalWebTestCase
{
use LayoutHelperTrait;
use DisplayHelperTrait;
/** @var XiboLayout */
protected $layout;
/** @var XiboDisplay */
protected $display;
// <editor-fold desc="Init">
public function setup()
{
parent::setup();
$this->getLogger()->debug('Setup test for Cache Layout Retire Test');
// Create a Layout
$this->layout = $this->createLayout(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()
{
// Retire the Layout we've got created for us.
$this->sendRequest('PUT','/layout/retire/' . $this->layout->layoutId, [], ['CONTENT_TYPE' => 'application/x-www-form-urlencoded']);
// Validate the layout status
$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');
// Somehow test that we have issued an XMR request
$this->assertTrue(in_array($this->display->displayId, $this->getPlayerActionQueue()), 'Player action not present');
}
}

View File

@@ -0,0 +1,146 @@
<?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\Helper\Random;
use Xibo\OAuth2\Client\Entity\XiboDisplay;
use Xibo\OAuth2\Client\Entity\XiboLayout;
use Xibo\OAuth2\Client\Entity\XiboLibrary;
use Xibo\OAuth2\Client\Entity\XiboPlaylist;
use Xibo\OAuth2\Client\Entity\XiboSchedule;
use Xibo\Tests\Helper\DisplayHelperTrait;
use Xibo\Tests\Helper\LayoutHelperTrait;
use Xibo\Tests\LocalWebTestCase;
/**
* Class LibraryReviseTest
*
* Tests whether a Layout Edit updates the Cache Appropriately
*
* @package integration\Cache
*/
class LibraryReviseTest extends LocalWebTestCase
{
use LayoutHelperTrait;
use DisplayHelperTrait;
/** @var XiboLibrary */
protected $media;
/** @var XiboLayout */
protected $layout;
/** @var XiboDisplay */
protected $display;
// <editor-fold desc="Init">
public function setup()
{
parent::setup();
$this->getLogger()->debug('Setup test for Cache Layout Edit Test');
// Upload some media
$this->media = (new XiboLibrary($this->getEntityProvider()))
->create(Random::generateString(), PROJECT_ROOT . '/tests/resources/xts-flowers-001.jpg');
// Create a Layout
$this->layout = $this->createLayout(1);
// Checkout
$layout = $this->getDraft($this->layout);
// Add it to the Layout
(new XiboPlaylist($this->getEntityProvider()))->assign([$this->media->mediaId], 10, $layout->regions[0]->regionPlaylist->playlistId);
// Publish
$this->layout = $this->publish($this->layout);
// Set the Layout status (force it)
$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);
$this->getLogger()->debug('Finished setup');
}
public function tearDown()
{
parent::tearDown();
// Delete the Layout we've been working with
$this->deleteLayout($this->layout);
// Delete the media record
$this->media->deleteAssigned();
// Delete the Display
$this->deleteDisplay($this->display);
}
// </editor-fold>
/**
* @group cacheInvalidateTests
*/
public function testInvalidateCache()
{
// Make sure we're in good condition to start
$this->assertTrue($this->displayStatusEquals($this->display, Display::$STATUS_DONE), 'Display Status isnt as expected');
$this->assertTrue($this->layoutStatusEquals($this->layout, 1), 'Layout status is not as expected');
// Replace the Media
$this->media = (new XiboLibrary($this->getEntityProvider()))
->create(Random::generateString(), PROJECT_ROOT . '/tests/resources/xts-flowers-002.jpg', $this->media->mediaId, 1, 1);
// Validate the layout status afterwards
$this->assertTrue($this->layoutStatusEquals($this->layout, 3), 'Layout Status isnt as expected');
// Validate the display status afterwards
$this->assertTrue($this->displayStatusEquals($this->display, Display::$STATUS_DONE), 'Display Status isnt as expected');
}
}

View File

@@ -0,0 +1,157 @@
<?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');
}
}

View File

@@ -0,0 +1,141 @@
<?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\XiboRegion;
use Xibo\OAuth2\Client\Entity\XiboSchedule;
use Xibo\Tests\Helper\DisplayHelperTrait;
use Xibo\Tests\Helper\LayoutHelperTrait;
use Xibo\Tests\LocalWebTestCase;
/**
* Class RegionDeleteTest
* @package Xibo\Tests\integration\Cache
*/
class RegionDeleteTest extends LocalWebTestCase
{
use LayoutHelperTrait;
use DisplayHelperTrait;
/** @var XiboLayout */
protected $layout;
/** @var XiboRegion */
protected $region;
/** @var XiboDisplay */
protected $display;
// <editor-fold desc="Init">
public function setup()
{
parent::setup();
$this->getLogger()->debug('Setup test for Cache Region Delete Test');
// Create a Layout
$this->layout = $this->createLayout();
// Checkout
$layout = $this->getDraft($this->layout);
// Add a widget to the existing 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
]);
// Add a region to the Layout
$this->region = (new XiboRegion($this->getEntityProvider()))->create($layout->layoutId, 200,300,75,125);
// 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()
{
// Edit region
$this->sendRequest('DELETE','/region/' . $this->region->regionId);
// This shouldn't effect the display
$this->assertTrue($this->displayStatusEquals($this->display, Display::$STATUS_DONE), 'Display Status isnt as expected');
// Checkin
$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');
// Somehow test that we have issued an XMR request
$this->assertFalse(in_array($this->display->displayId, $this->getPlayerActionQueue()), 'Player action not present');
}
}

View File

@@ -0,0 +1,144 @@
<?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\XiboRegion;
use Xibo\OAuth2\Client\Entity\XiboSchedule;
use Xibo\Tests\Helper\DisplayHelperTrait;
use Xibo\Tests\Helper\LayoutHelperTrait;
use Xibo\Tests\LocalWebTestCase;
/**
* Class RegionEditTest
* @package Xibo\Tests\integration\Cache
*/
class RegionEditTest extends LocalWebTestCase
{
use LayoutHelperTrait;
use DisplayHelperTrait;
/** @var XiboLayout */
protected $layout;
/** @var XiboRegion */
protected $region;
/** @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 widget to the existing 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
]);
// 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()
{
// Edit region
$this->sendRequest('PUT','/region/' . $this->layout->regions[0]->regionId, [
'width' => 700,
'height' => 500,
'top' => 400,
'left' => 400,
'loop' => 0,
'zIndex' => 1
], ['CONTENT_TYPE' => 'application/x-www-form-urlencoded']);
$this->assertTrue($this->displayStatusEquals($this->display, Display::$STATUS_DONE), 'Display Status isnt as expected');
// Checkin
$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');
// Somehow test that we have issued an XMR request
$this->assertFalse(in_array($this->display->displayId, $this->getPlayerActionQueue()), 'Player action not present');
}
}

View File

@@ -0,0 +1,159 @@
<?php
/*
* Copyright (C) 2025 Xibo Signage Ltd
*
* Xibo - Digital Signage - https://xibosignage.com
*
* 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\OAuth2\Client\Entity\XiboTicker;
use Xibo\Tests\Helper\DisplayHelperTrait;
use Xibo\Tests\Helper\LayoutHelperTrait;
use Xibo\Tests\LocalWebTestCase;
/**
* Class ScheduleChangeInsideRfTest
* @package Xibo\Tests\integration\Cache
*/
class ScheduleChangeInsideRfTest extends LocalWebTestCase
{
use LayoutHelperTrait;
use DisplayHelperTrait;
/** @var XiboLayout */
protected $layout;
/** @var XiboDisplay */
protected $display;
/** @var XiboTicker */
protected $widget;
/** @var XiboSchedule */
protected $event;
// <editor-fold desc="Init">
public function setup()
{
parent::setup();
$this->getLogger()->debug('Setup test for Cache ' . get_class($this) .' Test');
// Create a Layout
$this->layout = $this->createLayout();
// Checkout
$layout = $this->getDraft($this->layout);
$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
]);
// Check us in again
$this->layout = $this->publish($this->layout);
$this->widget = (new XiboText($this->getEntityProvider()))->hydrate($response);
// Build the layout
$this->buildLayout($this->layout);
// Create a Display
$this->display = $this->createDisplay();
// Schedule the Layout "always" onto our display
// deleting the layout will remove this at the end
$this->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);
$this->displaySetLicensed($this->display);
$this->getLogger()->debug('Finished Setup');
}
public function tearDown()
{
$this->getLogger()->debug('Tear Down');
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()
{
// Make sure our Layout is already status 1
$this->assertTrue($this->layoutStatusEquals($this->layout, 1), 'Layout Status isnt as expected');
// Make sure our Display is already DONE
$this->assertTrue($this->displayStatusEquals($this->display, Display::$STATUS_DONE), 'Display Status isnt as expected');
// Change the Schedule
$response = $this->sendRequest('PUT','/schedule/' . $this->event->eventId, [
'fromDt' => Carbon::createFromTimestamp($this->event->fromDt)->format(DateFormatHelper::getSystemFormat()),
'toDt' => Carbon::createFromTimestamp($this->event->toDt)->format(DateFormatHelper::getSystemFormat()),
'eventTypeId' => 1,
'campaignId' => $this->event->campaignId,
'displayGroupIds' => [$this->display->displayGroupId],
'displayOrder' => 1,
'isPriority' => 1
], ['CONTENT_TYPE' => 'application/x-www-form-urlencoded']);
$this->assertSame(200, $response->getStatusCode(), $response->getBody());
// 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');
// Validate that XMR has been called.
$this->assertTrue(in_array($this->display->displayId, $this->getPlayerActionQueue()), 'Player action not present');
}
}

View File

@@ -0,0 +1,161 @@
<?php
/*
* Copyright (C) 2025 Xibo Signage Ltd
*
* Xibo - Digital Signage - https://xibosignage.com
*
* 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\OAuth2\Client\Entity\XiboTicker;
use Xibo\Tests\Helper\DisplayHelperTrait;
use Xibo\Tests\Helper\LayoutHelperTrait;
use Xibo\Tests\LocalWebTestCase;
/**
* Class ScheduleChangeOutsideRfTest
* @package Xibo\Tests\integration\Cache
*/
class ScheduleChangeOutsideRfTest extends LocalWebTestCase
{
use LayoutHelperTrait;
use DisplayHelperTrait;
/** @var XiboLayout */
protected $layout;
/** @var XiboDisplay */
protected $display;
/** @var XiboTicker */
protected $widget;
/** @var XiboSchedule */
protected $event;
// <editor-fold desc="Init">
public function setup()
{
parent::setup();
$this->getLogger()->debug('Setup test for Cache ' . get_class($this) .' Test');
// Create a Layout
$this->layout = $this->createLayout();
// Checkout
$layout = $this->getDraft($this->layout);
$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
]);
// Check us in again
$this->layout = $this->publish($this->layout);
$this->widget = (new XiboText($this->getEntityProvider()))->hydrate($response);
// Build the layout
$this->buildLayout($this->layout);
// Create a Display
$this->display = $this->createDisplay();
// Dates outside of RF
$date = Carbon::now()->addMonth();
// Schedule the Layout "always" onto our display
// deleting the layout will remove this at the end
$this->event = (new XiboSchedule($this->getEntityProvider()))->createEventLayout(
$date->format(DateFormatHelper::getSystemFormat()),
$date->addHour()->format(DateFormatHelper::getSystemFormat()),
$this->layout->campaignId,
[$this->display->displayGroupId],
0,
NULL,
NULL,
NULL,
0,
0,
0
);
$this->displaySetStatus($this->display, Display::$STATUS_DONE);
$this->displaySetLicensed($this->display);
$this->getLogger()->debug('Finished Setup');
}
public function tearDown()
{
$this->getLogger()->debug('Tear Down');
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()
{
// Make sure our Layout is already status 1
$this->assertTrue($this->layoutStatusEquals($this->layout, 1), 'Layout Status isnt as expected');
// Make sure our Display is already DONE
$this->assertTrue($this->displayStatusEquals($this->display, Display::$STATUS_DONE), 'Display Status isnt as expected');
// Change the Schedule
$this->sendRequest('PUT','/schedule/' . $this->event->eventId, [
'fromDt' => date(DateFormatHelper::getSystemFormat(), $this->event->fromDt),
'toDt' => date(DateFormatHelper::getSystemFormat(), $this->event->toDt),
'eventTypeId' => 1,
'campaignId' => $this->event->campaignId,
'displayGroupIds' => [$this->display->displayGroupId],
'displayOrder' => 1,
'isPriority' => 1
], ['CONTENT_TYPE' => 'application/x-www-form-urlencoded']);
// 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_DONE), 'Display Status isnt as expected');
// Validate that XMR has been called.
$this->assertFalse(in_array($this->display->displayId, $this->getPlayerActionQueue()), 'Player action not present');
}
}

View File

@@ -0,0 +1,145 @@
<?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 WidgetDeleteTest
* @package Xibo\Tests\integration\Cache
*/
class WidgetDeleteTest extends LocalWebTestCase
{
use LayoutHelperTrait;
use DisplayHelperTrait;
/** @var XiboLayout */
protected $layout;
protected $widget;
/** @var XiboDisplay */
protected $display;
// <editor-fold desc="Init">
public function setup()
{
parent::setup();
$this->getLogger()->debug('Setup test for Cache Region Delete Test');
// Create a Layout
$this->layout = $this->createLayout();
// Checkout
$layout = $this->getDraft($this->layout);
$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
]);
$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->widget = (new XiboText($this->getEntityProvider()))->hydrate($response);
// 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()
{
// Edit region
$response = $this->sendRequest('DELETE','/playlist/widget/' . $this->widget->widgetId);
$this->assertEquals(200, $response->getStatusCode(), 'Transaction Status Incorrect');
$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');
// Somehow test that we have issued an XMR request
$this->assertFalse(in_array($this->display->displayId, $this->getPlayerActionQueue()), 'Player action not present');
}
}

View File

@@ -0,0 +1,142 @@
<?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 WidgetEditTest
* @package Xibo\Tests\integration\Cache
*/
class WidgetEditTest extends LocalWebTestCase
{
use LayoutHelperTrait;
use DisplayHelperTrait;
/** @var XiboLayout */
protected $layout;
protected $widget;
/** @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);
$response = $this->getEntityProvider()->post('/playlist/widget/text/' . $layout->regions[0]->regionPlaylist->playlistId, [
'text' => 'Widget A',
'duration' => 100,
'useDuration' => 1
]);
$this->widget = (new XiboText($this->getEntityProvider()))->hydrate($response);
// 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()
{
// Edit region
$response = $this->sendRequest('PUT','/playlist/widget/' . $this->widget->widgetId, [
'text' => 'Edited Text',
'duration' => 100,
'useDuration' => 1
], ['CONTENT_TYPE' => 'application/x-www-form-urlencoded']);
$this->assertEquals(200, $response->getStatusCode(), 'Transaction Status Incorrect');
$this->assertTrue($this->displayStatusEquals($this->display, Display::$STATUS_DONE), 'Display Status isnt as expected');
// Check us in again
$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');
// Somehow test that we have issued an XMR request
$this->assertFalse(in_array($this->display->displayId, $this->getPlayerActionQueue()), 'Player action not present');
}
}