~xibo-maintainers/xibo/tempel

« back to all changes in this revision

Viewing changes to tests/integration/Cache/LayoutInCampaignStatusTest.php

  • Committer: Dan Garner
  • Date: 2015-03-26 14:08:33 UTC
  • Revision ID: git-v1:70d14044444f8dc5d602b99890d59dea46d9470c
Moved web servable files to web folder

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
<?php
2
 
/*
3
 
 * Spring Signage Ltd - http://www.springsignage.com
4
 
 * Copyright (C) 2017-18 Spring Signage Ltd
5
 
 * (LayoutInCampaignStatusTest.php)
6
 
 */
7
 
 
8
 
 
9
 
namespace Xibo\Tests\integration\Cache;
10
 
 
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;
23
 
 
24
 
/**
25
 
 * Class LayoutInCampaignStatusTest
26
 
 * @package Xibo\Tests\integration\Cache
27
 
 */
28
 
class LayoutInCampaignStatusTest extends LocalWebTestCase
29
 
{
30
 
    use LayoutHelperTrait;
31
 
    use DisplayHelperTrait;
32
 
 
33
 
    /** @var XiboCampaign */
34
 
    protected $campaign;
35
 
 
36
 
    /** @var XiboLayout */
37
 
    protected $layout;
38
 
 
39
 
    /** @var XiboRegion */
40
 
    protected $region;
41
 
 
42
 
    /** @var XiboDisplay */
43
 
    protected $display;
44
 
 
45
 
    /** @var XiboTicker */
46
 
    protected $widget;
47
 
 
48
 
    // <editor-fold desc="Init">
49
 
    public function setup()
50
 
    {
51
 
        parent::setup();
52
 
 
53
 
        $this->getLogger()->debug('Setup test for Cache ' . get_class() .' Test');
54
 
 
55
 
        // Create a Campaign
56
 
        $this->campaign = (new XiboCampaign($this->getEntityProvider()))->create(Random::generateString());
57
 
 
58
 
        // Create a Layout
59
 
        $this->layout = $this->createLayout();
60
 
 
61
 
        // Create a text widget on the Layout
62
 
        $response = $this->getEntityProvider()->post('/playlist/widget/text/' . $this->layout->regions[0]->playlists[0]['playlistId'], [
63
 
            'text' => 'Widget A',
64
 
            'duration' => 100,
65
 
            'useDuration' => 1
66
 
        ]);
67
 
 
68
 
        $this->widget = (new XiboText($this->getEntityProvider()))->hydrate($response);
69
 
 
70
 
        // Assign the layout to our campaign
71
 
        $this->campaign->assignLayout($this->layout->layoutId);
72
 
 
73
 
        // Create a Display
74
 
        $this->display = $this->createDisplay();
75
 
 
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],
83
 
            0,
84
 
            NULL,
85
 
            NULL,
86
 
            NULL,
87
 
            0,
88
 
            0
89
 
        );
90
 
 
91
 
        $this->displaySetStatus($this->display, Display::$STATUS_DONE);
92
 
        $this->displaySetLicensed($this->display);
93
 
 
94
 
        $this->getLogger()->debug('Finished Setup');
95
 
    }
96
 
 
97
 
    public function tearDown()
98
 
    {
99
 
        $this->getLogger()->debug('Tear Down');
100
 
 
101
 
        parent::tearDown();
102
 
 
103
 
        // Delete the Layout we've been working with
104
 
        $this->deleteLayout($this->layout);
105
 
 
106
 
        // Delete the Display
107
 
        $this->deleteDisplay($this->display);
108
 
 
109
 
        // Delete the Campaign
110
 
        $this->campaign->delete();
111
 
    }
112
 
    // </editor-fold>
113
 
 
114
 
    /**
115
 
     * @group cacheInvalidateTests
116
 
     */
117
 
    public function testInvalidateCache()
118
 
    {
119
 
        // Make sure our Layout is already status 1
120
 
        $this->assertTrue($this->layoutStatusEquals($this->layout, 3), 'Layout Status isnt as expected');
121
 
 
122
 
        // Make sure our Display is already DONE
123
 
        $this->assertTrue($this->displayStatusEquals($this->display, Display::$STATUS_DONE), 'Display Status isnt as expected');
124
 
 
125
 
        // Build the Layout
126
 
        $this->client->get('/layout/status/' . $this->layout->layoutId);
127
 
 
128
 
        // Check the Layout Status
129
 
        // Validate the layout status afterwards
130
 
        $this->assertTrue($this->layoutStatusEquals($this->layout, 1), 'Layout Status isnt as expected');
131
 
 
132
 
        // Validate the display status afterwards
133
 
        $this->assertTrue($this->displayStatusEquals($this->display, Display::$STATUS_PENDING), 'Display Status isnt as expected');
134
 
 
135
 
        // Validate that XMR has been called.
136
 
        $this->assertTrue(in_array($this->display->displayId, $this->getPlayerActionQueue()), 'Player action not present');
137
 
    }
138
 
}
 
 
b'\\ No newline at end of file'