class CommentBulkFormTest
Same name in other branches
- 8.9.x core/modules/comment/tests/src/Unit/Plugin/views/field/CommentBulkFormTest.php \Drupal\Tests\comment\Unit\Plugin\views\field\CommentBulkFormTest
- 10 core/modules/comment/tests/src/Unit/Plugin/views/field/CommentBulkFormTest.php \Drupal\Tests\comment\Unit\Plugin\views\field\CommentBulkFormTest
- 11.x core/modules/comment/tests/src/Unit/Plugin/views/field/CommentBulkFormTest.php \Drupal\Tests\comment\Unit\Plugin\views\field\CommentBulkFormTest
@coversDefaultClass \Drupal\comment\Plugin\views\field\CommentBulkForm @group comment
Hierarchy
- class \Drupal\Tests\UnitTestCase extends \PHPUnit\Framework\TestCase uses \Drupal\Tests\Traits\PhpUnitWarnings, \Drupal\Tests\PhpUnitCompatibilityTrait, \Symfony\Bridge\PhpUnit\ExpectDeprecationTrait
- class \Drupal\Tests\comment\Unit\Plugin\views\field\CommentBulkFormTest extends \Drupal\Tests\UnitTestCase
Expanded class hierarchy of CommentBulkFormTest
File
-
core/
modules/ comment/ tests/ src/ Unit/ Plugin/ views/ field/ CommentBulkFormTest.php, line 15
Namespace
Drupal\Tests\comment\Unit\Plugin\views\fieldView source
class CommentBulkFormTest extends UnitTestCase {
/**
* {@inheritdoc}
*/
protected function tearDown() : void {
parent::tearDown();
$container = new ContainerBuilder();
\Drupal::setContainer($container);
}
/**
* Tests the constructor assignment of actions.
*/
public function testConstructor() {
$actions = [];
for ($i = 1; $i <= 2; $i++) {
$action = $this->createMock('\\Drupal\\system\\ActionConfigEntityInterface');
$action->expects($this->any())
->method('getType')
->willReturn('comment');
$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');
$views_data = $this->getMockBuilder('Drupal\\views\\ViewsData')
->disableOriginalConstructor()
->getMock();
$views_data->expects($this->any())
->method('get')
->with('comment')
->willReturn([
'table' => [
'entity type' => 'comment',
],
]);
$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('comment');
$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 = [];
$comment_bulk_form = new CommentBulkForm([], 'comment_bulk_form', $definition, $entity_type_manager, $language_manager, $messenger, $entity_repository);
$comment_bulk_form->init($executable, $display, $options);
$reflected_actions = (new \ReflectionObject($comment_bulk_form))->getProperty('actions');
$reflected_actions->setAccessible(TRUE);
$this->assertEquals(array_slice($actions, 0, -1, TRUE), $reflected_actions->getValue($comment_bulk_form));
}
}
Members
Title Sort descending | Deprecated | Modifiers | Object type | Summary | Overrides |
---|---|---|---|---|---|
CommentBulkFormTest::tearDown | protected | function | |||
CommentBulkFormTest::testConstructor | public | function | Tests the constructor assignment of actions. | ||
PhpUnitWarnings::$deprecationWarnings | private static | property | Deprecation warnings from PHPUnit to raise with @trigger_error(). | ||
PhpUnitWarnings::addWarning | public | function | Converts PHPUnit deprecation warnings to E_USER_DEPRECATED. | ||
UnitTestCase::$randomGenerator | protected | property | The random generator. | ||
UnitTestCase::$root | protected | property | The app root. | 1 | |
UnitTestCase::assertArrayEquals | Deprecated | protected | function | Asserts if two arrays are equal by sorting them first. | |
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 | 338 | ||
UnitTestCase::setUpBeforeClass | public static | function |
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.