Skip to content

Commit

Permalink
Add separate *.ttml file extension parse test
Browse files Browse the repository at this point in the history
  • Loading branch information
eijei521 committed Jun 22, 2023
1 parent 9b8a1c9 commit 2e9d6e2
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 1 deletion.
21 changes: 21 additions & 0 deletions tests/files/ttml_with_duplicated_element_ids.ttml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<tt xml:lang="en"
xmlns="http://www.w3.org/ns/ttml"
xmlns:tts="http://www.w3.org/ns/ttml#styling">
<head>
<metadata xmlns:ttm="http://www.w3.org/ns/ttml#metadata">
<ttm:title>TTML Example With Duplicated Element Ids</ttm:title>
<ttm:copyright>Thierry Michel 2015</ttm:copyright>
</metadata>

<styling xmlns:tts="http://www.w3.org/ns/ttml#styling">
<style xml:id="s1" tts:color="red" tts:textAlign="center" />
</styling>
</head>
<body>
<div>
<p xml:id="c1" begin="00:00:00" end="00:00:01">First line.</p>
<p xml:id="c1" begin="00:00:01" end="00:00:02">Second line.</p>
<p xml:id="c3" begin="00:00:02" end="00:00:03">Third line.</p>
</div>
</body>
</tt>
2 changes: 1 addition & 1 deletion tests/files/ttml_with_mixed_timestamps.ttml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ xmlns:tts="http://www.w3.org/ns/ttml#styling">
<div>
<p xml:id="c1" begin="00:00:00" end="00:00:10">First line.</p>
<p xml:id="c2" begin="00:00:11.200" end="00:00:13.300">Second line.</p>
<p xml:id="c2" begin="15s" end="18s">Third line.</p>
<p xml:id="c3" begin="15s" end="18s">Third line.</p>
</div>
</body>
</tt>
11 changes: 11 additions & 0 deletions tests/formats/TtmlTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,18 @@ public function testDifferentTimestampParse()
->add(15, 18, ['Third line.'])
->getInternalFormat();
$this->assertInternalFormatsEqual($expected, $actual);
}

public function testDuplicatedElementIdsParse()
{
$ttml_path = './tests/files/ttml_with_duplicated_element_ids.ttml';
$actual = Subtitles::loadFromFile($ttml_path)->getInternalFormat();
$expected = (new Subtitles())
->add(0, 1, 'First line.')
->add(1, 2, ['Second line.'])
->add(2, 3, ['Third line.'])
->getInternalFormat();
$this->assertInternalFormatsEqual($expected, $actual);
}

}

0 comments on commit 2e9d6e2

Please sign in to comment.