ILIAS  trunk Revision v11.0_alpha-2658-ge2404539063
WordOnlyMarkdownShapeTest.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
23 use ILIAS\Data;
27 
29 {
31 
32  protected function setUp(): void
33  {
34  $markup = $this->createMock(Data\Text\Markup::class);
35  $language = $this->createMock(ilLanguage::class);
36  $data_factory = new Data\Factory();
37  $refinery = new ILIAS\Refinery\Factory($data_factory, $language);
38  $this->word_only_markdown_shape = new WordOnlyMarkdown(new \ILIAS\Refinery\String\MarkdownFormattingToHTML());
39  }
40 
41  public static function constructDataProvider(): array
42  {
43  return [
44  [Structure::BOLD, Structure::ITALIC]
45  ];
46  }
47 
48  public static function stringComplianceDataProvider(): array
49  {
50  return [
51  ["This text has **bold** and _italic_ content", true],
52  ["> Quote block is not allowed", false],
53  ["Paragraphs\n\nare not allowed.", false],
54  ["Line breaks\\\nare not allowed.", false],
55  ["Also these \nline breaks are not allowed.", false]
56  ];
57  }
58 
59  #[\PHPUnit\Framework\Attributes\DataProvider('constructDataProvider')]
60  public function testGetSupportedStructure(Structure $dp_bold, Structure $dp_italic): void
61  {
62  $supported_structure = $this->word_only_markdown_shape->getSupportedStructure();
63  $exptected = [
64  $dp_bold,
65  $dp_italic
66  ];
67 
68  $this->assertEquals($exptected, $supported_structure);
69  }
70 
71  #[\PHPUnit\Framework\Attributes\DataProvider('stringComplianceDataProvider')]
72  public function testIsRawStringCompliant(string $markdown_string, bool $compliance): void
73  {
74  $this->assertEquals($compliance, $this->word_only_markdown_shape->isRawStringCompliant($markdown_string));
75  }
76 }
Interface Observer Contains several chained tasks and infos about them.
testGetSupportedStructure(Structure $dp_bold, Structure $dp_italic)
testIsRawStringCompliant(string $markdown_string, bool $compliance)