. */ namespace Xibo\Tests\integration\Cache; use Carbon\Carbon; use Xibo\Entity\Display; use Xibo\Helper\DateFormatHelper; use Xibo\Helper\Random; use Xibo\OAuth2\Client\Entity\XiboCampaign; 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 CampaignLayoutUnassignTest * @package Xibo\Tests\integration\Cache */ class CampaignLayoutUnassignTest extends LocalWebTestCase { use LayoutHelperTrait; use DisplayHelperTrait; /** @var XiboCampaign */ protected $campaign; /** @var XiboLayout */ protected $layout; /** @var XiboDisplay */ protected $display; /** @var XiboSchedule */ protected $event; // public function setup() { parent::setup(); $this->getLogger()->debug('Setup test for Cache ' . get_class($this) .' Test'); // Create a Layout $this->layout = $this->createLayout(); // Checkout $layout = $this->getDraft($this->layout); // Add a simple widget $this->addSimpleWidget($layout); // Check us in again $this->layout = $this->publish($this->layout); // Build the layout $this->buildLayout($this->layout); // Create a Campaign $this->campaign = (new XiboCampaign($this->getEntityProvider()))->create(Random::generateString()); // Assign the Layout to the Campaign $this->getEntityProvider()->post('/campaign/layout/assign/' . $this->campaign->campaignId, [ 'layoutId' => $this->layout->layoutId ]); // Create a Display $this->display = $this->createDisplay(); // Date $date = Carbon::now(); // Schedule the Campaign "always" onto our display // deleting the layout will remove this at the end $this->event = (new XiboSchedule($this->getEntityProvider()))->createEventLayout( $date->format(DateFormatHelper::getSystemFormat()), $date->addHours(3)->format(DateFormatHelper::getSystemFormat()), $this->campaign->campaignId, [$this->display->displayGroupId], 0, NULL, NULL, NULL, 0, 0, 0 ); $this->displaySetStatus($this->display, Display::$STATUS_DONE); $this->displaySetLicensed($this->display); $this->getLogger()->debug('Finished Setup'); } public function tearDown() { $this->getLogger()->debug('Tear Down'); parent::tearDown(); // Delete the Layout we've been working with $this->deleteLayout($this->layout); // Delete the Display $this->deleteDisplay($this->display); // Delete the Campaign $this->campaign->delete(); } // /** * @group cacheInvalidateTests */ public function testInvalidateCache() { // Make sure our Display is already DONE $this->assertTrue($this->displayStatusEquals($this->display, Display::$STATUS_DONE), 'Display Status isnt as expected'); // Unassign requires edit $this->sendRequest('PUT', '/campaign/' . $this->campaign->campaignId, [ 'name' => $this->campaign->campaign, 'manageLayouts' => 1, 'layoutIds' => [] // empty list ]); // Validate the display status afterwards $this->assertTrue($this->displayStatusEquals($this->display, Display::$STATUS_PENDING), 'Display Status isnt as expected'); // Validate that XMR has been called. $this->assertTrue(in_array($this->display->displayId, $this->getPlayerActionQueue()), 'Player action not present'); } }