3
* Spring Signage Ltd - http://www.springsignage.com
4
* Copyright (C) 2017-18 Spring Signage Ltd
5
* (LayoutInCampaignStatusTest.php)
9
namespace Xibo\Tests\integration\Cache;
11
use Xibo\Entity\Display;
12
use Xibo\Helper\Random;
13
use Xibo\OAuth2\Client\Entity\XiboCampaign;
14
use Xibo\OAuth2\Client\Entity\XiboDisplay;
15
use Xibo\OAuth2\Client\Entity\XiboLayout;
16
use Xibo\OAuth2\Client\Entity\XiboRegion;
17
use Xibo\OAuth2\Client\Entity\XiboSchedule;
18
use Xibo\OAuth2\Client\Entity\XiboText;
19
use Xibo\OAuth2\Client\Entity\XiboTicker;
20
use Xibo\Tests\Helper\DisplayHelperTrait;
21
use Xibo\Tests\Helper\LayoutHelperTrait;
22
use Xibo\Tests\LocalWebTestCase;
25
* Class LayoutInCampaignStatusTest
26
* @package Xibo\Tests\integration\Cache
28
class LayoutInCampaignStatusTest extends LocalWebTestCase
30
use LayoutHelperTrait;
31
use DisplayHelperTrait;
33
/** @var XiboCampaign */
36
/** @var XiboLayout */
39
/** @var XiboRegion */
42
/** @var XiboDisplay */
45
/** @var XiboTicker */
48
// <editor-fold desc="Init">
49
public function setup()
53
$this->getLogger()->debug('Setup test for Cache ' . get_class() .' Test');
56
$this->campaign = (new XiboCampaign($this->getEntityProvider()))->create(Random::generateString());
59
$this->layout = $this->createLayout();
61
// Create a text widget on the Layout
62
$response = $this->getEntityProvider()->post('/playlist/widget/text/' . $this->layout->regions[0]->playlists[0]['playlistId'], [
68
$this->widget = (new XiboText($this->getEntityProvider()))->hydrate($response);
70
// Assign the layout to our campaign
71
$this->campaign->assignLayout($this->layout->layoutId);
74
$this->display = $this->createDisplay();
76
// Schedule the Campaign "always" onto our display
77
// deleting the layout will remove this at the end
78
$event = (new XiboSchedule($this->getEntityProvider()))->createEventLayout(
79
date('Y-m-d H:i:s', time()+3600),
80
date('Y-m-d H:i:s', time()+7200),
81
$this->campaign->campaignId,
82
[$this->display->displayGroupId],
91
$this->displaySetStatus($this->display, Display::$STATUS_DONE);
92
$this->displaySetLicensed($this->display);
94
$this->getLogger()->debug('Finished Setup');
97
public function tearDown()
99
$this->getLogger()->debug('Tear Down');
103
// Delete the Layout we've been working with
104
$this->deleteLayout($this->layout);
106
// Delete the Display
107
$this->deleteDisplay($this->display);
109
// Delete the Campaign
110
$this->campaign->delete();
115
* @group cacheInvalidateTests
117
public function testInvalidateCache()
119
// Make sure our Layout is already status 1
120
$this->assertTrue($this->layoutStatusEquals($this->layout, 3), 'Layout Status isnt as expected');
122
// Make sure our Display is already DONE
123
$this->assertTrue($this->displayStatusEquals($this->display, Display::$STATUS_DONE), 'Display Status isnt as expected');
126
$this->client->get('/layout/status/' . $this->layout->layoutId);
128
// Check the Layout Status
129
// Validate the layout status afterwards
130
$this->assertTrue($this->layoutStatusEquals($this->layout, 1), 'Layout Status isnt as expected');
132
// Validate the display status afterwards
133
$this->assertTrue($this->displayStatusEquals($this->display, Display::$STATUS_PENDING), 'Display Status isnt as expected');
135
// Validate that XMR has been called.
136
$this->assertTrue(in_array($this->display->displayId, $this->getPlayerActionQueue()), 'Player action not present');
b'\\ No newline at end of file'