QuotaTest.php in Message 8
File
tests/src/Kernel/Plugin/MessagePurge/QuotaTest.php
View source
<?php
namespace Drupal\Tests\message\Kernel\Plugin\MessagePurge;
use Drupal\KernelTests\KernelTestBase;
use Drupal\message\Entity\Message;
use Drupal\message\Entity\MessageTemplate;
class QuotaTest extends KernelTestBase {
public static $modules = [
'message',
'user',
];
protected $plugin;
protected $template;
public function setUp() {
parent::setUp();
$this
->installEntitySchema('message');
$this->template = MessageTemplate::create([
'template' => 'foo',
]);
$this->template
->save();
}
public function testFetch() {
$configuration = [
'weight' => 4,
'data' => [
'quota' => 10,
],
];
$this
->createPlugin($configuration);
$this
->assertEquals([], $this->plugin
->fetch($this->template));
foreach (range(1, 5) as $i) {
$message = Message::create([
'template' => $this->template
->id(),
]);
$message
->save();
}
$this
->createPlugin($configuration);
$this
->assertEquals([], $this->plugin
->fetch($this->template));
$configuration['data']['quota'] = 3;
$this
->createPlugin($configuration);
$this
->assertEquals([
1 => 1,
2 => 2,
], $this->plugin
->fetch($this->template));
}
protected function createPlugin(array $configuration) {
$this->plugin = $this->container
->get('plugin.manager.message.purge')
->createInstance('quota', $configuration);
}
}
Classes
Name |
Description |
QuotaTest |
Integration tests for the 'quota' purge plugin. |