2
2
3
3
namespace App \Tests \unit \src \Markdown \Parser ;
4
4
5
- use App \Markdown \Parser \QuestionParser ;
5
+ use App \Markdown \Parser \DocumentExtractor ;
6
6
use PHPUnit \Framework \TestCase ;
7
7
8
- class QuestionParserTest extends TestCase
8
+ class QuestionExtractorTest extends TestCase
9
9
{
10
- private string $ document = '<h1>This is the question</h1>
11
- <p>An example</p>
12
- <pre><code class="language-php"><?php echo "hello world";
13
- // Hello</code></pre>
14
- <p>Another example</p>
15
- <pre><code class="language-php"><?php echo "hello world";</code></pre>
16
- <h2>Possible answers</h2>
17
- <ul>
18
- <li>[ ] 3</li>
19
- <li>[ ] 4</li>
20
- <li>[ ] 5</li>
21
- </ul>
22
- <details id="answer">
23
- <summary>
24
- <b>Answer</b>
25
- </summary>
26
- <p>
27
- Answer: <strong>5</strong>
28
- </p>
29
- </details> ' ;
10
+ private string $ document = '' ;
11
+
12
+ public function setUp (): void
13
+ {
14
+ $ filePath = '/var/www/html/tests/unit/src/Markdown/TestFixtures/question.html ' ;
15
+ $ this ->document = file_get_contents ($ filePath );
16
+
17
+ parent ::setUp ();
18
+ }
30
19
31
20
public function testQuestionHeadingValue ()
32
21
{
33
- $ parser = new QuestionParser ($ this ->document );
22
+ $ parser = new DocumentExtractor ($ this ->document );
34
23
$ parser ->extract ();
35
24
$ questionNodes = $ parser ->getQuestionNodes ();
36
25
@@ -39,7 +28,7 @@ public function testQuestionHeadingValue()
39
28
40
29
public function testQuestionHeadingElement ()
41
30
{
42
- $ parser = new QuestionParser ($ this ->document );
31
+ $ parser = new DocumentExtractor ($ this ->document );
43
32
$ parser ->extract ();
44
33
$ questionNodes = $ parser ->getQuestionNodes ();
45
34
@@ -48,7 +37,7 @@ public function testQuestionHeadingElement()
48
37
49
38
public function testLastQuestionElement ()
50
39
{
51
- $ parser = new QuestionParser ($ this ->document );
40
+ $ parser = new DocumentExtractor ($ this ->document );
52
41
$ parser ->extract ();
53
42
$ questionNodes = $ parser ->getQuestionNodes ();
54
43
$ count = count ($ questionNodes ) -1 ;
@@ -58,7 +47,7 @@ public function testLastQuestionElement()
58
47
59
48
public function testLastQuestionValue ()
60
49
{
61
- $ parser = new QuestionParser ($ this ->document );
50
+ $ parser = new DocumentExtractor ($ this ->document );
62
51
$ parser ->extract ();
63
52
$ questionNodes = $ parser ->getQuestionNodes ();
64
53
$ count = count ($ questionNodes ) -1 ;
0 commit comments