. */ 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; // 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); } // /** * @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'); } }