~xibo-maintainers/xibo/tempel

« back to all changes in this revision

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

  • Committer: Dan Garner
  • Date: 2017-12-27 14:42:37 UTC
  • mto: This revision was merged to the branch mainline in revision 596.
  • Revision ID: git-v1:411876aa7a88d59f940c02211330f64ef854e6ec
Begin some scaffolding for testing cache invalidation
xibosignage/xibo#1364

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 Spring Signage Ltd
 
5
 * (LayoutEditTest.php)
 
6
 */
 
7
 
 
8
 
 
9
namespace Xibo\Tests\integration\Cache;
 
10
 
 
11
 
 
12
use Xibo\Entity\Display;
 
13
use Xibo\OAuth2\Client\Entity\XiboDisplay;
 
14
use Xibo\OAuth2\Client\Entity\XiboLayout;
 
15
use Xibo\OAuth2\Client\Entity\XiboSchedule;
 
16
use Xibo\Tests\Helper\DisplayHelperTrait;
 
17
use Xibo\Tests\Helper\LayoutHelperTrait;
 
18
use Xibo\Tests\LocalWebTestCase;
 
19
 
 
20
/**
 
21
 * Class LayoutEditTest
 
22
 *
 
23
 * Tests whether a Layout Edit updates the Cache Appropriately
 
24
 *
 
25
 * @package integration\Cache
 
26
 */
 
27
class LayoutEditTest extends LocalWebTestCase
 
28
{
 
29
    use LayoutHelperTrait;
 
30
    use DisplayHelperTrait;
 
31
 
 
32
    /** @var XiboLayout */
 
33
    protected $layout;
 
34
 
 
35
    /** @var XiboDisplay */
 
36
    protected $display;
 
37
 
 
38
    // <editor-fold desc="Init">
 
39
    public function setup()
 
40
    {
 
41
        parent::setup();
 
42
 
 
43
        $this->getLogger()->debug('Setup test for Cache Layout Edit Test');
 
44
 
 
45
        // Create a Layout
 
46
        $this->layout = $this->createLayout(1);
 
47
 
 
48
        // Create a Display
 
49
        $this->display = $this->createDisplay();
 
50
 
 
51
        // Schedule the Layout "always" onto our display
 
52
        //  deleting the layout will remove this at the end
 
53
        $event = (new XiboSchedule($this->getEntityProvider()))->createEventLayout(
 
54
            date('Y-m-d H:i:s', time()+3600),
 
55
            date('Y-m-d H:i:s', time()+7200),
 
56
            $this->layout->campaignId,
 
57
            [$this->display->displayGroupId],
 
58
            0,
 
59
            NULL,
 
60
            NULL,
 
61
            NULL,
 
62
            0,
 
63
            0
 
64
        );
 
65
 
 
66
        $this->displaySetStatus($this->display, Display::$STATUS_DONE);
 
67
    }
 
68
 
 
69
    public function tearDown()
 
70
    {
 
71
        parent::tearDown();
 
72
 
 
73
        // Delete the Layout we've been working with
 
74
        $this->deleteLayout($this->layout);
 
75
 
 
76
        // Delete the Display
 
77
        $this->deleteDisplay($this->display);
 
78
    }
 
79
    // </editor-fold>
 
80
 
 
81
    /**
 
82
     * @group cacheInvalidateTests
 
83
     */
 
84
    public function testInvalidateCache()
 
85
    {
 
86
        // Make sure we're in good condition to start
 
87
        $this->assertTrue($this->displayStatusEquals($this->display, Display::$STATUS_DONE), 'Display Status isnt as expected');
 
88
 
 
89
        // Edit the Layout
 
90
        $this->client->put('/layout/' . $this->layout->layoutId, [
 
91
            'name' => $this->layout->layout,
 
92
            'description' => $this->layout->description,
 
93
            'backgroundColor' => $this->layout->backgroundColor,
 
94
            'backgroundzIndex' => $this->layout->backgroundzIndex
 
95
        ], ['CONTENT_TYPE' => 'application/x-www-form-urlencoded']);
 
96
 
 
97
        // Validate the layout status afterwards
 
98
        $this->assertTrue($this->layoutStatusEquals($this->layout, 3), 'Layout Status isnt as expected');
 
99
 
 
100
        // Validate the display status afterwards
 
101
        $this->assertTrue($this->displayStatusEquals($this->display, Display::$STATUS_DONE), 'Display Status isnt as expected');
 
102
 
 
103
        // Somehow test that we have issued an XMR request
 
104
        $this->assertFalse(in_array($this->display->displayId, $this->getPlayerActionQueue()), 'Player action not present');
 
105
    }
 
106
}
 
 
b'\\ No newline at end of file'