Commit a3cc5307 authored by catch's avatar catch
Browse files

Issue #3417559 by longwave, Spokje: Remove withConsecutive() in KeyValueEntityStorageTest

(cherry picked from commit ada2ee79)
parent db7c533b
Loading
Loading
Loading
Loading
Loading
+0 −5
Original line number Diff line number Diff line
@@ -3441,11 +3441,6 @@ parameters:
			count: 1
			path: tests/Drupal/Tests/Core/Entity/EntityUrlTest.php

		-
			message: "#^Call to deprecated method withConsecutive\\(\\) of class PHPUnit\\\\Framework\\\\MockObject\\\\Builder\\\\InvocationMocker\\.$#"
			count: 6
			path: tests/Drupal/Tests/Core/Entity/KeyValueStore/KeyValueEntityStorageTest.php

		-
			message: "#^Call to deprecated method withConsecutive\\(\\) of class PHPUnit\\\\Framework\\\\MockObject\\\\Builder\\\\InvocationMocker\\.$#"
			count: 1
+42 −25
Original line number Diff line number Diff line
@@ -158,9 +158,12 @@ public function testCreateWithPredefinedUuid() {
      ->willReturn(get_class($this->getMockEntity()));
    $this->setUpKeyValueEntityStorage();

    $this->moduleHandler->expects($this->exactly(2))
    $hooks = ['test_entity_type_create', 'entity_create'];
    $this->moduleHandler->expects($this->exactly(count($hooks)))
      ->method('invokeAll')
      ->withConsecutive(['test_entity_type_create'], ['entity_create']);
      ->with($this->callback(function (string $hook) use (&$hooks): bool {
        return array_shift($hooks) === $hook;
      }));
    $this->uuidService->expects($this->never())
      ->method('generate');

@@ -181,9 +184,12 @@ public function testCreateWithoutUuidKey() {
      ->willReturn(get_class($this->getMockEntity()));
    $this->setUpKeyValueEntityStorage(NULL);

    $this->moduleHandler->expects($this->exactly(2))
    $hooks = ['test_entity_type_create', 'entity_create'];
    $this->moduleHandler->expects($this->exactly(count($hooks)))
      ->method('invokeAll')
      ->withConsecutive(['test_entity_type_create'], ['entity_create']);
      ->with($this->callback(function (string $hook) use (&$hooks): bool {
        return array_shift($hooks) === $hook;
      }));
    $this->uuidService->expects($this->never())
      ->method('generate');

@@ -206,9 +212,12 @@ public function testCreate() {
      ->willReturn(get_class($entity));
    $this->setUpKeyValueEntityStorage();

    $this->moduleHandler->expects($this->exactly(2))
    $hooks = ['test_entity_type_create', 'entity_create'];
    $this->moduleHandler->expects($this->exactly(count($hooks)))
      ->method('invokeAll')
      ->withConsecutive(['test_entity_type_create'], ['entity_create']);
      ->with($this->callback(function (string $hook) use (&$hooks): bool {
        return array_shift($hooks) === $hook;
      }));
    $this->uuidService->expects($this->once())
      ->method('generate')
      ->willReturn('bar');
@@ -248,14 +257,13 @@ public function testSaveInsert(EntityInterface $entity) {
      ->method('toArray')
      ->willReturn($expected);

    $this->moduleHandler->expects($this->exactly(4))
    $hooks = ['test_entity_type_presave', 'entity_presave', 'test_entity_type_insert', 'entity_insert'];
    $this->moduleHandler->expects($this->exactly(count($hooks)))
      ->method('invokeAll')
      ->withConsecutive(
        ['test_entity_type_presave'],
        ['entity_presave'],
        ['test_entity_type_insert'],
        ['entity_insert'],
      );
      ->with($this->callback(function (string $hook) use (&$hooks): bool {
        return array_shift($hooks) === $hook;
      }));

    $this->keyValueStore->expects($this->once())
      ->method('set')
      ->with('foo', $expected);
@@ -292,14 +300,14 @@ public function testSaveUpdate(EntityInterface $entity) {
      ->willReturn([['id' => 'foo']]);
    $this->keyValueStore->expects($this->never())
      ->method('delete');
    $this->moduleHandler->expects($this->exactly(4))

    $hooks = ['test_entity_type_presave', 'entity_presave', 'test_entity_type_update', 'entity_update'];
    $this->moduleHandler->expects($this->exactly(count($hooks)))
      ->method('invokeAll')
      ->withConsecutive(
        ['test_entity_type_presave'],
        ['entity_presave'],
        ['test_entity_type_update'],
        ['entity_update'],
      );
      ->with($this->callback(function (string $hook) use (&$hooks): bool {
        return array_shift($hooks) === $hook;
      }));

    $this->keyValueStore->expects($this->once())
      ->method('set')
      ->with('foo', $expected);
@@ -574,12 +582,21 @@ public function testDelete() {
    $entities['bar'] = $this->getMockEntity(EntityBaseTest::class, [['id' => 'bar']]);
    $this->setUpKeyValueEntityStorage();

    $this->moduleHandler->expects($this->exactly(8))
    $hooks = [
      'test_entity_type_predelete',
      'entity_predelete',
      'test_entity_type_predelete',
      'entity_predelete',
      'test_entity_type_delete',
      'entity_delete',
      'test_entity_type_delete',
      'entity_delete',
    ];
    $this->moduleHandler->expects($this->exactly(count($hooks)))
      ->method('invokeAll')
      ->withConsecutive(
        ['test_entity_type_predelete'],
        ['entity_predelete'],
      );
      ->with($this->callback(function (string $hook) use (&$hooks): bool {
        return array_shift($hooks) === $hook;
      }));

    $this->keyValueStore->expects($this->once())
      ->method('deleteMultiple')