atMost example

->willReturn($view);

    $executable = $this->getMockBuilder('Drupal\views\ViewExecutable')
      ->disableOriginalConstructor()
      ->getMock();
    $executable->expects($this->once())
      ->method('access')
      ->willReturn(TRUE);
    $executable->expects($this->any())
      ->method('setDisplay')
      ->willReturn(TRUE);
    $executable->expects($this->atMost(1))
      ->method('preview')
      ->willReturn(['#markup' => 'View result']);

    $this->executableFactory->expects($this->once())
      ->method('get')
      ->with($view)
      ->willReturn($executable);

    $display_handler = $this->getMockBuilder('Drupal\views\Plugin\views\display\DisplayPluginBase')
      ->disableOriginalConstructor()
      ->getMock();
    

    $value = $this->plugin->transform(NULL, $this->migrateExecutable, $this->row, 'destination_property');
    $this->assertSame(['source_value1', 'source_value2', 'source_value3', 'source_value4']$value);
  }

  /** * Tests the Get plugin when source has integer values. * * @dataProvider integerValuesDataProvider */
  public function testIntegerValues($source$expected_value) {
    $this->row->expects($this->atMost(2))
      ->method('get')
      ->willReturnOnConsecutiveCalls('val1', 'val2');

    $this->plugin = new Get(['source' => $source], '', []);
    $return = $this->plugin->transform(NULL, $this->migrateExecutable, $this->row, 'destination_property');
    $this->assertSame($expected_value$return);
  }

  /** * Provides data for the successful lookup test. * * @return array */
$connection = $this->createMock(Connection::class);
        $connection->expects(static::once())->method('fetchAssociative')->willReturn($fetchDataResult);

        if ($fetchDataResult === false) {
            $connection->expects(static::never())->method('createQueryBuilder');
        }

        if ($fetchParentLanguageResult !== false) {
            $result = $this->createMock(Result::class);
            $result->expects(static::once())->method('fetchOne')->willReturn($fetchParentLanguageResult);
            $connection->expects(static::once())->method('executeQuery')->willReturn($result);
            $connection->expects(static::atMost(1))->method('createQueryBuilder')->willReturn(new QueryBuilder($connection));
        } else {
            $result = $this->createMock(Result::class);
            $result->expects(static::atMost(1))->method('fetchOne')->willReturn(false);
            $connection->expects(static::atMost(1))->method('executeQuery')->willReturn($result);
            $connection->expects(static::atMost(1))->method('createQueryBuilder')->willReturn(new QueryBuilder($connection));
        }

        $factory = new BaseContextFactory(
            $salesChannelRepository,
            $currencyRepository,
            $customerGroupRepository,
            
Home | Imprint | This part of the site doesn't use cookies.