You are here

class WebformSubmissionBulkFormTest in Webform 8.5

Same name and namespace in other branches
  1. 6.x tests/src/Unit/Plugin/views/field/WebformSubmissionBulkFormTest.php \Drupal\Tests\webform\Unit\Plugin\views\field\WebformSubmissionBulkFormTest

Tests webform submission bulk form actions.

@coversDefaultClass \Drupal\webform\Plugin\views\field\WebformSubmissionBulkForm @group webform

Hierarchy

Expanded class hierarchy of WebformSubmissionBulkFormTest

See also

\Drupal\Tests\node\Unit\Plugin\views\field\NodeBulkFormTest

\Drupal\Tests\user\Unit\Plugin\views\field\UserBulkFormTest

File

tests/src/Unit/Plugin/views/field/WebformSubmissionBulkFormTest.php, line 18

Namespace

Drupal\Tests\webform\Unit\Plugin\views\field
View source
class WebformSubmissionBulkFormTest extends UnitTestCase {

  /**
   * {@inheritdoc}
   */
  protected function tearDown() {
    parent::tearDown();
    $container = new ContainerBuilder();
    \Drupal::setContainer($container);
  }

  /**
   * Tests the constructor assignment of actions.
   */
  public function testConstructor() {

    // @todo Fix broken test.
    $this
      ->assertTrue(TRUE);
    return;
    $actions = [];
    for ($i = 1; $i <= 2; $i++) {
      $action = $this
        ->createMock('\\Drupal\\system\\ActionConfigEntityInterface');
      $action
        ->expects($this
        ->any())
        ->method('getType')
        ->will($this
        ->returnValue('webform_submission'));
      $actions[$i] = $action;
    }
    $action = $this
      ->createMock('\\Drupal\\system\\ActionConfigEntityInterface');
    $action
      ->expects($this
      ->any())
      ->method('getType')
      ->will($this
      ->returnValue('user'));
    $actions[] = $action;
    $entity_storage = $this
      ->createMock('Drupal\\Core\\Entity\\EntityStorageInterface');
    $entity_storage
      ->expects($this
      ->any())
      ->method('loadMultiple')
      ->will($this
      ->returnValue($actions));
    $entity_manager = $this
      ->createMock('Drupal\\Core\\Entity\\EntityManagerInterface');
    $entity_manager
      ->expects($this
      ->once())
      ->method('getStorage')
      ->with('action')
      ->will($this
      ->returnValue($entity_storage));
    $entity_repository = $this
      ->createMock(EntityRepositoryInterface::class);
    $language_manager = $this
      ->createMock('Drupal\\Core\\Language\\LanguageManagerInterface');
    $messenger = $this
      ->createMock('\\Drupal\\Core\\Messenger\\MessengerInterface');
    $views_data = $this
      ->getMockBuilder('Drupal\\views\\ViewsData')
      ->disableOriginalConstructor()
      ->getMock();
    $views_data
      ->expects($this
      ->any())
      ->method('get')
      ->with('webform_submission')
      ->will($this
      ->returnValue([
      'table' => [
        'entity type' => 'webform_submission',
      ],
    ]));
    $container = new ContainerBuilder();
    $container
      ->set('views.views_data', $views_data);
    $container
      ->set('string_translation', $this
      ->getStringTranslationStub());
    \Drupal::setContainer($container);
    $storage = $this
      ->createMock('Drupal\\views\\ViewEntityInterface');
    $storage
      ->expects($this
      ->any())
      ->method('get')
      ->with('base_table')
      ->will($this
      ->returnValue('webform_submission'));
    $executable = $this
      ->getMockBuilder('Drupal\\views\\ViewExecutable')
      ->disableOriginalConstructor()
      ->getMock();
    $executable->storage = $storage;
    $display = $this
      ->getMockBuilder('Drupal\\views\\Plugin\\views\\display\\DisplayPluginBase')
      ->disableOriginalConstructor()
      ->getMock();
    $definition['title'] = '';
    $options = [];
    $webform_submission_bulk_form = new WebformSubmissionBulkForm([], 'webform_submission_bulk_form', $definition, $entity_manager, $language_manager, $messenger, $entity_repository);
    $webform_submission_bulk_form
      ->init($executable, $display, $options);
    $this
      ->assertAttributeEquals(array_slice($actions, 0, -1, TRUE), 'actions', $webform_submission_bulk_form);
  }

}

Members

Namesort descending Modifiers Type Description Overrides
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
WebformSubmissionBulkFormTest::tearDown protected function
WebformSubmissionBulkFormTest::testConstructor public function Tests the constructor assignment of actions.