summaryrefslogtreecommitdiff
path: root/extensions/TimedMediaHandler/tests/phpunit/TestTimeParsing.php
diff options
context:
space:
mode:
authorAndré Fabian Silva Delgado <emulatorman@parabola.nu>2016-07-15 15:33:36 -0300
committerAndré Fabian Silva Delgado <emulatorman@parabola.nu>2016-07-15 15:33:36 -0300
commita5f917bbc55e295896b8084f6657eb8b6abaf8a8 (patch)
tree83dca14378e45b11fe6bbf1d17e64505dff43cbd /extensions/TimedMediaHandler/tests/phpunit/TestTimeParsing.php
parenta1d705e541e0d10baa6bb03935ffd38d9478d0e6 (diff)
Add TimedMediaHandler extension that allows display audio and video files in wiki pages, using the same syntax as for image files
Diffstat (limited to 'extensions/TimedMediaHandler/tests/phpunit/TestTimeParsing.php')
-rw-r--r--extensions/TimedMediaHandler/tests/phpunit/TestTimeParsing.php42
1 files changed, 42 insertions, 0 deletions
diff --git a/extensions/TimedMediaHandler/tests/phpunit/TestTimeParsing.php b/extensions/TimedMediaHandler/tests/phpunit/TestTimeParsing.php
new file mode 100644
index 00000000..b4ec6ba9
--- /dev/null
+++ b/extensions/TimedMediaHandler/tests/phpunit/TestTimeParsing.php
@@ -0,0 +1,42 @@
+<?php
+/**
+ * TestTimeParsing test .
+ *
+ * @ingroup timedmedia
+ * @since 0.2
+ * @author Michael Dale
+ */
+
+
+class TestTimeParsing extends PHPUnit_Framework_TestCase {
+ /**
+ * Test time string to np2
+ */
+ function testSeconds2NptFormat() {
+ // Some time conversions:
+ $this->assertEquals( TimedMediaHandler::seconds2npt( 100 ), '0:1:40' );
+ $this->assertEquals( TimedMediaHandler::seconds2npt( 0 ), '0:0:0' );
+ $this->assertEquals( TimedMediaHandler::seconds2npt( 3601 ), '1:0:1' );
+
+ // Test failures:
+ $this->assertEquals( TimedMediaHandler::seconds2npt( 'foo' ), false );
+ $this->assertEquals( TimedMediaHandler::seconds2npt( -1 ), false );
+ }
+
+ /**
+ * Test time parsing to seconds
+ */
+ function testParseTimeString() {
+ // Some time conversions:
+ $this->assertEquals( TimedMediaHandler::parseTimeString( 100 ), 100 );
+ $this->assertEquals( TimedMediaHandler::parseTimeString( '1:0:0' ), 3600 );
+ $this->assertEquals( TimedMediaHandler::parseTimeString( -1 ), 0 );
+ // Test longer than duration check ( should return time -1 )
+ $this->assertEquals( TimedMediaHandler::parseTimeString( 10, 9 ), 8 );
+
+ // Test failures:
+ $this->assertEquals( TimedMediaHandler::parseTimeString( '1:1:1:1' ), false );
+ $this->assertEquals( TimedMediaHandler::parseTimeString( 'abc' ), false );
+
+ }
+} \ No newline at end of file