Part of #1938068: Convert UnitTestBase to PHPUnit

Directory
- core/modules/block/lib/Drupal/block/Tests

Testing

cd core
vendor/bin/phpunit modules/block/lib/Drupal/block/Tests/BlockStorageUnitTest.php

Comments

clemens.tolboom’s picture

Assigned: Unassigned » clemens.tolboom
clemens.tolboom’s picture

This is not a Unittest as it needs a container right?

  protected function setUp() {
    parent::setUp();

    $this->controller = $this->container->get('plugin.manager.entity')->getStorageController('block');
  }
clemens.tolboom’s picture

Status: Active » Closed (works as designed)

Thanks to Berdir on irc we got pointer to Change notice
New, separate, extended DrupalUnitTestBase for unit-testing functionality whose dependencies can't be injected
which makes this issue futile.

msonnabaum’s picture

Status: Closed (works as designed) » Needs work

It's worth looking at this again.

Needing a container is not a blocker for phpunit, since we can mock it.

clemens.tolboom’s picture

I partly agree as we can create a mock.

But the tests done in BlockStorageUnitTest are CRUD testing against a plugin which generates stark particular values.

That's way out of my league :(

ParisLiakos’s picture

Issue tags: +phpunit

tagging

clemens.tolboom’s picture

Assigned: clemens.tolboom » Unassigned
clemens.tolboom’s picture

Issue summary: View changes

Added how to test.

dawehner’s picture

Issue summary: View changes
Status: Needs work » Fixed

Not sure whether there is much of a point at that time. Blocks are config entities, which have their own storage, which is tested.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.