Verified Commit abe98919 authored by Alex Pott's avatar Alex Pott
Browse files

Issue #3295880 by Spokje, longwave: ->willReturn(...) would make more sense here

(cherry picked from commit 2c4eec3dc3a848fdffb40416ecf71476d0c1ea73)
parent ec812517
Loading
Loading
Loading
Loading
+4 −4
Original line number Diff line number Diff line
@@ -66,13 +66,13 @@ protected function setUp(): void {
    $this->entityType = $this->createMock('\Drupal\Core\Entity\EntityTypeInterface');
    $this->entityType->expects($this->any())
      ->method('getProvider')
      ->will($this->returnValue('block'));
      ->willReturn('block');

    $this->entityTypeManager = $this->createMock(EntityTypeManagerInterface::class);
    $this->entityTypeManager->expects($this->any())
      ->method('getDefinition')
      ->with($this->entityTypeId)
      ->will($this->returnValue($this->entityType));
      ->willReturn($this->entityType);

    $this->uuid = $this->createMock('\Drupal\Component\Uuid\UuidInterface');

@@ -111,13 +111,13 @@ public function testCalculateDependencies() {
    $plugin_collection->expects($this->atLeastOnce())
      ->method('get')
      ->with($instance_id)
      ->will($this->returnValue($instance));
      ->willReturn($instance);
    $plugin_collection->addInstanceId($instance_id);

    // Return the mocked plugin collection.
    $entity->expects($this->once())
      ->method('getPluginCollections')
      ->will($this->returnValue([$plugin_collection]));
      ->willReturn([$plugin_collection]);

    $dependencies = $entity->calculateDependencies()->getDependencies();
    $this->assertContains('test', $dependencies['module']);
+6 −6
Original line number Diff line number Diff line
@@ -79,7 +79,7 @@ protected function setUp(): void {
    $this->themeHandler = $this->createMock('Drupal\Core\Extension\ThemeHandlerInterface');
    $this->entityTypeManager->expects($this->any())
      ->method('getStorage')
      ->will($this->returnValue($this->storage));
      ->willReturn($this->storage);

    $this->pluginFormFactory = $this->prophesize(PluginFormFactoryInterface::class);
  }
@@ -99,14 +99,14 @@ protected function getBlockMockWithMachineName($machine_name) {
      ->getMock();
    $plugin->expects($this->any())
      ->method('getMachineNameSuggestion')
      ->will($this->returnValue($machine_name));
      ->willReturn($machine_name);

    $block = $this->getMockBuilder(Block::class)
      ->disableOriginalConstructor()
      ->getMock();
    $block->expects($this->any())
      ->method('getPlugin')
      ->will($this->returnValue($plugin));
      ->willReturn($plugin);
    return $block;
  }

@@ -126,15 +126,15 @@ public function testGetUniqueMachineName() {
    $query = $this->createMock('Drupal\Core\Entity\Query\QueryInterface');
    $query->expects($this->exactly(5))
      ->method('condition')
      ->will($this->returnValue($query));
      ->willReturn($query);

    $query->expects($this->exactly(5))
      ->method('execute')
      ->will($this->returnValue(['test', 'other_test', 'other_test_1', 'other_test_2']));
      ->willReturn(['test', 'other_test', 'other_test_1', 'other_test_2']);

    $this->storage->expects($this->exactly(5))
      ->method('getQuery')
      ->will($this->returnValue($query));
      ->willReturn($query);

    $block_form_controller = new BlockForm($this->entityTypeManager, $this->conditionManager, $this->contextRepository, $this->language, $this->themeHandler, $this->pluginFormFactory->reveal());

+2 −2
Original line number Diff line number Diff line
@@ -56,7 +56,7 @@ protected function setUp(): void {
    $theme_manager = $this->createMock('Drupal\Core\Theme\ThemeManagerInterface');
    $theme_manager->expects($this->atLeastOnce())
      ->method('getActiveTheme')
      ->will($this->returnValue($active_theme));
      ->willReturn($active_theme);

    $this->contextHandler = $this->createMock('Drupal\Core\Plugin\Context\ContextHandlerInterface');
    $this->blockStorage = $this->createMock('Drupal\Core\Entity\EntityStorageInterface');
@@ -82,7 +82,7 @@ public function testGetVisibleBlocksPerRegion(array $blocks_config, array $expec
      $block = $this->createMock('Drupal\block\BlockInterface');
      $block->expects($this->once())
        ->method('access')
        ->will($this->returnValue($block_config[0]));
        ->willReturn($block_config[0]);
      $block->expects($block_config[0] ? $this->atLeastOnce() : $this->never())
        ->method('getRegion')
        ->willReturn($block_config[1]);
+1 −1
Original line number Diff line number Diff line
@@ -27,7 +27,7 @@ protected function setUp(): void {
    $block_manager = $this->createMock('Drupal\Core\Block\BlockManagerInterface');
    $block_manager->expects($this->any())
      ->method('getCategories')
      ->will($this->returnValue(['Comment', 'Node', 'None & Such', 'User']));
      ->willReturn(['Comment', 'Node', 'None & Such', 'User']);

    $this->autocompleteController = new CategoryAutocompleteController($block_manager);
  }
+1 −1
Original line number Diff line number Diff line
@@ -46,7 +46,7 @@ protected function setUp(): void {
    $theme_handler = $this->createMock('Drupal\Core\Extension\ThemeHandlerInterface');
    $theme_handler->expects($this->any())
      ->method('listInfo')
      ->will($this->returnValue($themes));
      ->willReturn($themes);
    $theme_handler->expects($this->any())
      ->method('hasUi')
      ->willReturnMap([
Loading