Skip to content

Commit

Permalink
Merge pull request #72 from catalyst/issue#31
Browse files Browse the repository at this point in the history
Issue#31 Fix issue with type extension
  • Loading branch information
ScottVerbeek authored Jan 22, 2024
2 parents 4bff5f9 + f81d3d8 commit a58d605
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 0 deletions.
4 changes: 4 additions & 0 deletions classes/converter.php
Original file line number Diff line number Diff line change
Expand Up @@ -418,6 +418,10 @@ public function poll_conversion_status(conversion $conversion) {
* @return bool
*/
public static function supports($from, $to) {
// Make sure we receive the extensions in lowercase.
$from = strtolower($from);
$to = strtolower($to);

// This is not a one-liner because of php 5.6.
$imports = self::$imports;
$exports = self::$exports;
Expand Down
45 changes: 45 additions & 0 deletions tests/converter_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -546,4 +546,49 @@ public function test_conversion_record_deduplication() {
$task->execute();
$this->assertEquals(2, $DB->count_records('file_conversion'));
}

/**
* Data provider for test_supports
* Supported formats: 'doc', 'docx', 'rtf', 'xls', 'xlsx', 'ppt', 'pptx', 'html', 'odt',
* 'ods', 'txt', 'png', 'jpg', 'gif', 'pdf'
*
* @return array
*/
public function supports_provider() {
return [
['doc', true], ['DOC', true],
['docx', true], ['DOCX', true],
['rtf', true], ['RTF', true],
['xls', true], ['XLS', true],
['xlsx', true], ['XLSX', true],
['ppt', true], ['PPT', true],
['pptx', true], ['PPTX', true],
['html', true], ['HTML', true],
['odt', true], ['ODT', true],
['ods', true], ['ODS', true],
['txt', true], ['TXT', true],
['png', true], ['PNG', true],
['jpg', true], ['JPG', true],
['gif', true], ['GIF', true],
['pdf', false], ['PDF', false],
['mp3', false], ['MP3', false],
['mp4', false], ['MP4', false],
];
}

/**
* Test supports method of converter class.
*
* @covers \fileconverter_librelambda\converter::supports
* @dataProvider supports_provider
*
* @param string $format The format to test.
* @param bool $expected The expected result.
*
*/
public function test_supports($format, $expected) {
// Check supported format.
$this->assertEquals($expected, \fileconverter_librelambda\converter::supports($format, 'pdf'));
$this->assertEquals($expected, \fileconverter_librelambda\converter::supports($format, 'PDF'));
}
}

0 comments on commit a58d605

Please sign in to comment.