~xibo-maintainers/xibo/tempel

« back to all changes in this revision

Viewing changes to tests/integration/Cache/DataSetDataEditTest.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
 
 * (DataSetDataEditTest.php)
6
 
 */
7
 
 
8
 
 
9
 
namespace Xibo\Tests\integration\Cache;
10
 
 
11
 
 
12
 
use Xibo\Entity\DataSetColumn;
13
 
use Xibo\Entity\Display;
14
 
use Xibo\Helper\Random;
15
 
use Xibo\OAuth2\Client\Entity\XiboDataSet;
16
 
use Xibo\OAuth2\Client\Entity\XiboDataSetColumn;
17
 
use Xibo\OAuth2\Client\Entity\XiboDataSetView;
18
 
use Xibo\OAuth2\Client\Entity\XiboDisplay;
19
 
use Xibo\OAuth2\Client\Entity\XiboLayout;
20
 
use Xibo\OAuth2\Client\Entity\XiboSchedule;
21
 
use Xibo\OAuth2\Client\Entity\XiboWidget;
22
 
use Xibo\Tests\Helper\DisplayHelperTrait;
23
 
use Xibo\Tests\Helper\LayoutHelperTrait;
24
 
use Xibo\Tests\LocalWebTestCase;
25
 
 
26
 
/**
27
 
 * Class DataSetDataEditTest
28
 
 * @package Xibo\Tests\integration\Cache
29
 
 */
30
 
class DataSetDataEditTest extends LocalWebTestCase
31
 
{
32
 
    use LayoutHelperTrait;
33
 
    use DisplayHelperTrait;
34
 
 
35
 
    /** @var XiboDataSet */
36
 
    protected $dataSet;
37
 
 
38
 
    /** @var DataSetColumn */
39
 
    protected $dataSetColumn;
40
 
 
41
 
    /** @var XiboLayout */
42
 
    protected $layout;
43
 
 
44
 
    /** @var XiboWidget */
45
 
    protected $widget;
46
 
 
47
 
    /** @var XiboDisplay */
48
 
    protected $display;
49
 
 
50
 
    // <editor-fold desc="Init">
51
 
    public function setup()
52
 
    {
53
 
        parent::setup();
54
 
 
55
 
        $this->getLogger()->debug('Setup test for Cache ' . get_class() .' Test');
56
 
 
57
 
        // Add a DataSet
58
 
        $this->dataSet = (new XiboDataSet($this->getEntityProvider()))->create(Random::generateString(), 'Test');
59
 
 
60
 
        // Add a Column
61
 
        $this->dataSetColumn = (new XiboDataSetColumn($this->getEntityProvider()))->create($this->dataSet->dataSetId,
62
 
            Random::generateString(),
63
 
            '',
64
 
            1,
65
 
            1,
66
 
            1,
67
 
            '');
68
 
 
69
 
        // Create a Layout
70
 
        $this->layout = $this->createLayout();
71
 
 
72
 
        // Add a couple of text widgets to the region
73
 
        $response = $this->getEntityProvider()->post('/playlist/widget/datasetview/' . $this->layout->regions[0]->playlists[0]['playlistId'], [
74
 
            'name' => Random::generateString(),
75
 
            'dataSetId' => $this->dataSet->dataSetId,
76
 
            'duration' => 100,
77
 
            'useDuration' => 1
78
 
        ]);
79
 
 
80
 
        $this->widget = (new XiboDataSetView($this->getEntityProvider()))->hydrate($response);
81
 
 
82
 
        // Set the Layout status
83
 
        $this->setLayoutStatus($this->layout, 1);
84
 
 
85
 
        // Create a Display
86
 
        $this->display = $this->createDisplay();
87
 
 
88
 
        // Schedule the Layout "always" onto our display
89
 
        //  deleting the layout will remove this at the end
90
 
        $event = (new XiboSchedule($this->getEntityProvider()))->createEventLayout(
91
 
            date('Y-m-d H:i:s', time()+3600),
92
 
            date('Y-m-d H:i:s', time()+7200),
93
 
            $this->layout->campaignId,
94
 
            [$this->display->displayGroupId],
95
 
            0,
96
 
            NULL,
97
 
            NULL,
98
 
            NULL,
99
 
            0,
100
 
            0
101
 
        );
102
 
 
103
 
        $this->displaySetStatus($this->display, Display::$STATUS_DONE);
104
 
    }
105
 
 
106
 
    public function tearDown()
107
 
    {
108
 
        parent::tearDown();
109
 
 
110
 
        // Delete the Layout we've been working with
111
 
        $this->deleteLayout($this->layout);
112
 
 
113
 
        // Delete the DataSet
114
 
        $this->dataSet->deleteWData();
115
 
 
116
 
        // Delete the Display
117
 
        $this->deleteDisplay($this->display);
118
 
    }
119
 
    // </editor-fold>
120
 
 
121
 
    /**
122
 
     * @group cacheInvalidateTests
123
 
     */
124
 
    public function testInvalidateCache()
125
 
    {
126
 
        // Add Data to the DataSet
127
 
        $this->client->post('/dataset/data/'. $this->dataSet->dataSetId, [
128
 
            'dataSetColumnId_' . $this->dataSetColumn->dataSetColumnId => '1'
129
 
        ]);
130
 
 
131
 
        // Validate the display status afterwards
132
 
        $this->assertTrue($this->displayStatusEquals($this->display, Display::$STATUS_PENDING), 'Display Status isnt as expected');
133
 
 
134
 
        // Somehow test that we have issued an XMR request
135
 
        $this->assertTrue(in_array($this->display->displayId, $this->getPlayerActionQueue()), 'Player action not present');
136
 
    }
137
 
}
 
 
b'\\ No newline at end of file'