You are here

class DaysTest in Message 8

Same name in this branch
  1. 8 tests/src/Unit/Plugin/MessagePurge/DaysTest.php \Drupal\Tests\message\Unit\Plugin\MessagePurge\DaysTest
  2. 8 tests/src/Kernel/Plugin/MessagePurge/DaysTest.php \Drupal\Tests\message\Kernel\Plugin\MessagePurge\DaysTest

Unit tests for the days purge plugin.

@coversDefaultClass \Drupal\message\Plugin\MessagePurge\Days

@group Message

Hierarchy

Expanded class hierarchy of DaysTest

File

tests/src/Unit/Plugin/MessagePurge/DaysTest.php, line 20

Namespace

Drupal\Tests\message\Unit\Plugin\MessagePurge
View source
class DaysTest extends UnitTestCase {

  /**
   * Test processing zero message.
   *
   * @covers ::process
   */
  public function testProcessNone() {
    $query = $this
      ->prophesize(QueryInterface::class)
      ->reveal();
    $request_stack = $this
      ->prophesize(RequestStack::class)
      ->reveal();
    $queue = $this
      ->prophesize(QueueInterface::class);
    $queue
      ->createItem(Argument::any())
      ->shouldNotBeCalled();
    $plugin = new Days([], 'days', [], $query, $queue
      ->reveal(), $request_stack);
    $plugin
      ->process([]);
  }

  /**
   * Tests processing more than defined queue item limit.
   *
   * @covers ::process
   */
  public function testProcess() {
    $query = $this
      ->prophesize(QueryInterface::class)
      ->reveal();
    $request_stack = $this
      ->prophesize(RequestStack::class)
      ->reveal();
    $queue = $this
      ->prophesize(QueueInterface::class);
    $queue
      ->createItem(Argument::size(MessagePurgeInterface::MESSAGE_DELETE_SIZE))
      ->shouldBeCalledTimes(1);
    $queue
      ->createItem(Argument::size(1))
      ->shouldBeCalledTimes(1);
    $plugin = new Days([], 'days', [], $query, $queue
      ->reveal(), $request_stack);
    $messages = range(1, MessagePurgeInterface::MESSAGE_DELETE_SIZE + 1);
    $plugin
      ->process($messages);
  }

}

Members

Namesort descending Modifiers Type Description Overrides
DaysTest::testProcess public function Tests processing more than defined queue item limit.
DaysTest::testProcessNone public function Test processing zero message.
PhpunitCompatibilityTrait::getMock Deprecated public function Returns a mock object for the specified class using the available method.
PhpunitCompatibilityTrait::setExpectedException Deprecated public function Compatibility layer for PHPUnit 6 to support PHPUnit 4 code.
UnitTestCase::$randomGenerator protected property The random generator.
UnitTestCase::$root protected property The app root. 1
UnitTestCase::assertArrayEquals protected function Asserts if two arrays are equal by sorting them first.
UnitTestCase::getBlockMockWithMachineName Deprecated protected function Mocks a block with a block plugin. 1
UnitTestCase::getClassResolverStub protected function Returns a stub class resolver.
UnitTestCase::getConfigFactoryStub public function Returns a stub config factory that behaves according to the passed array.
UnitTestCase::getConfigStorageStub public function Returns a stub config storage that returns the supplied configuration.
UnitTestCase::getContainerWithCacheTagsInvalidator protected function Sets up a container with a cache tags invalidator.
UnitTestCase::getRandomGenerator protected function Gets the random generator for the utility methods.
UnitTestCase::getStringTranslationStub public function Returns a stub translation manager that just returns the passed string.
UnitTestCase::randomMachineName public function Generates a unique random string containing letters and numbers.
UnitTestCase::setUp protected function 340