Skip to content

Commit

Permalink
Remove format, it should be detected automatically
Browse files Browse the repository at this point in the history
  • Loading branch information
mantas-done committed Jul 24, 2023
1 parent 470a8bb commit aeb46da
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 17 deletions.
4 changes: 2 additions & 2 deletions tests/formats/CsvTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public function testClientAnsiFile()
*/
public function testDifferentContentSeparators($string)
{
$actual_internal_format = Subtitles::loadFromString($string, 'csv')->getInternalFormat();
$actual_internal_format = Subtitles::loadFromString($string)->getInternalFormat();
$expected_internal_format = (new Subtitles())
->add(1, 2, ['Oh! Can I believe my eyes!'])
->add(2, 3, ['If Heaven and earth.'])->getInternalFormat();
Expand Down Expand Up @@ -91,7 +91,7 @@ public function testParseFileWithSingleTimestamp()
00:00:01 One
00:00:02 Two
TEXT;
$actual_internal_format = Subtitles::loadFromString($string, 'csv')->getInternalFormat();
$actual_internal_format = Subtitles::loadFromString($string)->getInternalFormat();
$expected_internal_format = (new Subtitles())
->add(1, 2, ['One'])
->add(2, 3, ['Two'])->getInternalFormat();
Expand Down
4 changes: 2 additions & 2 deletions tests/formats/SbvTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public function testFileToInternalFormat()
Because every child in our society is
a part of that society
TEXT;
$actual_internal_format = Subtitles::loadFromString($actual_file_content, 'sbv')->getInternalFormat();
$actual_internal_format = Subtitles::loadFromString($actual_file_content)->getInternalFormat();
$expected_internal_format = [[
'start' => 340,
'end' => 346,
Expand Down Expand Up @@ -95,7 +95,7 @@ public function testParseMultipleNewLines()
Lisa...Mona Lisa.
TEXT;

$actual_internal_format = Subtitles::loadFromString($actual_file_content, 'sbv')->getInternalFormat();
$actual_internal_format = Subtitles::loadFromString($actual_file_content)->getInternalFormat();
$expected_internal_format = [[
'start' => 64.927,
'end' => 66.927,
Expand Down
6 changes: 2 additions & 4 deletions tests/formats/SrtTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ class SrtTest extends TestCase {

use AdditionalAssertionsTrait;

protected $format = 'srt';

public function testRecognizesSrt()
{
$content = file_get_contents('./tests/files/srt.srt');
Expand All @@ -36,14 +34,14 @@ public function testConvertingFileFromSrtToSrtDoesNotChangeItContent()

public function testFileToInternalFormat()
{
$actual_internal_format = Subtitles::loadFromString(self::fileContent(), $this->format)->getInternalFormat();
$actual_internal_format = Subtitles::loadFromString(self::fileContent())->getInternalFormat();

$this->assertInternalFormatsEqual(self::generatedSubtitles()->getInternalFormat(), $actual_internal_format);
}

public function testConvertToFile()
{
$actual_file_content = self::generatedSubtitles()->content($this->format);
$actual_file_content = self::generatedSubtitles()->content('srt');

$this->assertStringEqualsStringIgnoringLineEndings(self::fileContent(), $actual_file_content);
}
Expand Down
2 changes: 1 addition & 1 deletion tests/formats/TxtQuickTimeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public function testConvertingToFormat()

public function testConvertingToInternalFormat()
{
$actual = Subtitles::loadFromString($this->qttxt, 'txt_quicktime')->getInternalFormat();
$actual = Subtitles::loadFromString($this->qttxt)->getInternalFormat();

$expected = (new Subtitles())
->add(137.44, 140.375, ['Senator, we\'re making', 'our final approach into Coruscant.'])
Expand Down
16 changes: 8 additions & 8 deletions tests/formats/VttTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public function testConvertToInternalFormatWhenFileContainsNumbers() // numbers
Roger Bingham: We are in New York City
TEXT;

$actual_vtt_file_content = (new Subtitles())->loadFromString($input_vtt_file_content, 'vtt')->content('vtt');
$actual_vtt_file_content = (new Subtitles())->loadFromString($input_vtt_file_content)->content('vtt');

$this->assertStringEqualsStringIgnoringLineEndings($expected_vtt_file_content, $actual_vtt_file_content);
}
Expand Down Expand Up @@ -113,7 +113,7 @@ public function testFileContainingMultipleNewLinesBetweenBlocks()
00:00:01.000 --> 00:00:02.000
text2
TEXT;
$actual = (new Subtitles())->loadFromString($given, 'vtt')->getInternalFormat();
$actual = (new Subtitles())->loadFromString($given)->getInternalFormat();

$expected = (new Subtitles())
->add(0, 1, 'text1')
Expand All @@ -126,7 +126,7 @@ public function testFileContainingMultipleNewLinesBetweenBlocks()
public function testParsesFileWithStyles()
{
$given = file_get_contents('./tests/files/vtt_with_styles.vtt');
$actual = (new Subtitles())->loadFromString($given, 'vtt')->getInternalFormat();
$actual = (new Subtitles())->loadFromString($given)->getInternalFormat();

$expected = (new Subtitles())
->add(0, 10, 'Hello world.')
Expand All @@ -138,7 +138,7 @@ public function testParsesFileWithStyles()
public function testParsesFileWithHtml()
{
$given = file_get_contents('./tests/files/vtt_with_html.vtt');
$actual = (new Subtitles())->loadFromString($given, 'vtt')->getInternalFormat();
$actual = (new Subtitles())->loadFromString($given)->getInternalFormat();

$expected = (new Subtitles())
->add(0.0, 10.0, 'Sur les playground, ici à Montpellier')
Expand All @@ -150,7 +150,7 @@ public function testParsesFileWithHtml()
public function testParsesFileWithoutHoursInTimestamp()
{
$given = file_get_contents('./tests/files/vtt_without_hours_in_timestamp.vtt');
$actual = (new Subtitles())->loadFromString($given, 'vtt')->getInternalFormat();
$actual = (new Subtitles())->loadFromString($given)->getInternalFormat();

$expected = (new Subtitles())
->add(0.0, 10.0, "I've spent nearly two decades")
Expand All @@ -162,7 +162,7 @@ public function testParsesFileWithoutHoursInTimestamp()
public function testParsesFileWithMultipleNewLines()
{
$given = file_get_contents('./tests/files/vtt_with_multiple_new_lines.vtt');
$actual = (new Subtitles())->loadFromString($given, 'vtt')->getInternalFormat();
$actual = (new Subtitles())->loadFromString($given)->getInternalFormat();
$expected = (new Subtitles())
->add(0.0, 1.0, ['one', 'two'])
->add(2.0, 3.0, 'three')
Expand All @@ -180,7 +180,7 @@ public function testParseFileWithMetadata()
00:00:00.000 --> 00:00:01.000
text1
TEXT;
$actual = (new Subtitles())->loadFromString($given, 'vtt')->getInternalFormat();
$actual = (new Subtitles())->loadFromString($given)->getInternalFormat();
$expected = (new Subtitles())
->add(0, 1, 'text1')
->getInternalFormat();
Expand All @@ -196,7 +196,7 @@ public function testParseFileWithSpacesBetweenTimestamps()
00:00:00.100 --> 00:00:01.100
text1
TEXT;
$actual = (new Subtitles())->loadFromString($given, 'vtt')->getInternalFormat();
$actual = (new Subtitles())->loadFromString($given)->getInternalFormat();
$expected = (new Subtitles())
->add(0.1, 1.1, 'text1')
->getInternalFormat();
Expand Down

0 comments on commit aeb46da

Please sign in to comment.