. */ 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\OAuth2\Client\Exception\XiboApiException; use Xibo\Tests\Helper\DisplayHelperTrait; use Xibo\Tests\Helper\LayoutHelperTrait; use Xibo\Tests\LocalWebTestCase; /** * Class LayoutDeleteTest * @package Xibo\Tests\integration\Cache */ class LayoutDeleteTest 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); // 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 if ($this->layout !== null) $this->deleteLayout($this->layout); // Delete the Display $this->deleteDisplay($this->display); } // /** * @group cacheInvalidateTests */ public function testInvalidateCache() { // Delete the Layout we've got created for us. $this->sendRequest('DELETE','/layout/' . $this->layout->layoutId); // Check its deleted try { $this->layoutStatusEquals($this->layout, 0); } catch (XiboApiException $xiboApiException) { $this->assertEquals(404, $xiboApiException->getCode(), 'Expecting a 404, got ' . $xiboApiException->getCode()); } $this->layout = null; // Validate the display status afterwards $this->assertTrue($this->displayStatusEquals($this->display, Display::$STATUS_PENDING), 'Display Status isnt as expected'); // Somehow test that we have issued an XMR request $this->assertTrue(in_array($this->display->displayId, $this->getPlayerActionQueue()), 'Player action not present'); } }