Exemple #1
0
 /**
  * {@inheritdoc}
  */
 public function setUp()
 {
     parent::setUp();
     $mock_data_definition = $this->getMock('Drupal\\Core\\TypedData\\DataDefinitionInterface');
     $this->contextDefinition = $this->getMockBuilder('Drupal\\Core\\Plugin\\Context\\ContextDefinitionInterface')->setMethods(array('getDefaultValue', 'getDataDefinition'))->getMockForAbstractClass();
     $this->contextDefinition->expects($this->once())->method('getDefaultValue')->willReturn('test');
     $this->contextDefinition->expects($this->once())->method('getDataDefinition')->willReturn($mock_data_definition);
     $this->typedData = $this->getMock('Drupal\\Core\\TypedData\\TypedDataInterface');
     $this->typedDataManager = $this->getMockBuilder('Drupal\\Core\\TypedData\\TypedDataManager')->disableOriginalConstructor()->setMethods(array('create'))->getMock();
     $this->typedDataManager->expects($this->once())->method('create')->with($mock_data_definition, 'test')->willReturn($this->typedData);
 }
Exemple #2
0
 /**
  * Set up mocks for the getDefaultValue() method call.
  *
  * @param mixed $default_value
  *   The default value to assign to the mock context definition.
  */
 protected function setUpDefaultValue($default_value = NULL)
 {
     $mock_data_definition = $this->getMock('Drupal\\Core\\TypedData\\DataDefinitionInterface');
     $this->contextDefinition = $this->getMockBuilder('Drupal\\Core\\Plugin\\Context\\ContextDefinitionInterface')->setMethods(array('getDefaultValue', 'getDataDefinition'))->getMockForAbstractClass();
     $this->contextDefinition->expects($this->once())->method('getDefaultValue')->willReturn($default_value);
     $this->contextDefinition->expects($this->once())->method('getDataDefinition')->willReturn($mock_data_definition);
     $this->typedData = $this->getMock('Drupal\\Core\\TypedData\\TypedDataInterface');
     $this->typedDataManager->expects($this->once())->method('create')->with($mock_data_definition, $default_value)->willReturn($this->typedData);
 }