Unverified Commit 91fe1d2f authored by Alex Pott's avatar Alex Pott
Browse files

Issue #2929133 by voleger, alexpott, Lendude: Replace all usages of getMock()

parent 2bb3bba5
Loading
Loading
Loading
Loading
+4 −5
Original line number Diff line number Diff line
@@ -83,11 +83,10 @@ public function testSettingsForm() {
      'aggregator_allowed_html_tags' => '',
    ]);

    $test_processor = $this->getMock(
      'Drupal\aggregator_test\Plugin\aggregator\processor\TestProcessor',
      ['buildConfigurationForm', 'validateConfigurationForm', 'submitConfigurationForm'],
      [[], 'aggregator_test', ['description' => ''], $this->configFactory]
    );
    $test_processor = $this->getMockBuilder('Drupal\aggregator_test\Plugin\aggregator\processor\TestProcessor')
      ->setMethods(['buildConfigurationForm', 'validateConfigurationForm', 'submitConfigurationForm'])
      ->setConstructorArgs([[], 'aggregator_test', ['description' => ''], $this->configFactory])
      ->getMock();
    $test_processor->expects($this->at(0))
      ->method('buildConfigurationForm')
      ->with($this->anything(), $form_state)
+2 −2
Original line number Diff line number Diff line
@@ -41,8 +41,8 @@ class BanMiddlewareTest extends UnitTestCase {
  protected function setUp() {
    parent::setUp();

    $this->kernel = $this->getMock('Symfony\Component\HttpKernel\HttpKernelInterface');
    $this->banManager = $this->getMock('Drupal\ban\BanIpManagerInterface');
    $this->kernel = $this->createMock('Symfony\Component\HttpKernel\HttpKernelInterface');
    $this->banManager = $this->createMock('Drupal\ban\BanIpManagerInterface');
    $this->banMiddleware = new BanMiddleware($this->kernel, $this->banManager);
  }

+3 −3
Original line number Diff line number Diff line
@@ -63,18 +63,18 @@ class BlockConfigEntityUnitTest extends UnitTestCase {
  protected function setUp() {
    $this->entityTypeId = $this->randomMachineName();

    $this->entityType = $this->getMock('\Drupal\Core\Entity\EntityTypeInterface');
    $this->entityType = $this->createMock('\Drupal\Core\Entity\EntityTypeInterface');
    $this->entityType->expects($this->any())
      ->method('getProvider')
      ->will($this->returnValue('block'));

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

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

    $this->moduleHandler = $this->prophesize(ModuleHandlerInterface::class);
    $this->themeHandler = $this->prophesize(ThemeHandlerInterface::class);
+7 −7
Original line number Diff line number Diff line
@@ -70,13 +70,13 @@ class BlockFormTest extends UnitTestCase {
  protected function setUp() {
    parent::setUp();

    $this->conditionManager = $this->getMock('Drupal\Core\Executable\ExecutableManagerInterface');
    $this->language = $this->getMock('Drupal\Core\Language\LanguageManagerInterface');
    $this->contextRepository = $this->getMock('Drupal\Core\Plugin\Context\ContextRepositoryInterface');
    $this->conditionManager = $this->createMock('Drupal\Core\Executable\ExecutableManagerInterface');
    $this->language = $this->createMock('Drupal\Core\Language\LanguageManagerInterface');
    $this->contextRepository = $this->createMock('Drupal\Core\Plugin\Context\ContextRepositoryInterface');

    $this->entityTypeManager = $this->getMock('Drupal\Core\Entity\EntityTypeManagerInterface');
    $this->storage = $this->getMock('Drupal\Core\Config\Entity\ConfigEntityStorageInterface');
    $this->themeHandler = $this->getMock('Drupal\Core\Extension\ThemeHandlerInterface');
    $this->entityTypeManager = $this->createMock('Drupal\Core\Entity\EntityTypeManagerInterface');
    $this->storage = $this->createMock('Drupal\Core\Config\Entity\ConfigEntityStorageInterface');
    $this->themeHandler = $this->createMock('Drupal\Core\Extension\ThemeHandlerInterface');
    $this->entityTypeManager->expects($this->any())
      ->method('getStorage')
      ->will($this->returnValue($this->storage));
@@ -123,7 +123,7 @@ public function testGetUniqueMachineName() {
    $blocks['other_test_1'] = $this->getBlockMockWithMachineName('other_test');
    $blocks['other_test_2'] = $this->getBlockMockWithMachineName('other_test');

    $query = $this->getMock('Drupal\Core\Entity\Query\QueryInterface');
    $query = $this->createMock('Drupal\Core\Entity\Query\QueryInterface');
    $query->expects($this->exactly(5))
      ->method('condition')
      ->will($this->returnValue($query));
+5 −5
Original line number Diff line number Diff line
@@ -60,13 +60,13 @@ protected function setUp() {
        'bottom',
      ]);

    $theme_manager = $this->getMock('Drupal\Core\Theme\ThemeManagerInterface');
    $theme_manager = $this->createMock('Drupal\Core\Theme\ThemeManagerInterface');
    $theme_manager->expects($this->atLeastOnce())
      ->method('getActiveTheme')
      ->will($this->returnValue($active_theme));

    $this->contextHandler = $this->getMock('Drupal\Core\Plugin\Context\ContextHandlerInterface');
    $this->blockStorage = $this->getMock('Drupal\Core\Entity\EntityStorageInterface');
    $this->contextHandler = $this->createMock('Drupal\Core\Plugin\Context\ContextHandlerInterface');
    $this->blockStorage = $this->createMock('Drupal\Core\Entity\EntityStorageInterface');
    /** @var \Drupal\Core\Entity\EntityTypeManagerInterface|\PHPUnit_Framework_MockObject_MockObject $entity_type_manager */
    $entity_type_manager = $this->createMock(EntityTypeManagerInterface::class);
    $entity_type_manager->expects($this->any())
@@ -86,7 +86,7 @@ protected function setUp() {
  public function testGetVisibleBlocksPerRegion(array $blocks_config, array $expected_blocks) {
    $blocks = [];
    foreach ($blocks_config as $block_id => $block_config) {
      $block = $this->getMock('Drupal\block\BlockInterface');
      $block = $this->createMock('Drupal\block\BlockInterface');
      $block->expects($this->once())
        ->method('access')
        ->will($this->returnValue($block_config[0]));
@@ -155,7 +155,7 @@ public function providerBlocksConfig() {
   * @covers ::getVisibleBlocksPerRegion
   */
  public function testGetVisibleBlocksPerRegionWithContext() {
    $block = $this->getMock('Drupal\block\BlockInterface');
    $block = $this->createMock('Drupal\block\BlockInterface');
    $block->expects($this->once())
      ->method('access')
      ->willReturn(AccessResult::allowed()->addCacheTags(['config:block.block.block_id']));
Loading