ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
WordOnlyMarkdownShapeTest.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
21use PHPUnit\Framework\TestCase;
23use ILIAS\Data;
24use ILIAS\Refinery\Factory as Refinery;
25use PHPUnit\Framework\MockObject\MockObject;
27
28class WordOnlyMarkdownShapeTest extends TestCase
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}
Builds data types.
Definition: Factory.php:36
testGetSupportedStructure(Structure $dp_bold, Structure $dp_italic)
testIsRawStringCompliant(string $markdown_string, bool $compliance)
Interface Observer \BackgroundTasks Contains several chained tasks and infos about them.