protected function setUp() { // Mock text format configuration entity object. $this->format = $this->getMockBuilder('\\Drupal\\filter\\Entity\\FilterFormat')->disableOriginalConstructor()->getMock(); $this->format->expects($this->any())->method('getFilterTypes')->will($this->returnValue(array(FilterInterface::TYPE_HTML_RESTRICTOR))); $restrictions = array('allowed' => array('p' => TRUE, 'a' => TRUE, '*' => array('style' => FALSE, 'on*' => FALSE))); $this->format->expects($this->any())->method('getHtmlRestrictions')->will($this->returnValue($restrictions)); }
/** * Sets up mocks for buildForm() calls. * * @param object $asset * An asset to load from the entity type manager. */ private function setUpBuildForm($asset = NULL) { $this->mockFilter->expects($this->exactly(2))->method('id')->willReturn(self::MOCK_FILTER_ID); $filter_align = new \stdClass(); $filter_align->status = 1; $this->mockFilter->expects($this->once())->method('filters')->with('filter_align')->willReturn($filter_align); $catalog_id = 'test_catalog'; $editor_settings['plugins']['embridgeimage']['embridge_image_upload'] = ['max_size' => '2 MB', 'library_id' => 101, 'catalog_id' => $catalog_id, 'directory' => 'test-directory']; $mock_editor = $this->getMockBuilder(Editor::class)->disableOriginalConstructor()->getMock(); $mock_editor->expects($this->once())->method('getSettings')->willReturn($editor_settings); $mock_editor_storage = $this->getMockBuilder(EntityStorageInterface::class)->disableOriginalConstructor()->getMock(); $mock_editor_storage->expects($this->once())->method('load')->with(self::MOCK_FILTER_ID)->willReturn($mock_editor); $mock_catalog = $this->getMockBuilder(EmbridgeCatalog::class)->disableOriginalConstructor()->getMock(); $mock_catalog->expects($this->any())->method('getApplicationId')->willReturn('test_application'); $mock_catalog->expects($this->once())->method('getConversionsArray')->willReturn(['thumb', 'medium', 'large']); $mock_catalog_storage = $this->getMockBuilder(EntityStorageInterface::class)->disableOriginalConstructor()->getMock(); $mock_catalog_storage->expects($this->once())->method('load')->with($catalog_id)->willReturn($mock_catalog); $map = [['editor', $mock_editor_storage], ['embridge_catalog', $mock_catalog_storage]]; if ($asset) { $mock_asset_storage = $this->getMockBuilder(EntityStorageInterface::class)->disableOriginalConstructor()->getMock(); $mock_asset_storage->expects($this->once())->method('load')->willReturn($asset); $map[] = ['embridge_asset_entity', $mock_asset_storage]; } $this->entityTypeManager->expects($this->exactly(count($map)))->method('getStorage')->will($this->returnValueMap($map)); }