class NodeBulkFormTest

Same name and namespace in other branches
  1. 9 core/modules/node/tests/src/Unit/Plugin/views/field/NodeBulkFormTest.php \Drupal\Tests\node\Unit\Plugin\views\field\NodeBulkFormTest
  2. 8.9.x core/modules/node/tests/src/Unit/Plugin/views/field/NodeBulkFormTest.php \Drupal\Tests\node\Unit\Plugin\views\field\NodeBulkFormTest
  3. 10 core/modules/node/tests/src/Unit/Plugin/views/field/NodeBulkFormTest.php \Drupal\Tests\node\Unit\Plugin\views\field\NodeBulkFormTest

@coversDefaultClass \Drupal\node\Plugin\views\field\NodeBulkForm @group node

Hierarchy

Expanded class hierarchy of NodeBulkFormTest

File

core/modules/node/tests/src/Unit/Plugin/views/field/NodeBulkFormTest.php, line 18

Namespace

Drupal\Tests\node\Unit\Plugin\views\field
View source
class NodeBulkFormTest extends UnitTestCase {
    
    /**
     * {@inheritdoc}
     */
    protected function tearDown() : void {
        parent::tearDown();
        $container = new ContainerBuilder();
        \Drupal::setContainer($container);
    }
    
    /**
     * Tests the constructor assignment of actions.
     */
    public function testConstructor() : void {
        $actions = [];
        for ($i = 1; $i <= 2; $i++) {
            $action = $this->createMock('\\Drupal\\system\\ActionConfigEntityInterface');
            $action->expects($this->any())
                ->method('getType')
                ->willReturn('node');
            $actions[$i] = $action;
        }
        $action = $this->createMock('\\Drupal\\system\\ActionConfigEntityInterface');
        $action->expects($this->any())
            ->method('getType')
            ->willReturn('user');
        $actions[] = $action;
        $entity_storage = $this->createMock('Drupal\\Core\\Entity\\EntityStorageInterface');
        $entity_storage->expects($this->any())
            ->method('loadMultiple')
            ->willReturn($actions);
        $entity_type_manager = $this->createMock(EntityTypeManagerInterface::class);
        $entity_type_manager->expects($this->once())
            ->method('getStorage')
            ->with('action')
            ->willReturn($entity_storage);
        $entity_repository = $this->createMock(EntityRepositoryInterface::class);
        $language_manager = $this->createMock('Drupal\\Core\\Language\\LanguageManagerInterface');
        $messenger = $this->createMock('Drupal\\Core\\Messenger\\MessengerInterface');
        $route_match = $this->createMock(ResettableStackedRouteMatchInterface::class);
        $views_data = $this->getMockBuilder('Drupal\\views\\ViewsData')
            ->disableOriginalConstructor()
            ->getMock();
        $views_data->expects($this->any())
            ->method('get')
            ->with('node')
            ->willReturn([
            'table' => [
                'entity type' => 'node',
            ],
        ]);
        $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')
            ->willReturn('node');
        $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 = [];
        $node_bulk_form = new NodeBulkForm([], 'node_bulk_form', $definition, $entity_type_manager, $language_manager, $messenger, $entity_repository, $route_match);
        $node_bulk_form->init($executable, $display, $options);
        $reflected_actions = (new \ReflectionObject($node_bulk_form))->getProperty('actions');
        $this->assertEquals(array_slice($actions, 0, -1, TRUE), $reflected_actions->getValue($node_bulk_form));
    }

}

Members

Title Sort descending Modifiers Object type Summary Overrides
ExpectDeprecationTrait::expectDeprecation public function Adds an expected deprecation.
ExpectDeprecationTrait::getCallableName private static function Returns a callable as a string suitable for inclusion in a message.
ExpectDeprecationTrait::setUpErrorHandler public function Sets up the test error handler.
ExpectDeprecationTrait::tearDownErrorHandler public function Tears down the test error handler.
NodeBulkFormTest::tearDown protected function
NodeBulkFormTest::testConstructor public function Tests the constructor assignment of actions.
RandomGeneratorTrait::getRandomGenerator protected function Gets the random generator for the utility methods.
RandomGeneratorTrait::randomMachineName protected function Generates a unique random string containing letters and numbers.
RandomGeneratorTrait::randomObject public function Generates a random PHP object.
RandomGeneratorTrait::randomString public function Generates a pseudo-random string of ASCII characters of codes 32 to 126.
UnitTestCase::$root protected property The app root.
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::getStringTranslationStub public function Returns a stub translation manager that just returns the passed string.
UnitTestCase::setUp protected function 354
UnitTestCase::setUpBeforeClass public static function

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.