summaryrefslogtreecommitdiff
path: root/www/wiki/extensions/SemanticMediaWiki/tests/phpunit/Unit/DataValues/ValueParsers/TimeValueParserTest.php
diff options
context:
space:
mode:
Diffstat (limited to 'www/wiki/extensions/SemanticMediaWiki/tests/phpunit/Unit/DataValues/ValueParsers/TimeValueParserTest.php')
-rw-r--r--www/wiki/extensions/SemanticMediaWiki/tests/phpunit/Unit/DataValues/ValueParsers/TimeValueParserTest.php88
1 files changed, 88 insertions, 0 deletions
diff --git a/www/wiki/extensions/SemanticMediaWiki/tests/phpunit/Unit/DataValues/ValueParsers/TimeValueParserTest.php b/www/wiki/extensions/SemanticMediaWiki/tests/phpunit/Unit/DataValues/ValueParsers/TimeValueParserTest.php
new file mode 100644
index 00000000..732097a5
--- /dev/null
+++ b/www/wiki/extensions/SemanticMediaWiki/tests/phpunit/Unit/DataValues/ValueParsers/TimeValueParserTest.php
@@ -0,0 +1,88 @@
+<?php
+
+namespace SMW\Tests\DataValues\ValueParsers;
+
+use SMW\DataValues\Time\Components;
+use SMW\DataValues\ValueParsers\TimeValueParser;
+
+/**
+ * @covers \SMW\DataValues\ValueParsers\TimeValueParser
+ * @group semantic-mediawiki
+ *
+ * @license GNU GPL v2+
+ * @since 3.0
+ *
+ * @author mwjames
+ */
+class TimeValueParserTest extends \PHPUnit_Framework_TestCase {
+
+ public function testCanConstruct() {
+
+ $this->assertInstanceOf(
+ TimeValueParser::class,
+ new TimeValueParser()
+ );
+ }
+
+ /**
+ * @dataProvider valueProvider
+ */
+ public function testParse( $value, $expected, $errors ) {
+
+ $instance = new TimeValueParser();
+
+ $this->assertEquals(
+ new Components( $expected ),
+ $instance->parse( $value )
+ );
+
+ $this->assertEquals(
+ $errors,
+ $instance->getErrors()
+ );
+ }
+
+ public function valueProvider() {
+
+ yield [
+ '1 Jan 1970',
+ [
+ 'value' => '1 Jan 1970',
+ 'datecomponents' => [
+ '1', 'Jan', '1970'
+ ],
+ 'calendarmodel' => false,
+ 'era' => false,
+ 'hours' => false,
+ 'minutes' => false,
+ 'seconds' => false,
+ 'microseconds' => false,
+ 'timeoffset' => 0,
+ 'timezone' => false
+ ],
+ []
+ ];
+
+ // JD value
+ yield [
+ '2458119.500000',
+ [
+ 'value' => '2458119.500000',
+ 'datecomponents' => [
+ '2458119', '500000'
+ ],
+ 'calendarmodel' => 'JD',
+ 'era' => false,
+ 'hours' => false,
+ 'minutes' => false,
+ 'seconds' => false,
+ 'microseconds' => false,
+ 'timeoffset' => 0,
+ 'timezone' => false
+ ],
+ []
+ ];
+
+ }
+
+}